XSS leads to Infrastructure Compromise
A stored XSS in the name field of an invoice feature was triggered when the invoice PDF was viewed, allowing an attacker to make requests to the AWS instance metadata service. This exposed temporary IAM credentials with overly broad permissions, enabling access to all S3 buckets, CloudWatch log groups, and DynamoDB tables in the account.
osintteam.blog
Published on osintteam.blog
Hi everyone, in this article I’ll be talking about an issue that one of my colleagues found during a web application pentest. When reading through the article, you’ll notice that the issue has been exploited multiple times but in this article, I’ll discuss why some can lead to infrastructure compromise which the rest…
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 invoice name field was not sanitised before being rendered in the PDF, and the EC2 instance used IMDSv1 with an IAM role that had overly permissive permissions (s3:*, logs:*, dynamodb:* on all resources).
Impact
The exposed IAM credentials had s3:*, logs:*, and dynamodb:* permissions on all resources, allowing access to all S3 buckets, CloudWatch log groups, and DynamoDB tables in the AWS account; the attack relied on IMDSv1 being enabled.
What the attacker needed
Ability to create or edit an invoice; victim views the generated PDF; EC2 instance uses IMDSv1; IAM role with overly permissive permissions
How it was found
- Enter an XSS payload in the invoice name field and save it.
- Export the invoice as a PDF and view it, triggering the XSS.
- Use the XSS to send a request to the AWS instance metadata endpoint to fetch IAM credentials.
- Use the obtained credentials to enumerate permissions.
- Access S3 buckets, CloudWatch log groups, and DynamoDB tables according to the permissions.
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.
The invoice name field did not safely handle user input, so when someone viewed the generated PDF, malicious code ran in their browser. That code could ask the cloud server for its secret access keys, which were then used to reach other cloud services. The keys had far more access than needed, letting the attacker read many storage buckets and logs.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.