Skip to content
SSRF Write-up Beginner

Unintended Path to Exam Domination - AWS EC2 Meta-Data

The AWS EC2 instance metadata service (IMDS) and user-data were accessible from within exam lab environments, allowing attackers to retrieve sensitive information such as temporary AWS credentials and startup scripts containing admin passwords. This could let them bypass the intended exam path or break out of the lab environment.

Dr. Michael Gschwender Follow

Published on rootcat.de

This is directed to everyone using aws EC2 for CTF’s, labs or offensive security exams.

Dr. Michael Gschwender (@rootcathacking), on rootcat.de

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the EC2 instance metadata service (IMDS) was left enabled and accessible from within the lab, and user-data scripts containing sensitive information were stored in readable log files on the instances.

Impact

An attacker with access to the lab environment could obtain AWS credentials and sensitive information from user-data, potentially allowing them to bypass the exam or escalate privileges within the AWS account.

What the attacker needed

Access to the EC2 instance; IMDS enabled (default)

The fix

The metadata service should be disabled or restricted (e.g., using IMDSv2) and user-data should not contain sensitive information or be stored in readable logs.

How it was found

  1. Access the EC2 instance (e.g., via RDP to a Windows VM).
  2. Query the metadata service endpoint to retrieve instance information.
  3. Retrieve temporary AWS credentials from the metadata service.
  4. Access user-data logs (e.g., C:\ProgramData\Amazon\EC2Launch\log\agent.log) to obtain credentials from startup scripts.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

In cloud environments like AWS, each virtual machine has a special internal web address that only the machine itself can reach. This address provides information about the machine, including temporary passwords (credentials) that let it use other AWS services. If an attacker can access this address from inside the machine, they can steal those credentials and use them to do things they shouldn't, like reading exam answers or taking over the whole cloud account.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.