Detect Cloud Instance Metadata API in IBM QRadar
Adversaries may attempt to access the Cloud Instance Metadata API to collect credentials and other sensitive data. Most cloud providers host a metadata API at http://169.254.169.254 (AWS, Azure, GCP, DigitalOcean) or http://fd00:ec2::254 (AWS IPv6). This internal endpoint provides running instances with credentials including temporary IAM role credentials (AWS), managed identity tokens (Azure), and service account tokens (GCP). Adversaries with code execution on a VM can query this endpoint directly, or exploit Server-Side Request Forgery (SSRF) vulnerabilities in public-facing applications to retrieve cloud credentials from external networks. TeamTNT, Peirates, and Hildegard have all exploited this API. The Capital One breach involved SSRF to the metadata API.
MITRE ATT&CK
- Tactic
- Credential Access
- Technique
- T1552 Unsecured Credentials
- Sub-technique
- T1552.005 Cloud Instance Metadata API
- Canonical reference
- https://attack.mitre.org/techniques/T1552/005/
QRadar Detection Query
SELECT
DATEFORMAT(starttime, 'yyyy-MM-dd HH:mm:ss') AS EventTime,
sourceip,
destinationip,
username,
QIDNAME(qid) AS EventName,
CATEGORYNAME(category) AS Category,
"processname",
"CommandLine",
LOGSOURCENAME(logsourceid) AS LogSource,
magnitude
FROM events
WHERE
starttime > NOW() - 86400000
AND
(
-- Pattern 1: Network connections to metadata IP
(
destinationip = '169.254.169.254'
AND "processname" NOT ILIKE '%AzureGuestAgent%'
AND "processname" NOT ILIKE '%amazon-ssm-agent%'
AND "processname" NOT ILIKE '%google_guest_agent%'
AND "processname" NOT ILIKE '%cloud-init%'
AND "processname" NOT ILIKE '%waagent%'
)
OR
-- Pattern 2: Process command lines with metadata API patterns
(
(
"CommandLine" ILIKE '%169.254.169.254%'
OR "CommandLine" ILIKE '%metadata/instance%'
OR "CommandLine" ILIKE '%iam/security-credentials%'
OR "CommandLine" ILIKE '%latest/meta-data%'
OR "CommandLine" ILIKE '%latest/dynamic%'
OR "CommandLine" ILIKE '%instance-identity%'
OR "CommandLine" ILIKE '%computeMetadata%'
OR "CommandLine" ILIKE '%metadata.google.internal%'
OR "CommandLine" ILIKE '%imds.azure.com%'
)
AND "CommandLine" NOT ILIKE '%aws-cfn-bootstrap%'
AND "CommandLine" NOT ILIKE '%cloud-init%'
AND "CommandLine" NOT ILIKE '%amazon-ssm%'
AND "CommandLine" NOT ILIKE '%google_guest_agent%'
AND "CommandLine" NOT ILIKE '%waagent%'
)
)
ORDER BY starttime DESC
LIMIT 500 QRadar AQL query detecting Cloud Instance Metadata API access via suspicious network connections to 169.254.169.254 or process command lines containing IMDS paths for AWS, Azure, and GCP. Filters known legitimate cloud management agent activity.
Data Sources
Required Tables
False Positives & Tuning
- Cloud-native services and deployment agents (SSM Agent, Azure Guest Agent, Google Guest Agent) that regularly poll the metadata service for configuration updates and credential rotation
- Infrastructure-as-code tools (Terraform, AWS CDK, Pulumi) executing plans on cloud instances that query metadata to resolve provider credentials or region configuration
- Container orchestration agents (kubelet, ECS agent, containerd-shim) on cloud VMs that access IMDS to retrieve node identity or cluster join tokens during provisioning
Other platforms for T1552.005
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 1Query AWS Instance Metadata for IAM Credentials
Expected signal: Linux auditd EXECVE records for curl with 169.254.169.254 metadata URLs. CONNECT syscall to 169.254.169.254:80. Network connection visible in /proc/net/tcp. AWS access logs would capture this if instance metadata logging is enabled.
- Test 2Query Azure IMDS for Managed Identity Token
Expected signal: Linux auditd EXECVE for curl with 169.254.169.254 and metadata/identity in args. HTTP connection to 169.254.169.254. Response contains access_token, token_type, expires_in fields.
- Test 3Query GCP Instance Metadata for Service Account Token
Expected signal: Linux auditd EXECVE for curl with metadata.google.internal URL. DNS resolution for metadata.google.internal (resolves to 169.254.169.254). Network connection to 169.254.169.254:80.
- Test 4Steal Cloud Credentials via Python SSRF Simulation
Expected signal: Linux auditd EXECVE for python3 with 169.254.169.254 URL in command. CONNECT syscall from python3 to 169.254.169.254. Unexpected process (python3) accessing metadata API.
References (8)
- https://attack.mitre.org/techniques/T1552/005/
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
- https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service
- https://cloud.google.com/compute/docs/metadata/overview
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1552.005/T1552.005.md
- https://krebsonsecurity.com/2019/08/what-we-can-learn-from-the-capital-one-hack/
- https://blog.trendmicro.com/trendlabs-security-intelligence/teamtnt-now-deploying-ddos-capable-irc-bot-tntbotinger/
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html
Unlock Pro Content
Get the full detection package for T1552.005 including response playbook, investigation guide, and atomic red team tests.