Skip to content
SSRF Write-up Intermediate

Cybr Academy: Exploiting Lambda SSRF to Access S3 Buckets — wal

The Lambda function's /product-image endpoint accepted a user-supplied URL and used it without validation, allowing an attacker to read local files such as /proc/self/environ. This exposed temporary AWS credentials, which the attacker used to list and download objects from an S3 bucket.

marianita_cloud Follow

Published on medium.com

This lab simulates an attack path where an attacker can access an object in an S3 bucket by taking advantage of an e-commerce web application and its serverless API via an SSRF vulnerability hosted on AWS Lambda with public URL.

marianita_cloud, on medium.com

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 application passed user-controlled input directly to a file-fetching function without validating or restricting the URL scheme or destination.

Impact

An attacker could read the Lambda function's environment variables, obtain temporary AWS credentials, and use them to access S3 buckets, potentially exposing sensitive data.

What the attacker needed

Access to the Lambda function URL; knowledge of the /product-image endpoint

The fix

The application should validate and restrict user-supplied URLs, avoid using file:// for fetching, store secrets in a dedicated service like Secrets Manager, and use IAM roles instead of hardcoded credentials.

How it was found

  1. Access the Lambda function URL to view the e-commerce application.
  2. Discover the /doc endpoint via directory brute-force, which reveals the /product-image?url= endpoint.
  3. Test the url parameter with http://localhost to confirm SSRF.
  4. Fetch file:///proc/self/environ through the url parameter to obtain AWS credentials.
  5. Configure AWS CLI with the obtained credentials and session token.
  6. List S3 buckets and download the flag file using the credentials.

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.

A web server can be tricked into fetching a URL that the attacker chooses. Here, the server fetched a local file instead of an image, and that file contained cloud login keys. With those keys, the attacker could read files stored in the cloud.

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.