Ssrf Steals ec2 Tokens
A download endpoint accepted a user-supplied URL and fetched it server-side without restricting the scheme or destination, so the author could read local files and reach the AWS instance metadata service. That allowed reading the EC2 instance credentials and, per the author, taking over cloud resources.
Published on infosecwriteups.com
What is SSRF (Server-Side Request Forgery)? Server-Side Request Forgery (SSRF) is a critical vulnerability that allows an attacker to manipulate a server into making unintended requests.
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 download script passed the user-controlled pdf_path value straight to a fetch function without validating the scheme or restricting destinations to an allowlist.
Impact
An attacker could read local files including database credentials and retrieve the EC2 instance's IAM credentials, which the author says could allow taking over S3 buckets and other cloud resources.
What the attacker needed
Reachable download endpoint; no authentication mentioned; server runs on AWS EC2
The fix
The endpoint should be fixed by validating the supplied URL, allowing only expected schemes and hosts, and blocking access to link-local and internal addresses.
How it was found
- Open the download endpoint with a normal external PDF URL in the pdf_path parameter and confirm it fetches remote content.
- Replace the value with a local file URL to read files on the server.
- Use the process working-directory symlink to read index.php and find the database config path.
- Read the database config file to obtain MySQL credentials.
- Point pdf_path at the AWS instance metadata address to list directories.
- Request the EC2 identity credentials path to retrieve the instance 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 server-side request forgery (SSRF) bug is when a website takes a link from you and fetches it from its own servers. If the site does not check where that link points, you can make its server read files on its own disk or talk to cloud services that only the server can reach. Here the download page fetched any link given to it, including local files and the cloud provider's internal address that hands out temporary passwords.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.