Stealing Salesforce OAuth Tokens using the WAF
An XSS vulnerability in a Salesforce Commerce Cloud component allowed injection of an event handler via a JSON parameter. The attacker escalated it to steal OAuth authorization codes by using a Cloudflare WAF block to interrupt the redirect, enabling account takeover.
castilho.sh
Published on castilho.sh
Recently, while running a pentest on a Salesforce instance, I found an XSS vulnerability. This post breaks down the bug and how I escalated it to steal OAuth tokens by leveraging the Cloudflare WAF as a gadget.
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 application failed to sanitise the 'components' parameter before rendering it into HTML attributes, allowing attribute injection and execution of JavaScript.
Impact
An attacker could steal OAuth tokens and achieve account takeover, but the exploit required the victim to visit a malicious page and the WAF to block the redirect.
What the attacker needed
Victim visits malicious page; WAF blocks redirect; OAuth flow with IdP
How it was found
- Force logout the victim and retrieve the IdP Google login URL from the /account/login page.
- Set a malicious cookie to trigger a WAF block when the request returns to the origin.
- Initiate the OAuth flow by inserting an iframe pointing to the IdP login URL.
- Wait for the iframe to load the redirect back to the origin.
- Steal the unused code and state parameters from the iframe URL.
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 report describes a cross-site scripting (XSS) bug where user input is placed into a web page without proper cleaning, letting an attacker run their own JavaScript. The attacker then abused a web application firewall (WAF) to block a login redirect, which let them capture a one-time code used to log in as the victim.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.