CSP script-src 'none' does not block SVG accessKey
A page with a Content Security Policy that disables scripts (script-src 'none') still allows SVG accessKey events to fire. An attacker who can inject an SVG element could use these events to build a scriptless keylogger, capturing keystrokes despite the policy.
Originally disclosed on Mozilla
- Fixed in 15 days
- Paid in 39 days
- Disclosed after 15 days
Created attachment 8934262
exploit.html
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Steps to reproduce:
Load a page serving an SVG with an accessKey event (see attached SVG) and the CSP header script-src 'none'.
Actual results:
When the button is pressed, the accessKey event fires.
Expected results:
The accessKey event should not fire. SVG access key events are blocked by Firefox when javascript is turned off via `javascript.enabled` in about:config due to the possibility of using them as a scriptless keylogger. See https://bugzilla.mozilla.org/show_bug.cgi?id=704482 for the original bug report leading to this mitigation and a PoC keylogger.
As Firefox currently works, a developer could be serving a page with Javascript disabled via CSP as a security measure, and an attacker would be able to inject a scriptless keylogger into the page.
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 browser's CSP implementation does not apply the script-src 'none' restriction to SVG accessKey event handlers, even though similar restrictions exist when JavaScript is disabled globally.
Impact
An attacker who can inject an SVG into a page protected by script-src 'none' could potentially create a scriptless keylogger, capturing user keystrokes.
What the attacker needed
Victim uses Firefox; attacker can inject SVG into page; page has CSP script-src 'none'
The fix
The browser should block SVG accessKey events when script-src 'none' is set, consistent with the existing mitigation for disabled JavaScript.
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 (CSP) is a rule that tells the browser which scripts are allowed to run. Here, the rule says no scripts at all. But the browser still lets a special SVG feature (accessKey) trigger an event, which can be abused to record what keys a user presses without any script. This means the protection is incomplete.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.