SSRF in Document-Preview Service Leaked EC2 IAM Role Credentials
A red‑team discovered that the service fetching arbitrary URLs allowed SSRF to the instance metadata endpoint, exposing IAM role credentials and enabling privilege escalation.
The document‑preview microservice runs on an EC2 instance and renders thumbnails for any user‑supplied URL. Because it makes outbound HTTP requests without validation, an attacker can direct it to the metadata service (169.254.169.254) and retrieve temporary IAM credentials.
- The service performs a raw
GETto the supplied URL; no allowlist or DNS rebinding protection is applied. - EC2 metadata is reachable via link‑local address
169.254.169.254; egress allowlists that filter domains do not block this traffic. - The retrieved credentials are returned in the HTTP response body, leaking
AccessKeyId,SecretAccessKey, andToken. - Mitigation steps: enforce IMDSv2 (
curl -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" http://169.254.169.254/latest/api/token), add network‑level egress rules to block 169.254.0.0/16, and implement URL sanitisation or a proxy that validates destinations.
Engineering Takeaway: Harden any user‑driven fetcher by blocking metadata endpoints, requiring IMDSv2, and validating outbound URLs before request execution.





