SSRF to Cloud Metadata: The Attack Chain That Turns a Web Bug Into a Breach | Lorikeet Security Skip to main content
Back to Blog

SSRF to Cloud Metadata: The Attack Chain That Turns a Web Bug Into a Breach

Lorikeet Security Team March 21, 2026 10 min read

Server-Side Request Forgery (SSRF) is one of the most misunderstood vulnerabilities in web application security. In a traditional on-premises deployment, SSRF is dangerous: it can be used to scan internal networks, access internal services, and bypass network controls. But in cloud environments, SSRF takes on an entirely different risk profile. A basic SSRF vulnerability in a cloud-hosted application can provide direct access to IAM credentials, enabling an attacker to pivot from a web-layer finding to full cloud account compromise. The 2019 Capital One breach demonstrated this attack chain at scale — over 100 million customer records exfiltrated through SSRF targeting the AWS instance metadata service.

TL;DR: SSRF vulnerabilities in cloud-hosted applications can reach the instance metadata service at 169.254.169.254, which returns IAM credentials without requiring authentication. Those credentials can be used to access S3, Secrets Manager, and other AWS services. IMDSv2 raises the bar but does not fully prevent exploitation. Enforce IMDSv2, apply least-privilege IAM roles, and test every URL-fetching feature in your application.


The SSRF-to-Metadata Attack Chain

The attack proceeds through a predictable sequence that Lorikeet Security's pentesters encounter regularly in cloud-hosted web application assessments:

Step 1: Identify the SSRF vulnerability

SSRF occurs when a web application fetches a URL on behalf of the user without adequately validating the destination. Common locations include: webhook configuration endpoints (the application fetches the webhook URL to verify it), URL preview or screenshot features, document or image import from URL, PDF generation from HTML (headless browsers may follow redirects), and server-side proxies. Any feature where the server makes an outbound HTTP request based on user input is a potential SSRF vector.

Step 2: Reach the metadata endpoint

Once SSRF is confirmed — typically by making the server fetch an external URL you control — the next step is redirecting the request to http://169.254.169.254/. This is the link-local address reserved for cloud instance metadata services. It is reachable by any process running on the instance, including your web application. The address is the same across AWS EC2, GCP Compute Engine, and Azure VMs (though the API structure differs).

Step 3: Extract IAM credentials

On AWS, the path http://169.254.169.254/latest/meta-data/iam/security-credentials/ returns the name of the IAM role attached to the instance. A second request to http://169.254.169.254/latest/meta-data/iam/security-credentials/{role-name} returns the temporary Access Key ID, Secret Access Key, and Session Token for that role — refreshed automatically every few hours. These are fully functional AWS API credentials. An attacker who extracts them can use the AWS CLI or SDKs from any machine.

Step 4: Use credentials to escalate or exfiltrate

The impact of the extracted credentials depends entirely on what permissions the EC2 instance role has. In the Capital One case, the role had broad S3 access — enough to list and download data from over 700 buckets. In other cases, pentesters have found roles with Secrets Manager access (extracting database credentials and API keys), IAM permissions (enabling privilege escalation to more powerful roles), or RDS access.


Real-World Impact: The Capital One Breach

The Capital One breach is the canonical example of SSRF-to-metadata exploitation at enterprise scale. In 2019, a former AWS employee exploited an SSRF vulnerability in a misconfigured WAF running on an EC2 instance in Capital One's AWS environment. The WAF was configured to proxy requests, and an SSRF vulnerability allowed the attacker to craft requests that caused the WAF to fetch the IMDS endpoint and return the attached IAM role's temporary credentials.

Those credentials had access to over 700 S3 buckets containing Capital One customer data. The attacker exfiltrated data on approximately 106 million credit card applicants before the intrusion was detected — not by Capital One's security team, but by a tip received after the attacker posted about it in a public forum. The total cost of the breach exceeded $270 million in settlements, regulatory fines, and remediation costs.

The Capital One breach key takeaway: The SSRF vulnerability was the entry point, but the IAM role attached to the EC2 instance had far more S3 access than the application needed. Both layers failed: the web vulnerability (SSRF) and the cloud permission model (over-privileged IAM role). Fixing either one would have prevented the breach.


IMDSv2: The Mitigation and Its Limits

AWS released IMDSv2 (Instance Metadata Service version 2) specifically to address the SSRF-to-credentials attack chain. IMDSv2 introduces a session-oriented protocol that requires a two-step process to retrieve credentials:

  1. Send a PUT request to http://169.254.169.254/latest/api/token with the header X-aws-ec2-metadata-token-ttl-seconds: 21600 to obtain a session token
  2. Use the returned token in subsequent GET requests via the header X-aws-ec2-metadata-token: {token}

Simple SSRF that can only make GET requests cannot complete step 1 and therefore cannot retrieve credentials from an IMDSv2-only instance. However, IMDSv2 is not a complete solution:


SSRF Severity by Environment

Environment SSRF Severity Primary Risk Key Mitigation
On-premises (no cloud) Medium-High Internal network scanning, internal service access Network egress filtering, allowlist outbound destinations
AWS EC2 (IMDSv1) Critical IAM credential theft → full cloud account pivot Enforce IMDSv2, least-privilege IAM roles
AWS EC2 (IMDSv2 enforced) High Internal AWS service access, advanced SSRF still reaches IMDS IMDSv2 + egress filtering + minimal IAM permissions
AWS Lambda / ECS Critical Environment variable credential theft, execution role abuse Minimal execution role, egress control, secrets via Secrets Manager not env vars
GCP Compute Engine High Service account token theft via metadata service Metadata-Flavor header enforcement, minimal service account scope

What Pentesters Test for SSRF in Cloud Environments

In a cloud-hosted web application penetration test, SSRF testing is a structured activity that covers more than the obvious URL input fields:

Is your cloud-hosted application vulnerable to SSRF?

Lorikeet Security's cloud security assessments test SSRF vectors, IAM configuration, and the complete SSRF-to-compromise chain in AWS, GCP, and Azure environments.

-- views
Link copied!
Lorikeet Security

Lorikeet Security Team

Penetration Testing & Cybersecurity Consulting

We've completed 170+ security engagements across web apps, APIs, cloud infrastructure, and AI-generated codebases. Everything we publish here comes from patterns we see in real client work.

Lory waving

Hi, I'm Lory! Need help finding the right service? Click to chat!