Join our Newsletter — 33% off our NHI Course
Home› Guides› Database Audit Log Detection Guide: Turning Engine Audit…
Guide SOC & Detection Engineering

Database Audit Log Detection Guide: Turning Engine Audit Trails Into Reliable Alerts

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 13 min read
On this page

Most database breaches are visible in the database's own audit trail, but in many organisations that trail is switched off, kept on the same server as the data, or never reaches the SOC. Attackers who steal a database or warehouse credential, abuse an application account through SQL injection, or misuse administrator rights all leave logins, permission changes and unusual queries behind. Detection engineers usually start from the log they have, so this guide is organised by log source: what SQL Server Audit, Oracle Unified Auditing, PostgreSQL and pgAudit, MySQL, MongoDB, Amazon RDS Database Activity Streams and Snowflake actually record, how those events map to ATT&CK, which detections are worth building, and how to keep the logs trustworthy when the administrators are in scope. It is for detection engineers, SOC analysts and database administrators. For the wider control set see the Database Security Guide.

Key takeaways

  • Nothing is captured until you define it. SQL Server audits are created disabled, pgAudit logs nothing at its default, MySQL Enterprise Audit is an Enterprise Edition feature and Database Activity Streams capture only the policies you activate.
  • Start with identity events, not query text. Logins, failed logins, role membership changes, new principals and audit configuration changes are low volume and catch most credential abuse.
  • Superusers can blind local auditing. The pgAudit documentation states superusers cannot be reliably audited; ship logs off the host quickly and use platform features that DBAs cannot change, such as Activity Streams.
  • Audit logs can leak secrets. Statement logging can record plaintext passwords and sensitive literals, so the audit store needs its own access control.
  • Service accounts are the baseline that matters. Application and integration logins are predictable; a service account logging in from a new address or client tool is one of the strongest signals in this data.

What each engine records

Engine or serviceAudit mechanismDefault stateSecurity-relevant eventsDestination
Microsoft SQL Server and Azure SQLSQL Server Audit: server audit plus server and database audit specifications built from action groupsAudits are disabled when createdFAILED_LOGIN_GROUP, SUCCESSFUL_LOGIN_GROUP, SERVER_ROLE_MEMBER_CHANGE_GROUP, SERVER_PRINCIPAL_CHANGE_GROUP, DATABASE_PERMISSION_CHANGE_GROUP, AUDIT_CHANGE_GROUP, BACKUP_RESTORE_GROUP, SCHEMA_OBJECT_ACCESS_GROUPAudit file, or Windows Security or Application log
Oracle DatabaseUnified Auditing; records in the AUDSYS schema, read through UNIFIED_AUDIT_TRAILORA_SECURECONFIG and ORA_LOGON_FAILURES enabled for new databasesLogon failures, security configuration changes, plus custom policies from CREATE AUDIT POLICY and AUDIT POLICYDatabase table; export to SIEM
PostgreSQLCore logging (log_connections, log_disconnections, log_statement) plus the pgAudit extensionlog_connections empty, log_statement = none, pgaudit.log = noneConnection receipt, authentication and authorisation; pgAudit classes ROLE, DDL, READ, WRITE, FUNCTION, MISCstderr, csvlog, jsonlog or syslog
MySQLMySQL Enterprise Audit (audit_log plugin) in Enterprise Edition; community builds rely on other plugins or the general query logNot installed by defaultConnects, disconnects, databases and tables accessed, optional query statisticsaudit.log (new-style XML by default, audit_log_format to change)
MongoDBAuditing in Enterprise Advanced and Atlas (M10 and larger)Off until a destination is setauthenticate, createUser, DDL; CRUD only with auditAuthorizationSuccessConsole, syslog, JSON or BSON file
Amazon RDS for Oracle and SQL ServerDatabase Activity StreamsNothing captured until audit policies are activeWhatever the engine's policies capture, as JSON DatabaseActivityMonitoringRecord eventsKinesis data stream encrypted with a KMS key
SnowflakeAccount Usage views such as LOGIN_HISTORY, plus query and access history viewsAlways on; up to 120 minutes latency for LOGIN_HISTORYCLIENT_IP, REPORTED_CLIENT_TYPE, FIRST_AUTHENTICATION_FACTOR, SECOND_AUTHENTICATION_FACTOR, IS_SUCCESSViews queried by the SIEM or a connector; 365 days

Engine-specific hardening is covered in the Microsoft SQL Server Security Guide, Oracle Database Security Guide, PostgreSQL Security Guide, MySQL Security Guide and MongoDB Security Guide.

Mapping attacker behaviour to database events

ATT&CK v20 ties detections to data components. Database audit trails mostly supply DC0002 User Account Authentication, DC0014 User Account Creation, DC0010 User Account Modification and DC0038 Application Log Content.

BehaviourATT&CKEvents to use
Password guessing or spraying against database loginsT1110 Brute ForceSQL Server FAILED_LOGIN_GROUP; Oracle ORA_LOGON_FAILURES; PostgreSQL authentication failures with log_connections; Snowflake IS_SUCCESS = FALSE
Use of a stolen database or warehouse credentialT1078 Valid Accounts, T1078.004 Cloud AccountsSuccessful logins with new source address, new client type, missing second factor
Creating a backdoor login or granting privilegesT1136 Create Account, T1098 Account ManipulationSERVER_PRINCIPAL_CHANGE_GROUP, SERVER_ROLE_MEMBER_CHANGE_GROUP, DATABASE_ROLE_MEMBER_CHANGE_GROUP; pgAudit ROLE; MongoDB createUser
Bulk reading of sensitive tablesT1213.006 DatabasesSCHEMA_OBJECT_ACCESS_GROUP on sensitive objects; pgAudit object audit through pgaudit.role with pgaudit.log_rows; Snowflake query history
Persistence through stored procedures or triggersT1505.001 SQL Stored ProceduresDDL events: SQL Server schema change groups, pgAudit DDL, Oracle policies on CREATE PROCEDURE and CREATE TRIGGER
Backups taken or restored to an unexpected placeT1048 Exfiltration Over Alternative ProtocolBACKUP_RESTORE_GROUP; warehouse unload or copy commands to external stages
Destroying or encrypting dataT1485 Data Destruction, T1486 Data Encrypted for ImpactBursts of DROP, TRUNCATE or mass UPDATE from pgAudit DDL and WRITE or engine equivalents
Silently changing recordsT1565.001 Stored Data ManipulationObject-level write auditing on high-value tables
Turning auditing offT1685 Disable or Modify ToolsAUDIT_CHANGE_GROUP (changes to an audit are recorded in that audit); Oracle audit policy changes; gaps in event flow

A baseline audit configuration per engine

Begin with identity and configuration events everywhere, then add object-level auditing only for crown-jewel tables.

  • SQL Server: one server audit with a server audit specification containing FAILED_LOGIN_GROUP, SUCCESSFUL_LOGIN_GROUP, SERVER_ROLE_MEMBER_CHANGE_GROUP, SERVER_PRINCIPAL_CHANGE_GROUP, LOGIN_CHANGE_PASSWORD_GROUP, AUDIT_CHANGE_GROUP and BACKUP_RESTORE_GROUP; database audit specifications with DATABASE_ROLE_MEMBER_CHANGE_GROUP, DATABASE_PERMISSION_CHANGE_GROUP, DATABASE_OBJECT_PERMISSION_CHANGE_GROUP and SCHEMA_OBJECT_ACCESS_GROUP scoped to sensitive schemas. Remember to set STATE = ON. Use BATCH_COMPLETED_GROUP sparingly: it records full batch text, and Microsoft's tables disagree on whether it needs SQL Server 2019 or 2022.
  • Oracle: keep ORA_SECURECONFIG and ORA_LOGON_FAILURES enabled, add policies for privilege grants, user management and DDL on application schemas, and grant AUDIT_ADMIN only to a security role separate from DBAs. Give the SOC AUDIT_VIEWER.
  • PostgreSQL: log_connections = 'receipt,authentication,authorization' (PostgreSQL 18 syntax; older releases take a boolean), log_disconnections = on, a log_line_prefix with user, database, application and client address, and log_destination including jsonlog or csvlog for parsing. Load pgAudit through shared_preload_libraries, run CREATE EXTENSION pgaudit, set pgaudit.log = 'role, ddl', and use pgaudit.role for object auditing of sensitive tables. Set pgaudit.log_catalog = off to cut noise from client tools.
  • MySQL: on Enterprise Edition, install the audit_log plugin with filters for connection events and table access on sensitive schemas. On community builds, use a supported audit plugin from your distribution or vendor rather than the general query log, which records everything and is hard to protect.
  • MongoDB: set an audit destination and filter on atype values such as authenticate, createUser and dropCollection; enable auditAuthorizationSuccess only for targeted collections because it adds load. Note the server terminates if it cannot write to the audit destination, so monitor disk space.
  • Amazon RDS for Oracle and SQL Server: enable Database Activity Streams on the primary, then create and activate the engine audit policies; DAS captures nothing without them.
  • Snowflake: pull LOGIN_HISTORY and query and access history into the SIEM on a schedule that accounts for view latency. See the Snowflake Security Guide.

Rollout order:

  1. Inventory databases and classify them; pick the crown jewels.
  2. Enable identity and configuration auditing on all production instances and confirm events arrive in the SIEM.
  3. Measure volume and performance on a pilot instance for a week before enabling object-level auditing.
  4. Add object-level read and write auditing for sensitive tables only.
  5. Build detections, run them in report-only mode for two to four weeks, then promote to alerting.
  6. Rollback: audit specifications and policies can be disabled individually, so remove the noisiest object policy first rather than turning auditing off.

Detection use cases worth building

  • Service account anomaly: an application or integration login from a source address, host or client type not seen in the last 30 days. Service accounts have stable patterns, so this is high fidelity. See the Database Credential and Access Security Guide.
  • Human login without MFA on a warehouse: Snowflake SECOND_AUTHENTICATION_FACTOR is null for a human user. Treat REPORTED_CLIENT_TYPE as a hint only, because it is self-reported.
  • Failed then successful login: many failures for one login followed by a success from the same source.
  • Privilege change outside change windows: any server role, sysadmin, DBA or superuser grant, and any new login, correlated with your change tickets.
  • Audit tampering: any AUDIT_CHANGE_GROUP event, Oracle audit policy change, pgAudit setting change, or a source that stops sending for longer than its normal interval.
  • Bulk access: row counts or result volumes well above the baseline for that account on sensitive tables, or warehouse unloads to new external locations.
  • Destructive bursts: several DROP or TRUNCATE statements in a short window from one session. Pair this with cloud control plane logs, because deletion can bypass the database entirely: in the PocketOS database deletion an AI coding agent removed a production database and its backups through a single platform API call with an over-scoped token.

Correlate database events with identity provider and network logs: a database login is far more suspicious when the same account had an impossible-travel sign-in an hour earlier.

Tuning noise and volume

Database audit volume grows with workload, and the pgAudit documentation warns that logs can exhaust disk space and add latency to busy transactional systems. Plan for this rather than discovering it in production.

LeverEffectTrade-off
Audit identity and configuration events onlyVery low volume, high signalNo visibility of what data was read
Object-level auditing on named sensitive tables (pgaudit.role, scoped SCHEMA_OBJECT_ACCESS_GROUP, Oracle policies on specific objects)Read and write visibility where it mattersNeeds an accurate data classification to choose the tables
Exclude catalogue and monitoring noise (pgaudit.log_catalog = off, filters for monitoring logins)Removes high-volume, low-value eventsAttackers who masquerade as the monitoring account are harder to see; baseline that account tightly
Log row counts rather than full statements (pgaudit.log_rows)Enables bulk-access detections with less sensitive contentLess detail for forensic reconstruction
Full statement capture (BATCH_COMPLETED_GROUP, log_statement = all)Complete record for investigationsHighest volume and risk of capturing secrets; use for short, targeted periods

Small versus large organisations: a small team with a handful of databases should enable identity events everywhere and object auditing on one or two critical tables, then rely on managed services such as Activity Streams or warehouse views. A large estate needs a central audit standard per engine, deployed as code, with exceptions approved and recorded.

Keeping the audit trail trustworthy

  • Separate duties: the people who administer the database should not administer its audit. Oracle's AUDIT_ADMIN role and RDS Activity Streams, where the documentation states DBAs cannot alter the audit policy or remove audit logs, support this.
  • Ship off-host fast: pgAudit is best-effort and not transactional, and MongoDB may lose buffered events if the server stops. Forward continuously rather than in nightly batches.
  • Protect sensitive content: PostgreSQL warns that logged statements can contain plaintext passwords; keep log_file_mode at 0600 and restrict SIEM indexes holding database statements.
  • Retain long enough to scope: breach scoping often needs months of login history; align retention with your notification obligations. See the CIS Control 8 Audit Log Management Guide.
  • Record enough context: user, client address, application name, database and object for every event, so an analyst can answer who, from where and what without going back to the server.

Measuring coverage

  • Share of production databases sending identity and configuration audit events to the SIEM (target: 100 percent).
  • Share of crown-jewel tables with object-level read auditing.
  • Median delay from event to SIEM availability, per engine.
  • Number of service accounts with a baselined behaviour profile.
  • Silent-source alerts raised and closed within one working day.
  • Detections for the techniques in the mapping table that have been tested with a safe simulation in the last 12 months.

Framework mapping

RequirementNIST SP 800-53 Rev. 5NIST CSF 2.0CIS Controls v8.1ISO/IEC 27001:2022 Annex A
Define and generate database audit eventsAU-2, AU-12PR.PS-04Control 8A.8.15
Content of records (who, where, what)AU-3PR.PS-04Control 8A.8.15
Review and correlateAU-6, SI-4DE.AE-02, DE.AE-03, DE.CM-03Control 8, Control 13A.8.16
Protect audit data from administratorsAU-9PR.PS-04Control 8A.8.15
Retention for investigationAU-11PR.PS-04Control 8A.8.15
Failed logon handlingAC-7DE.CM-03Control 6A.8.5

Common failure patterns

  • Auditing created but never enabled. SQL Server audits and specifications are off until STATE = ON; teams pass a configuration review and capture nothing.
  • Everything or nothing. Turning on full statement logging fills disks and is switched off within a week; start with identity events.
  • Logs stay on the database host. An attacker with superuser rights, or a ransomware operator, removes the evidence along with the data.
  • No baseline for service accounts. Shared application logins used by people and tools make anomaly detection impossible.
  • Warehouse logs ignored. Cloud data platforms log well, but the views are never pulled into the SIEM.
  • Secrets in the audit store. Statement text containing passwords ends up readable by everyone with SIEM access.

Lessons from incidents

In the Snowflake customer breaches of 2024, a threat group used infostealer credentials to log in to customer accounts that had no MFA and no network restrictions, then stole data from around 165 organisations. The behaviour was visible in exactly the fields this guide recommends watching: logins from unfamiliar addresses and commercial VPNs, new client tools, no second factor, and large data copy operations to temporary stages. The lesson is that warehouse login and query history should be in the SIEM with alerts on those conditions before an incident, not exported afterwards for scoping. For the response side see the Database Breach Response Playbook.

Practitioner checklist

  • List every production database and warehouse with its audit mechanism and current state.
  • Enable login, failed login, principal, role and audit-change events on all of them.
  • Add object-level auditing for crown-jewel tables after a volume test.
  • Forward audit events off-host continuously with user, client address, application and object fields.
  • Separate audit administration from database administration.
  • Baseline service account logins and alert on new sources and client types.
  • Alert on any audit configuration change and on silent sources.
  • Restrict access to audit stores that contain statement text.
  • Pull cloud warehouse login and query history into the SIEM on a schedule.
  • Test detections with safe simulations at least yearly.

Standards and references

Related NHI Mgmt Group resources: Database Security Guide · Database Breach Response Playbook · Database Credential and Access Security Guide · CIS Control 8 Audit Log Management Guide

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org