Bug Bounty Stories #1: Tale of CSP bypass in an electron app!
The Electron app had a content injection issue and a weak CSP nonce that used the current epoch time plus only 6 random bytes. An attacker could predict the nonce and bypass CSP to execute scripts, though the text does not show a full exploit chain.
Published on web.archive.org
I have been working on developing an APIs, and was weeks into it. As a pentester and security researcher, I feel more joyful when I am in action mode.
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
Impact
An attacker could bypass CSP to execute scripts, but the text does not specify what actions were possible beyond the bypass.
What the attacker needed
Content injection vulnerability; CSP with nonce
The fix
The nonce should be generated with high entropy (e.g., a UUID) and user input should be encoded when reflected.
How it was found
- Observe that the app is vulnerable to content injection.
- Try XSS but find it blocked by CSP.
- Notice the CSP allows scripts with a nonce.
- Modify the payload and see the nonce change, revealing the epoch prefix.
- Develop a proof of concept that predicts the nonce and bypasses 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.
Content Security Policy (CSP) is a browser rule that blocks unauthorised scripts. A nonce is a random value that allows specific scripts. Here the nonce was predictable because part of it was the current time, so an attacker could guess it and run their own script.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.