Audio Worklet can execute dynamic code without `unsafe-eval` in CSP
Firefox did not enforce the Content Security Policy restriction on dynamic code evaluation inside Audio Worklet code, so eval() ran even though the policy omitted unsafe-eval. An attacker who could get script onto a page with such a policy could run dynamically generated code that the policy was meant to block.
- Fixed in 18 days
- Paid in 25 days
- Disclosed after 18 days
Created attachment 9545212 poc.tar
VULNERABILITY DETAILS
Content Security Policy (CSP) is not properly enforced for Audio Worklet. Specifically, Audio Worklet can execute dynamic code (via eval() and similar constructs) even when the unsafe-eval is absent from the CSP.
VERSION
Firefox Version: 147.0.3 stable
The vulnerability is also present in Firefox 149.0a1 nightly
REPRODUCTION CASE
- Host the provided code (
index.htmlandscript.jsinpoc.tar) on a local server by runningpython3 -m http.server -b 127.0.0.1 1337orphp -S 127.0.0.1:1337in the directory containing the files. - Navigate to
http://127.0.0.1:1337/#6*7in Firefox. - Although the CSP is set to
default-src 'none'; script-src 'self' 'unsafe-inline';, the Audio Worklet should successfully executeeval()and the page should display the result42ofeval("6*7"). This demonstrates that CSP is not properly enforced for Audio Worklet.
When visiting the same page in Chromium, an error message appears indicating that
eval()is blocked by CSP instead of showing42. I think it should be the expected behavior.
CREDIT INFORMATION
Reporter credit: lebr0nli of National Yang Ming Chiao Tung University, Dept. of CS, Security and Systems Lab.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Audio Worklet's script execution context was not wired into the CSP check that blocks eval and similar dynamic code evaluation.
Impact
A page relying on CSP to block dynamic code could still have such code executed through an Audio Worklet, weakening the defence that policy was meant to provide; the report shows this in Firefox only, and Chromium blocked it as expected.
What the attacker needed
Attacker-controlled script on a CSP-protected page; victim uses Firefox
How it was found
- Serve the proof-of-concept files from a local web server.
- Open the page in Firefox, which carries a CSP that forbids eval.
- Observe that the Audio Worklet still evaluates the expression and the page shows the result.
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 report has not been written yet. The Original tab links to the source.
A Content Security Policy is a set of rules a website sends to the browser to limit what scripts may do, for example banning eval(), which turns text into running code. Firefox applied these rules to normal page scripts but not to code running inside an Audio Worklet, a background audio-processing context. So a page that said 'no eval' could still run eval there, while Chromium blocked it.