Inappropriate implementation in CSS (CVE-2026-3541)
A CSS parsing function in Chromium reads a variable name from a token without checking that the token actually holds string data, so a malformed var() expression makes it copy from an uninitialised pointer and length. An attacker could trigger an out-of-bounds read and crash the browser, and the report suggests the copied size and pointer are attacker-influenced.
- Fix shipped in 16 days
Summary
CSSUnparsedValue’s var()/env() tokenization path assumes the first argument is always string-backed, and calls FindVariableName() as stream.Consume().Value().ToString() without validating the token type. When the first token inside var(...) is a comma (e.g. var(,)), the consumed token is kCommaToken (not string-backed), so CSSParserToken::Value() constructs a StringView from uninitialized value_length_/value_data_char_raw_.Therefore, OOB happens when we convert that StringView to a String copies an attacker-influenced size from an invalid pointer.
Details
When converting a serialized custom property back into Typed OM segments, ParserTokenStreamToTokens() treats any var()/env() function token as a variable-reference and immediately parses a “variable name” token.
In css_unparsed_value.cc, the variable-name extraction does not check token type or whether the token is string-backed:
String FindVariableName(CSSParserTokenStream& stream) {
stream.ConsumeWhitespace();
return stream.Consume().Value().ToString();
}
For malformed input like var(,), after consuming whitespace the next token is a comma (kCommaToken). Comma tokens are not string-backed (see CSSParserToken::HasStringBacking()), but FindVariableName() still calls Value().
In css_parser_token.h, CSSParserToken::Value() returns a StringView built from value_length_ and value_data_char_raw_:
StringView Value() const {
return value_is_8bit_ ? StringView(Span8()) : StringView(Span16());
}
In css_parser_token.h, non-string-backed tokens constructed via CSSParserToken(CSSParserTokenType, BlockType) do not initialize the “value” fields, so value_length_ and value_data_char_raw_ contain indeterminate data:
explicit CSSParserToken(CSSParserTokenType type,
BlockType block_type = kNotBlock)
: type_(type),
block_type_(block_type),
numeric_value_type_(0),
numeric_sign_(0),
unit_(0),
value_is_inline_(false),
value_is_8bit_(false),
padding_(0) {}
As a result, Value().ToString() can attempt to copy an attacker-controlled large length from an attacker-controlled pointer, leading to the OOB during the copy inside StringView::ToString().
Bisection
This issue was introduced in commit fb6b1c467f2705a7d8c607d512cacefd17f1488d ("Convert CSSUnparsedValue parsing to the streaming parser") by Steinar H. Gunderson on 2024-08-27 (CL 5803173).
Reproduction
Using https://storage.googleapis.com/chromium-browser-asan/linux-release/asan-linux-release-1585188.zip
Run:
./chrome --no-sandbox --user-data-dir=/tmp/xx poc.html
You should ASAN crash which shown in the asan.txt
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 variable-name extraction calls Value() on a token without checking that the token is string-backed, so uninitialised length and pointer fields are used to build a StringView.
Impact
An attacker could cause an out-of-bounds read during string conversion, leading to a browser crash; the report does not demonstrate code execution.
What the attacker needed
Victim loads a crafted HTML page; Chromium browser
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 turn CSS text into internal objects, and some of those objects store text in a buffer with a length. Here the code assumed a certain piece of CSS always contained text, but a malformed value made it read a length and pointer that were never set. That can make the browser read memory it should not, which at minimum crashes the tab.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.