Exploiting CORS misconfigurations for Bitcoins and bounties
Several websites, including bitcoin exchanges, misconfigured CORS by reflecting arbitrary Origin headers or using flawed whitelists, allowing an attacker to make a victim's browser send authenticated requests and read sensitive data such as API keys and wallet backups.
Published on portswigger.net
In this post, I'll show how to identify and exploit misconfigured CORS. This is a greatly condensed version of my AppSec USA talk.
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 server dynamically generates the Access-Control-Allow-Origin header based on the user-supplied Origin value without proper validation, or uses flawed whitelisting logic.
Impact
An attacker could steal private API keys, disable notifications, enable 2FA to lock out the user, transfer bitcoins, and steal encrypted wallet backups enabling offline brute-force attacks.
What the attacker needed
Victim visits attacker's page; victim logged into target site; target reflects Origin header
The fix
Servers should validate the Origin header against a strict whitelist and include the Vary: Origin header when dynamically generating CORS headers.
How it was found
- Identify a target that sends CORS headers and reflects the Origin header.
- Craft a malicious page that makes a cross-origin request with credentials to the target.
- Host the page and trick a victim into visiting it.
- The victim's browser sends the request with their cookies, and the response is read by the attacker's script.
- Exfiltrate sensitive data from the response to the attacker's server.
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.
CORS is a browser feature that lets a website ask another site for data. If a site trusts any website, an attacker can trick your browser into fetching your private data from that site and sending it to the attacker. This article shows several real examples where that happened.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.