Inappropriate implementation in CSS (CVE-2026-13837)
Blink's CSSOM serialization for counter values fails to escape custom identifiers, returning raw unescaped strings. If a web application reads and re-injects this serialized CSS, an attacker can smuggle structural characters to inject arbitrary CSS rules, potentially leading to mutation XSS.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 44 days
Flapjack, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: Blink's CSSOM serialization for counter values fails to escape custom identifiers, returning raw, unescaped strings. If a web application reads and dynamically re-injects this serialized CSS, an attacker can smuggle structural characters to inject arbitrary CSS rules. This breaks the CSSOM round-trip invariant, creating a potential mutation XSS (mXSS) vulnerability.
Affected files:
third_party/blink/renderer/core/css/css_counter_value.ccthird_party/blink/renderer/core/css/css_counter_content_value.cc
Estimated timestamp from git blame: Unknown (Google3 checkout)
Overview
The CSSOM serialization logic for CSSCounterValue and CSSCounterContentValue in Blink's CSS engine contains a potential vulnerability that can lead to CSS injection, often referred to as mutation XSS (mXSS).
Specifically, the CustomCSSText() methods in these classes append the raw, decoded identifier string to the serialization buffer instead of its properly escaped CSS representation. This allows structural CSS characters (like ;, {, and }) that were originally safely escaped in the input to be serialized as literal characters, breaking the CSSOM round-trip invariant.
Technical Details
In third_party/blink/renderer/core/css/css_counter_value.cc:
String CSSCounterValue::CustomCSSText() const {
StringBuilder result;
// ...
result.Append(identifier_->Value()); // Vulnerability: appends raw, unescaped string
// ...
}
A parallel issue exists in third_party/blink/renderer/core/css/css_counter_content_value.cc:
String CSSCounterContentValue::CustomCSSText() const {
// ...
result.Append(Identifier()); // Identifier() returns identifier_->Value()
// ...
}
The identifier_ member is a CSSCustomIdentValue. During parsing, any CSS escape sequences (e.g., \3b for ;) are decoded, and the literal string is stored. When CSSCustomIdentValue::CustomCSSText() is called, it correctly uses SerializeIdentifier to re-escape these characters. However, the counter value classes bypass this and call Value(), directly embedding the unescaped string into the output.
Potential Attack Scenario
(Note: These are potential steps to trigger the issue, as our tooling agent does not run active code execution to provide a working PoC.)
- Injection: An attacker provides a payload where a safe CSS property value contains escaped structural characters. For example:
counter-reset: \3b \7d * \7b color: red; \7d 1;(Decodes to:; } * { color: red; } 1;) - Parsing: The browser parses this safely. The tokenizer decodes the escapes into a single identifier token, isolating the attacker's payload as a valid counter name.
- Serialization: A benign script reads the CSS text via the CSSOM (e.g.,
element.style.cssTextorelement.style.counterReset). Due to the bug, the browser serializes this as:counter-reset: ; } * { color: red; } 1; - Re-parsing / Execution: The application dynamically injects this serialized string back into the DOM (a common pattern in CSS-in-JS libraries, SSR rehydration, or HTML sanitizers). Because the output is no longer escaped, the literal
;prematurely terminates thecounter-resetdeclaration, the}closes the current rule block, and* { color: red; }is evaluated as a completely new, attacker-controlled CSS rule.
This grants the attacker the ability to inject arbitrary CSS, which can be leveraged for UI spoofing or data exfiltration via CSS-based side channels.
Suggested Fix
Update the CustomCSSText() implementations in both affected classes to rely on the underlying identifier's safe serialization method rather than extracting the raw value.
For CSSCounterValue:
Change result.Append(identifier_->Value()); to result.Append(identifier_->CustomCSSText());
For CSSCounterContentValue:
Change result.Append(Identifier()); to result.Append(identifier_->CustomCSSText());
Evaluated with Chrome root at commit: b7d0c4d810da1b31400f198c70d9720fc8f0e5a0
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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
The CustomCSSText() methods in CSSCounterValue and CSSCounterContentValue append the raw, decoded identifier string instead of using the safe serialization method that escapes structural characters.
Impact
This grants the attacker the ability to inject arbitrary CSS, which can be leveraged for UI spoofing or data exfiltration via CSS-based side channels.
What the attacker needed
Web app reads and re-injects serialized CSS; attacker can supply CSS input
The fix
Update the CustomCSSText() implementations in both affected classes to rely on the underlying identifier's safe serialization method rather than extracting the raw value.
How it was found
- An attacker provides a payload where a safe CSS property value contains escaped structural characters.
- The browser parses this safely, decoding the escapes into a single identifier token.
- A benign script reads the CSS text via the CSSOM, and due to the bug, the browser serializes it with unescaped structural characters.
- The application dynamically injects this serialized string back into the DOM, causing the literal characters to terminate the declaration and inject a new CSS rule.
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.
When a browser reads CSS code and then writes it back out, it should produce the same safe text. Here, for a specific CSS feature (counter values), the browser writes back dangerous characters like semicolons and braces without escaping them. If a website takes that text and puts it back into the page, an attacker could sneak in extra CSS rules, which might be used to trick users or steal data.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.