Detect Malicious Image in IBM QRadar
Adversaries may rely on a user running a malicious image to facilitate execution. Amazon Web Services AMIs, Google Cloud Platform Images, Azure Images, and container runtimes such as Docker can be backdoored. Backdoored images may be uploaded to public repositories, and users may download and deploy an instance or container without realizing the image is malicious. This technique is commonly used to deploy cryptocurrency miners, backdoors, and data exfiltration tools. TeamTNT is a prominent threat actor known for publishing malicious Docker images to Docker Hub containing XMRig cryptocurrency miners and credential stealers. Adversaries may also typosquat popular image names to increase the likelihood of accidental deployment.
MITRE ATT&CK
- Tactic
- Execution
- Technique
- T1204 User Execution
- Sub-technique
- T1204.003 Malicious Image
- Canonical reference
- https://attack.mitre.org/techniques/T1204/003/
QRadar Detection Query
SELECT
DATEFORMAT(devicetime, 'yyyy-MM-dd HH:mm:ss') AS EventTime,
sourceip AS HostIP,
username AS UserName,
"Process Name" AS ProcessName,
"Command" AS CommandLine,
destinationip AS DestIP,
destinationport AS DestPort,
LOGSOURCENAME(logsourceid) AS LogSource,
QIDNAME(qid) AS EventName,
CASE
WHEN "Process Name" ILIKE ANY ('%xmrig%','%minerd%','%cpuminer%','%nbminer%','%t-rex%','%lolminer%','%ethminer%','%cgminer%','%bfgminer%','%phoenixminer%','%teamtntbot%') THEN 'MinerProcessExecution'
WHEN destinationport IN (3333, 3334, 4444, 4445, 14444, 45560, 5555, 8333, 7777, 9999, 13333, 19999) THEN 'MiningPoolNetworkConnection'
WHEN "Command" ILIKE ANY ('%stratum+tcp%','%stratum+ssl%','%donate-level%','%xmrpool%','%supportxmr%','%minexmr%','%moneroocean%','%hashvault%','%nanopool%') THEN 'MinerCommandLineArgs'
WHEN LOGSOURCETYPEID(logsourceid) = 347 AND QIDNAME(qid) ILIKE '%RunInstances%' THEN 'AWSInstanceLaunch'
ELSE 'Unknown'
END AS DetectionBranch
FROM events
WHERE LOGSOURCETYPEID(logsourceid) IN (12, 347, 433)
AND devicetime > (NOW() - 86400000)
AND (
"Process Name" ILIKE ANY ('%xmrig%','%xmrig-notls%','%minerd%','%cpuminer%','%nbminer%','%t-rex%','%lolminer%','%ethminer%','%cgminer%','%bfgminer%','%phoenixminer%','%teamtntbot%','%cryptonight%')
OR "Command" ILIKE ANY ('%stratum+tcp%','%stratum+ssl%','%--donate-level%','%xmrpool%','%supportxmr%','%minexmr%','%moneroocean%','%hashvault%','%nanopool%')
OR (
destinationport IN (3333, 3334, 4444, 4445, 14444, 45560, 5555, 8333, 7777, 9999, 13333, 19999)
AND NOT (destinationip ILIKE '10.%' OR destinationip ILIKE '172.16.%' OR destinationip ILIKE '172.17.%' OR destinationip ILIKE '192.168.%' OR destinationip ILIKE '127.%')
AND "Process Name" NOT ILIKE ANY ('%firefox%','%chrome%','%msedge%','%brave%','%opera%','%iexplore%')
)
OR (LOGSOURCETYPEID(logsourceid) = 347 AND QIDNAME(qid) ILIKE '%RunInstances%')
)
ORDER BY devicetime DESC
LIMIT 1000 QRadar AQL detection for T1204.003 covering three branches: miner process execution by image name, command-line arguments referencing mining pool stratum protocols or pool addresses, and outbound connections to known mining pool ports from non-browser processes. Also captures AWS RunInstances events via CloudTrail log source type 347 for cloud image deployment detection.
Data Sources
Required Tables
False Positives & Tuning
- Authorized cryptocurrency mining operations where the organization has deployed mining software as part of a legitimate business activity
- AWS CI/CD pipelines that frequently launch EC2 instances from custom AMIs that may not match well-known publisher patterns, triggering RunInstances detections
- Penetration testing engagements where testers execute miner binaries as part of post-exploitation simulation to validate endpoint detection capabilities
Other platforms for T1204.003
Testing Methodology
Validate this detection against 5 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 1Docker Container Executing Cryptocurrency Miner Process Name
Expected signal: Linux syslog or auditd process creation event showing process name 'xmrig' spawned under dockerd/containerd parent process. If Sysmon for Linux is deployed, EventCode=1 with Image containing 'xmrig' and ParentImage containing 'containerd-shim' or 'runc'. Docker daemon logs show container start/stop events.
- Test 2Simulate Mining Pool Network Connection Attempt
Expected signal: If Sysmon for Linux is deployed: EventCode=3 network connection event with Image=curl, DestinationPort=3333, DestinationHostname=pool.minexmr.com. DNS query EventCode=22 for pool.minexmr.com. On Windows equivalent: 'Test-NetConnection -ComputerName pool.minexmr.com -Port 3333' generates Sysmon EventCode=3.
- Test 3Pull and Inspect Publicly Known Malicious-Style Docker Image Name
Expected signal: Docker daemon log entry for image pull. Process creation event for 'wget' process spawned from container runtime (dockerd/containerd parent). Network connection attempt to 127.0.0.1:3333 generating Sysmon EventCode=3 or auditd network event. 'docker history' output shows image layer commands.
- Test 4AWS EC2 Instance Launch from Public Community AMI
Expected signal: AWS CloudTrail RunInstances event with eventName=RunInstances, requestParameters.instancesSet.items[0].imageId containing the public AMI ID, userIdentity fields showing the executing principal, awsRegion=us-east-1. Followed by StopInstances event.
- Test 5Container Environment Variable Credential Exposure Simulation
Expected signal: Process creation event with container spawning wget/curl with credential parameters visible in command line. Network connection attempt to exfil endpoint. Container inspect shows AWS_* environment variables in container configuration. Linux syslog shows process execution under dockerd parent.
References (10)
- https://attack.mitre.org/techniques/T1204/003/
- https://summitroute.com/blog/2018/09/24/investigating_malicious_amis/
- https://info.aquasec.com/hubfs/Threat%20reports/AquaSecurity_Cloud_Native_Threat_Report_2021.pdf
- https://www.lacework.com/blog/teamtnt-the-first-crypto-mining-worm-to-steal-aws-credentials/
- https://unit42.paloaltonetworks.com/teamtnt-cryptojacking-watchdog-masquerade/
- https://docs.microsoft.com/en-us/azure/sentinel/data-connectors-reference
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1204.003/T1204.003.md
- https://sysdig.com/blog/teamtnt-docker-hub-cryptomining/
- https://www.trendmicro.com/vinfo/us/security/news/virtualization-and-cloud/coinminer-ddos-bot-attack-docker-daemon-ports
Unlock Pro Content
Get the full detection package for T1204.003 including response playbook, investigation guide, and atomic red team tests.