T1552.005: Cloud Instance Metadata API

Adversaries may attempt to access the Cloud Instance Metadata API to collect credentials and other sensitive data.

Most cloud service providers support a Cloud Instance Metadata API which is a service provided to running virtual instances that allows applications to access information about the running virtual instance. Available information generally includes name, security group, and additional metadata including sensitive data such as credentials and UserData scripts that may contain additional secrets. The Instance Metadata API is provided as a convenience to assist in managing applications and is accessible by anyone who can access the instance. A cloud metadata API has been used in at least one high profile compromise.

If adversaries have a presence on the running virtual instance, they may query the Instance Metadata API directly to identify credentials that grant access to additional resources. Additionally, adversaries may exploit a Server-Side Request Forgery (SSRF) vulnerability in a public facing web proxy that allows them to gain access to the sensitive information via a request to the Instance Metadata API.

The de facto standard across cloud service providers is to host the Instance Metadata API at http[:]//169.254.169.254.

Positive Technologies products that cover the technique

MaxPatrol SIEM knowledge base

— Monitoring of events related to execution of the Get-MsolUser cmdlet of the MSOnline module (for Azure). For example: Get-MsolUser -All; foreach($user in $users){$props = @();$user | Get-Member | foreach-object{$props+=$_.Name}; foreach($prop in $props){if($user.$prop -like "password"){Write-Output ("[*]" + $user.UserPrincipalName + "[" + $prop + "]" + " : " + $user.$prop)}}}. — Monitoring of process-start events where command line input contains a request to the instance metadata API by default at 169.254.169.254 (or 169.254.170.2) in order to export available data to a file. The request URL may contain the following: 'metadata', 'meta-data' 'cedentials'. For example: Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri "http://169.254.169.254/metadata/instance?api-version=2021-02-01 " | ConvertTo-Json -Depth 64 > #{output_file}.

Expert Required. The technique is detected only with the combination of «PT Product + Expert»

Detection

IDDS0002Data source and componentUser Account: User Account AuthenticationDescription

It may be possible to detect adversary use of credentials they have obtained such as in Valid Accounts.

Mitigation

IDM1035NameLimit Access to Resource Over NetworkDescription

Limit access to the Instance Metadata API using a host-based firewall such as iptables.

IDM1042NameDisable or Remove Feature or ProgramDescription

Disable unnecessary metadata services and restrict or disable insecure versions of metadata services that are in use to prevent adversary access.

IDM1037NameFilter Network TrafficDescription

Limit access to the Instance Metadata API. A properly configured Web Application Firewall (WAF) may help prevent external adversaries from exploiting Server-side Request Forgery (SSRF) attacks that allow access to the Cloud Instance Metadata API.