T1213.006

Databases

Adversaries may leverage databases to mine valuable information. These databases may be hosted on-premises or in the cloud (both in platform-as-a-service and software-as-a-service environments). Examples of databases from which information may be collected include MySQL, PostgreSQL, MongoDB, Amazon Relational Database Service, Azure SQL Database, Google Firebase, and Snowflake. Databases may include a variety of information of interest to adversaries, such as usernames, hashed passwords, personally identifiable information, and financial data. Threat actors including Sandworm Team, FIN6, Sea Turtle, and UNC5537 have leveraged database administration tools such as Adminer, mysqldump, and sqlcmd to extract schema definitions, user credentials, and bulk records. Data collected from databases may be used for Lateral Movement, Command and Control, or Exfiltration, and may be used to extort victims or sold for profit.

Microsoft Sentinel / Defender
kusto
let DatabaseDumpTools = dynamic([
    "mysqldump.exe", "mysqldump",
    "pg_dump.exe", "pg_dump",
    "pg_dumpall.exe", "pg_dumpall",
    "mongodump.exe", "mongodump",
    "sqlite3.exe", "sqlite3"
]);
let DatabaseClients = dynamic([
    "mysql.exe", "mysql",
    "sqlcmd.exe", "sqlcmd",
    "psql.exe", "psql",
    "mongo.exe", "mongo",
    "mongosh.exe", "mongosh",
    "osql.exe", "osql",
    "bcp.exe", "bcp",
    "isql.exe", "isql"
]);
let WebServerProcesses = dynamic([
    "w3wp.exe", "php-cgi.exe", "php.exe", "httpd.exe",
    "nginx.exe", "tomcat9.exe", "java.exe"
]);
let SuspiciousScriptEngines = dynamic([
    "wscript.exe", "cscript.exe", "mshta.exe",
    "rundll32.exe", "regsvr32.exe"
]);
let BulkExtractionPatterns = dynamic([
    "--all-databases", "-A ", "--databases",
    "INTO OUTFILE", "into outfile",
    "INTO DUMPFILE", "into dumpfile",
    "SELECT * FROM", "select * from",
    "-e \"SELECT", "-Q \"SELECT",
    "--query", "-q "
]);
// Part 1: Any execution of a database dump/export utility
let DumpToolExec = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName has_any (DatabaseDumpTools)
| extend DetectionType = "DatabaseDumpToolExecution",
         WebShellIndicator = InitiatingProcessFileName has_any (WebServerProcesses),
         SuspiciousParent = InitiatingProcessFileName has_any (SuspiciousScriptEngines);
// Part 2: Database clients spawned directly by web server worker processes (Adminer / P.A.S. webshell pattern)
let WebShellDBAccess = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName has_any (DatabaseClients)
| where InitiatingProcessFileName has_any (WebServerProcesses)
| extend DetectionType = "WebShellDatabaseClientAccess",
         WebShellIndicator = true,
         SuspiciousParent = false;
// Part 3: Database clients with bulk extraction flags or inline query patterns
let BulkExtraction = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName has_any (DatabaseClients)
| where ProcessCommandLine has_any (BulkExtractionPatterns)
| extend DetectionType = "BulkDatabaseExtraction",
         WebShellIndicator = InitiatingProcessFileName has_any (WebServerProcesses),
         SuspiciousParent = InitiatingProcessFileName has_any (SuspiciousScriptEngines);
// Part 4: Database clients spawned by suspicious scripting engines (post-exploitation staging)
let ScriptEngineDBAccess = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName has_any (DatabaseClients)
| where InitiatingProcessFileName has_any (SuspiciousScriptEngines)
| extend DetectionType = "ScriptEngineSpawnedDBClient",
         WebShellIndicator = false,
         SuspiciousParent = true;
// Union all detection patterns
union DumpToolExec, WebShellDBAccess, BulkExtraction, ScriptEngineDBAccess
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         DetectionType, WebShellIndicator, SuspiciousParent
| sort by Timestamp desc
high severity high confidence

Data Sources

Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint

Required Tables

DeviceProcessEvents

False Positives

  • Database administrators legitimately running mysqldump, pg_dump, or mongodump as part of scheduled backup jobs — cross-reference with change management tickets and verify execution time matches backup schedule
  • Application deployment pipelines (CI/CD systems like Jenkins or GitLab runners) running database migration scripts that invoke psql, sqlcmd, or mysql with SELECT/schema queries
  • Monitoring and observability agents (Datadog, Nagios, Zabbix) that invoke database clients to run health check queries against local or remote database instances
  • Developers on workstations using database clients (mysql.exe, psql.exe) interactively for legitimate application development and testing against local or staging databases
  • Java-based application servers (java.exe) that manage their own JDBC database connections may appear as a suspicious parent for database activity in environments without a dedicated DB tier

Unlock Pro Content

Get the full detection package for T1213.006 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections