Skip to content
XSS Advisory Advanced CVE-2026-87550

Improper encoding or escaping of output in CSS (CVE-2026-87550)

The CSS Typed OM serialisation of custom-property variable names in Chromium fails to escape HTML metacharacters, so a variable name containing a closing style tag and a script tag survives into the serialised output. If an application re-injects that serialised string into a style block, the HTML parser can break out and execute the script, leading to mutation XSS.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 3 months

Project Fortify, 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: A potential Mutation XSS (mXSS) vulnerability exists in the CSS Typed OM serialization of custom-property variable names. When CSSUnparsedValue.toString() serializes a CSSVariableReferenceValue segment, it emits the decoded identifier name verbatim without performing proper escaping (such as the CSSOM 'serialize an identifier' algorithm). This allows unescaped HTML metacharacters to survive in the serialized output, potentially leading to script execution if re-injected into style blocks.

Affected files:

  • third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc
  • third_party/blink/renderer/core/css/cssom/css_style_variable_reference_value.cc

Estimated timestamp from git blame: 2017-12-06

Root Cause

In third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc, the AppendUnparsedString method serializes CSSVariableReferenceValue segments by appending the custom-property variable name raw to the string builder:

C++
case V8CSSUnparsedSegment::ContentType::kCSSVariableReferenceValue: {
  const auto* reference_value =
      segments_[i]->GetAsCSSVariableReferenceValue();
  builder.Append("var(");
  builder.Append(reference_value->variable()); // Missing SerializeIdentifier()
  ...

During parsing of CSS, any CSS escapes inside custom-property identifiers (e.g., \3c for <) are decoded into their literal representation. Thus, the variable name stored in CSSStyleVariableReferenceValue::variable_ can contain literal HTML metacharacters such as < or >. Additionally, the JS constructor for CSSVariableReferenceValue only performs a basic starts_with("--") check on the variable name, allowing developers/attackers to directly supply names with arbitrary characters.

When CSSUnparsedValue.toString() is called, it serializes this raw variable name without utilizing the standard CSSOM SerializeIdentifier algorithm, allowing these metacharacters to be output in raw form.

Potential Trigger Path

Note: These are suggested/potential steps; our tooling agent does not yet have the ability to dynamically run or execute code.

  1. An attacker is able to inject a CSS style containing escaped sequences inside a custom property name, or construct a CSSVariableReferenceValue directly via the JavaScript API: new CSSVariableReferenceValue("--a,</style><script>alert(1)</script>")
  2. A web application or sanitizer reads the custom property using CSS Typed OM: const val = element.attributeStyleMap.get('--x');
  3. The application serializes the value back to a string: const serialized = val.toString(); This outputs: "var(--a,</style><script>alert/**/(1)</script>)"
  4. If the application or sanitizer injects this serialized string back into a <style> block in the DOM, the HTML parser parses </style>, transitions out of the RAWTEXT style state, parses the <script> element, and executes the payload, leading to potential Mutation XSS (mXSS).

Suggested Fix

  1. In third_party/blink/renderer/core/css/cssom/css_unparsed_value.cc, replace: builder.Append(reference_value->variable()); with: SerializeIdentifier(reference_value->variable(), builder);
  2. In third_party/blink/renderer/core/css/cssom/css_style_variable_reference_value.cc, tighten the validation in CSSStyleVariableReferenceValue::Create and setVariable to verify that the variable name conforms to a valid <dashed-ident> token.

Evaluated with Chrome root at commit: fb72408a8493c46bc75fae1c70d03daec96b3040


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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 appends the decoded custom-property variable name directly to the output instead of using the standard CSS identifier serialisation routine, and the JavaScript constructor only checks that the name starts with two dashes.

Impact

If an application re-injects the serialised value into a style block, an attacker could achieve script execution through mutation XSS; the report notes the trigger path is suggested and has not been dynamically executed.

What the attacker needed

Application re-injects serialised CSS into a style block; attacker can supply a crafted variable name

The fix

The serialiser should use the standard CSS identifier serialisation routine and the constructor should validate that the variable name is a valid dashed identifier.

How it was found

  1. Create a CSS variable reference whose name contains HTML metacharacters, either through an escaped CSS custom property or directly via the JavaScript constructor.
  2. Read the custom property back using the CSS Typed OM attribute style map.
  3. Call toString() on the value, which returns a string containing the unescaped metacharacters.
  4. Inject that serialised string back into a style block in the DOM, causing the HTML parser to leave the style context and execute the embedded 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.

When a browser turns a CSS value back into text, it is supposed to escape special characters so the text cannot be mistaken for HTML. Here, a variable name inside a CSS value is copied out without that escaping, so characters like a closing style tag can slip through. If a website takes that text and puts it back into the page as HTML, the browser may treat part of it as a script and run it.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.