Detection of Unauthorized Cloud Instance Metadata Service Access
Attackers exploit cloud instance metadata service (IMDS) endpoints by using command-line tools to exfiltrate temporary security credentials and sensitive configuration data, facilitating unauthorized access to cloud resources.
What's new
- 1. OS windows; OS linux; OS macos Sep 19, 13:10 via elastic
This threat involves the exploitation of the cloud Instance Metadata Service (IMDS) by adversaries to perform credential theft and environment discovery. By gaining command execution on a cloud-resident virtual machine, attackers use common utilities such as curl, wget, or native shell commands to query the IMDS endpoint. This technique allows attackers to retrieve highly sensitive information, including instance identity, public IP addresses, and, most critically, temporary IAM role credentials or managed identity tokens. Once acquired, these credentials are used to authenticate to cloud APIs - such as storage buckets, secrets managers, or subscription management services - without the need for long-term passwords. This activity is often a precursor to broader lateral movement and privilege escalation within a cloud environment. Monitoring for command-line access to these specific metadata URIs is essential for detecting post-exploitation discovery and exfiltration phases.
Attack Chain
- Attacker gains initial access to a cloud-based virtual machine via web application exploitation or remote command execution.
- Attacker performs internal reconnaissance to identify the environment as a cloud instance and locates the IMDS address (e.g., 169.254.169.254).
- Attacker identifies the appropriate API path for credential or token retrieval, such as
/latest/meta-data/iam/security-credentials/or equivalent cloud-specific token endpoints. - Attacker invokes common system utilities or interpreters like
curl,wget,powershell.exe, orpythonto query the identified metadata path. - The metadata service returns the temporary security credentials or OAuth access tokens to the attacker-controlled process.
- Attacker exfiltrates these credentials from the local host to an external command-and-control server or uses them immediately to access cloud services.
- Attacker utilizes the stolen credentials to interact with cloud management APIs, storage, or secrets providers to achieve their final objective (exfiltration, sabotage, or persistence).
Impact
Successful exploitation leads to the loss of workload identity, allowing attackers to impersonate the instance's service role. This can result in unauthorized access to sensitive cloud data, modification of infrastructure configurations, and persistent access to the cloud environment, potentially impacting large-scale deployments across sectors utilizing cloud infrastructure.
Recommendation
- Deploy the Sigma rules provided in this brief to detect suspicious command-line execution targeting IMDS endpoints.
- Require IMDSv2 or similar protections that mandate session-oriented authentication to mitigate unauthorized metadata access.
- Review IAM roles and managed identities attached to virtual machines to ensure the principle of least privilege is applied, limiting the impact if credentials are stolen.
- Block outbound connections from production workloads to the IMDS endpoint for any process that does not have a documented, legitimate business requirement.
- Configure alerting for the use of cloud CLI tools or SDKs using credentials retrieved from the metadata service in unexpected geographic locations.
Immediate actions
Deploy detection rule to identify command-line access to IMDS endpoints
Threat Hunt
Search for command lines containing 169.254.169.254 or cloud-specific metadata paths
Mitigations
Require IMDSv2 and restrict metadata access to authorized service accounts
T1552.005
Detection coverage 1
Detect Suspicious Instance Metadata Service (IMDS) Access
mediumDetects command-line execution attempting to access IMDS API endpoints for credential or token retrieval
Detection queries are available on the platform. Get full rules →
Indicators of compromise
1
domain
1
ip
| Type | Value |
|---|---|
| ip | 169.254.169.254 |
| domain | metadata.google.internal |