Inappropriate implementation in CSS (CVE-2026-13836)
The CSSOM serialisation of @position-try rule names in Blink did not re-escape CSS escape sequences, so a rule name containing encoded angle brackets and slashes was returned raw by cssText(). If a script read that value and injected it back into a style element, the unescaped closing style tag could break out and allow script execution.
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: The CSSOM serialization logic for @position-try rules in Blink fails to escape the rule name, outputting it raw. If an attacker uses CSS escapes to embed HTML tags (like </style>) into the rule name, the serialized cssText can trigger a mutation XSS (mXSS) when injected back into the DOM.
Affected files:
third_party/blink/renderer/core/css/css_position_try_rule.cc
Estimated timestamp from git blame: Unknown (Google3 checkout)
The implementation of CSSPositionTryRule::cssText() in third_party/blink/renderer/core/css/css_position_try_rule.cc incorrectly appends the rule's name directly to the output StringBuilder without proper CSS escaping.
During CSS parsing, escape sequences within identifiers (such as \3c for < or \2f for /) are decoded and stored internally as literal characters. To prevent these characters from breaking out of their CSS context when serialized back to text, the CSSOM specification requires them to be safely re-escaped. While other rules (such as @keyframes in CSSKeyframesRule::cssText()) correctly invoke SerializeIdentifier() to escape special characters, @position-try rules append the raw, unescaped string directly:
// third_party/blink/renderer/core/css/css_position_try_rule.cc
String CSSPositionTryRule::cssText() const {
StringBuilder result;
result.Append("@position-try ");
result.Append(name()); // <--- Vulnerability: Raw string appended without SerializeIdentifier()
result.Append(" { ");
...
Potential Attack Steps
(Note: These are suggested steps based on static analysis; our tooling agent does not currently have the ability to run code to verify a working proof-of-concept.)
- Inject Malicious CSS: An attacker provides malicious CSS to a vulnerable web application, utilizing CSS escapes within a
@position-tryrule name:@position-try --foo\3c \2fstyle\3e \3c script\3e alert(1)\3c \2fscript\3e { margin: 10px; } - Browser Parsing: The browser's CSS parser unescapes the rule name and stores it internally as the literal string
--foo</style><script>alert(1)</script>. - CSSOM Read: A script running on the page, such as a DOM sanitizer (e.g., DOMPurify) or an application dynamically copying styles, reads the rule's
.cssTextproperty. - Vulnerable Serialization: Because
SerializeIdentifier()is missing, the browser returns the raw, unescaped string:@position-try --foo</style><script>alert(1)</script> { margin: 10px; } - mXSS Trigger: The script trusts this output (as it originated from the browser's CSSOM) and injects it back into the DOM inside a
<style>block (e.g.,styleElement.innerHTML = text;). - Code Execution: The HTML parser encounters the unescaped
</style>sequence, prematurely terminating the style block, and executes the subsequent<script>tag, resulting in a Cross-Site Scripting (XSS) vulnerability.
Suggested Fix
Update CSSPositionTryRule::cssText() in third_party/blink/renderer/core/css/css_position_try_rule.cc to safely serialize the identifier:
#include "third_party/blink/renderer/core/css/css_markup.h"
// ...
String CSSPositionTryRule::cssText() const {
StringBuilder result;
result.Append("@position-try ");
SerializeIdentifier(name(), result); // <--- FIX
result.Append(" { ");
// ...
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
Likely the serialiser for @position-try rules appended the decoded rule name directly instead of passing it through the identifier escaping helper used by other rules.
Impact
Could lead to cross-site scripting, but only where a page script reads the serialised rule and re-injects it into the DOM; the report is based on static analysis and no working proof of concept was run.
What the attacker needed
Attacker-controlled CSS reaches the page; page script reads cssText and re-injects it; victim uses a vulnerable Chromium build
The fix
The serialiser should be changed to escape the rule name with the identifier serialisation helper, as the report suggests.
How it was found
- Supply CSS containing a @position-try rule whose name uses CSS escapes for angle brackets and slashes.
- The browser parses the rule and stores the name as literal characters.
- A page script reads the rule's cssText property.
- The browser returns the name unescaped in the serialised text.
- The script injects that text into a style element, and the HTML parser ends the style block early and runs the following script.
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.
Browsers store CSS in an internal form and can print it back out as text. When printing, special characters must be re-encoded so they cannot be mistaken for HTML. Here the browser forgot to re-encode the name of one kind of CSS rule, so text that looked like an HTML tag could slip through and run as code if a page copied it back into the page.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.