Detect Databases in Splunk
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.
MITRE ATT&CK
- Tactic
- Collection
- Technique
- T1213 Data from Information Repositories
- Sub-technique
- T1213.006 Databases
- Canonical reference
- https://attack.mitre.org/techniques/T1213/006/
SPL Detection Query
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
| eval ImageLower=lower(Image), ParentImageLower=lower(ParentImage), CmdLower=lower(CommandLine)
| eval IsDumpTool=if(match(ImageLower, "(mysqldump|pg_dump|pg_dumpall|mongodump|sqlite3)(\.exe)?$"), 1, 0)
| eval IsDBClient=if(match(ImageLower, "(\\\\)(mysql|sqlcmd|psql|mongo|mongosh|osql|bcp|isql)(\.exe)?$"), 1, 0)
| eval IsWebServerParent=if(match(ParentImageLower, "(w3wp|php-cgi|php|httpd|nginx|tomcat|java)(\.exe)?$"), 1, 0)
| eval IsSuspiciousScriptParent=if(match(ParentImageLower, "(wscript|cscript|mshta|rundll32|regsvr32)(\.exe)?$"), 1, 0)
| eval HasBulkFlag=if(match(CmdLower, "(--all-databases|-a\s+|--databases|into outfile|into dumpfile|select \\* from|-e\s+.{0,5}select|-q\s+.{0,5}select)"), 1, 0)
| where (IsDumpTool=1)
OR (IsDBClient=1 AND IsWebServerParent=1)
OR (IsDBClient=1 AND HasBulkFlag=1)
OR (IsDBClient=1 AND IsSuspiciousScriptParent=1)
| eval DetectionType=case(
IsDumpTool=1 AND IsWebServerParent=1, "WebShellDumpToolExecution",
IsDumpTool=1, "DatabaseDumpToolExecution",
IsDBClient=1 AND IsWebServerParent=1, "WebShellDatabaseClientAccess",
IsDBClient=1 AND IsSuspiciousScriptParent=1, "ScriptEngineSpawnedDBClient",
IsDBClient=1 AND HasBulkFlag=1, "BulkDatabaseExtraction",
true(), "DatabaseCollectionActivity"
)
| eval RiskScore=IsDumpTool + IsWebServerParent + IsSuspiciousScriptParent + HasBulkFlag
| table _time, host, User, Image, CommandLine, ParentImage, ParentCommandLine,
DetectionType, RiskScore, IsWebServerParent, HasBulkFlag, IsSuspiciousScriptParent
| sort - RiskScore, - _time Detects database collection activity using Sysmon Event ID 1 (Process Creation) logs. Evaluates each process creation against four detection categories: database dump tool execution (mysqldump, pg_dump, mongodump), database clients spawned by web server processes (Adminer/webshell pattern), database clients with bulk extraction flags or inline SELECT queries, and database clients spawned by suspicious scripting engines. A cumulative RiskScore field aggregates multiple concurrent risk factors, allowing analysts to prioritize events where several indicators are present simultaneously. Results are sorted by RiskScore descending to surface the highest-confidence events first.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Scheduled database backup jobs executing mysqldump, pg_dump, or mongodump under a service account — verify against backup schedule and authorized service account list
- CI/CD pipeline agents (Jenkins, GitLab Runner, TeamCity) invoking database clients for automated schema migrations, seed data loading, or integration test setup
- Database health monitoring tools (Nagios check_mysql, pg_activity, MongoDB Atlas agent) running as background services that periodically invoke database clients
- Developer workstations where engineers use database clients interactively — exclude known developer hostnames or user accounts from the alert
- Application servers using embedded database engines (SQLite, H2) where java.exe or python.exe may appear as a parent of sqlite3.exe during normal operation
Other platforms for T1213.006
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1MySQL Full Database Dump via mysqldump
Expected signal: Sysmon Event ID 1: Process Create with Image=mysqldump.exe, CommandLine containing '--all-databases' and '-p'. Sysmon Event ID 3: Network Connection to 127.0.0.1:3306 (or configured MySQL port). Sysmon Event ID 11: File Create for %TEMP%\db_dump_test.sql. Security Event ID 4688 (if command-line auditing enabled) with same process details.
- Test 2SQL Server Schema and User Enumeration via sqlcmd
Expected signal: Sysmon Event ID 1: Process Create with Image=sqlcmd.exe, CommandLine containing '-Q' and 'SELECT' and '-S'. Sysmon Event ID 3: Network Connection to localhost:1433. Sysmon Event ID 11: File Create for %TEMP%\sql_enum_test.txt. PowerShell ScriptBlock Logging will not capture this as it is a native executable.
- Test 3PostgreSQL Database Export via pg_dump
Expected signal: Auditd process execution event for pg_dump with arguments. Syslog entry from PostgreSQL server: connection received from 127.0.0.1, authentication succeeded for user 'postgres'. Network socket activity on TCP 5432. File creation of /tmp/pg_dump_test.backup. If Sysmon for Linux is deployed: Event ID 1 with Image=pg_dump and full CommandLine.
- Test 4Simulated Adminer Webshell Database Access (PowerShell Mimicry)
Expected signal: Sysmon Event ID 1: Process Create with Image=mysql.exe, ParentImage=powershell.exe (in production this would be w3wp.exe or php.exe). CommandLine contains '-e' and 'SELECT'. Sysmon Event ID 3: Network connection to 127.0.0.1:3306 from mysql.exe.
References (10)
- https://attack.mitre.org/techniques/T1213/006/
- https://cloud.google.com/blog/topics/threat-intelligence/unc5537-snowflake-data-theft-extortion
- https://www.mandiant.com/resources/blog/fin6-cybercrime-group-expands-threat-financial-sector
- https://www.welivesecurity.com/en/eset-research/evasive-panda-apt-group-targets-china-leveled-government-agencies/
- https://hunt.io/blog/sea-turtle-cyberattack-targets-dutch-it-and-telecom-companies
- https://www.anssi.fr/en/actualite-de-lANSSI/sandworm-intrusion-set-campaign-targeting-centreon-systems
- https://learn.microsoft.com/en-us/azure/azure-sql/database/threat-detection-overview
- https://docs.snowflake.com/en/user-guide/access-history
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1213.006/T1213.006.md
- https://www.elastic.co/guide/en/security/current/database-content-discovery-via-adminer.html
Unlock Pro Content
Get the full detection package for T1213.006 including response playbook, investigation guide, and atomic red team tests.