Suspicious Instance Metadata Service API Requests
Attackers with initial code execution on cloud-hosted virtual machines query the Instance Metadata Service (IMDS) at 169.254.169.254 to harvest sensitive instance details and temporary security credentials for unauthorized cloud control-plane access.
What's new
- 1. OS linux; OS macos; OS windows Sep 19, 13:10 via elastic
Attackers frequently leverage access to cloud-hosted virtual machines to target the Instance Metadata Service (IMDS). By querying the well-known, non-routable IP address 169.254.169.254, adversaries can retrieve instance-specific metadata, such as public IP addresses, instance IDs, and - most critically - temporary IAM role credentials or managed identity tokens. This technique is often used as a post-exploitation step to escalate privileges into the cloud control plane. Defenders should monitor for unexpected network traffic directed at this endpoint from shell interpreters, scripting engines, or binaries executing from user-writable and temporary directories. The activity is distinct from legitimate bootstrap or configuration scripts, which typically execute from authorized system paths at startup.
Attack Chain
- Attacker gains initial code execution on a cloud virtual machine via exploit or compromised credentials.
- Attacker performs local reconnaissance to locate configuration files or shell history (Discovery).
- Attacker uses a common tool (e.g., curl, PowerShell) or a custom script to query the IMDS endpoint at 169.254.169.254 (Discovery/Credential Access).
- IMDS returns sensitive metadata and temporary security credentials to the attacker process.
- Attacker captures the returned token or credential material from the process output.
- Attacker utilizes the harvested cloud credentials to interact with cloud APIs (e.g., S3, Secrets Manager, IAM) to exfiltrate data or persist in the cloud environment (Impact).
Impact
Successful exploitation allows attackers to bypass host-level security boundaries and move laterally into the cloud control plane. By assuming the identity of the compromised instance's service role, attackers can gain unauthorized access to sensitive cloud storage, managed secrets, IAM policies, and other subscription resources, potentially leading to widespread data exposure or further infrastructure takeover.
Recommendation
- Deploy the provided Sigma rule to identify unauthorized network connections to the IMDS endpoint.
- Baseline your environment to distinguish between legitimate bootstrap/agent activity and malicious IMDS queries originating from interactive shells or temporary directories.
- Enforce IMDSv2 (or equivalent provider-specific hardening) to require session tokens and disable metadata access for non-essential processes.
- Regularly rotate instance profile and managed identity credentials if suspicious IMDS query activity is detected.
Immediate actions
Deploy IMDS network detection rule
Threat Hunt
Search for processes (curl, wget, python) communicating with 169.254.169.254 outside of authorized boot windows
Data: Network connection logs
Detection coverage 1
Detect Suspicious IMDS API Requests
mediumDetects suspicious processes or scripts querying the cloud Instance Metadata Service (IMDS) at 169.254.169.254
Detection queries are available on the platform. Get full rules →
Indicators of compromise
1
ip
| Type | Value |
|---|---|
| ip | 169.254.169.254 |