XSS in the AWS Console
The AWS Console's Elastic Beanstalk Change History page inserted user-controlled values such as the user agent and environment name directly into the DOM without sanitisation, allowing HTML injection. Although a Content Security Policy initially blocked script execution, the page used AngularJS, and by injecting an AngularJS directive the attacker could bypass the CSP and achieve cross-site scripting.
Published on frichetten.com
As I had posted about on Twitter, I had recently started a side project to fuzz the AWS API. This was the logical next step to my previous work on the subject.
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
The page inserted user-controlled values (user agent and environment name) directly into the DOM without proper sanitisation, and the use of AngularJS allowed template/directive injection that bypassed the CSP.
Impact
An attacker with valid AWS credentials (even without Elastic Beanstalk or CloudTrail permissions) could inject HTML and, by leveraging AngularJS, execute arbitrary JavaScript in the AWS Console, potentially leading to phishing or other client-side attacks against console users.
What the attacker needed
Valid AWS credentials; victim views the Change History page
How it was found
- Send an API request to update an Elastic Beanstalk environment with a user agent containing an HTML payload.
- Wait for the CloudTrail event to appear in the Change History page.
- Refresh the AWS Console Change History page and observe the HTML injection.
- Create an Elastic Beanstalk application with a name containing an AngularJS template expression.
- Refresh the page and observe that the template expression is evaluated.
- Inject an AngularJS directive payload to execute JavaScript and bypass the CSP.
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 AWS Console is a web page used to manage cloud services. A part of it showed a list of changes, and some of the text in that list came from values the attacker could set, like the name of an environment or the browser's user agent string. Because the page put that text into the page without cleaning it first, an attacker could insert their own HTML and, eventually, JavaScript that runs in the browser of anyone who views the page.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.