Heap buffer overflow in CSS (CVE-2026-4442)
The CSS resolver in Chromium reads the first argument of env() as an identifier but only checks the token type in debug builds, so a non-string token such as a number reaches a string accessor. Through CSS Typed OM an attacker could inject an invalid env() argument and cause an out-of-bounds memory read, crashing the browser.
- Fix shipped in 31 days
Summary
StyleCascade resolves env()/attr() substitutions by reading the function’s first argument as an ident via ConsumeVariableName, but it only DCHECKs the token type and then calls CSSParserToken::Value(). In release builds, CSS Typed OM can inject syntactically-invalid env(0) into an unparsed declaration (via attributeStyleMap.set()), so the resolver ends up calling Value() on a non-string-backed token (e.g. kNumberToken), producing a StringView with uninitialized pointer/length and cause OOB in ToAtomicString().
Details
During variable/substitution resolution, StyleCascade::ResolveTokensInto detects env() and calls StyleCascade::ResolveEnvInto, which consumes the environment variable name using ConsumeVariableName.
The key issue is that ConsumeVariableName relies on a debug-only type assertion before calling Value():
AtomicString ConsumeVariableName(CSSParserTokenStream& stream) {
stream.ConsumeWhitespace();
CSSParserToken ident_token = stream.ConsumeIncludingWhitespaceRaw();
DCHECK_EQ(ident_token.GetType(), kIdentToken);
return ident_token.Value().ToAtomicString();
}
In a normal stylesheet parse pipeline, invalid env() syntax is expected to be rejected before this point. However, CSS Typed OM can store CSSUnparsedValue content as a CSSUnparsedDeclarationValue without enforcing env()’s argument grammar, so a value like env(0) can reach the substitution resolver.
For env(0), the token after the ( is a kNumberToken, which is not string-backed. CSSParserToken::Value() does not check GetType()/HasStringBacking(); it constructs a StringView from the token’s internal value_* fields:
StringView Value() const {
return value_is_8bit_ ? StringView(Span8()) : StringView(Span16());
}
For non-string-backed tokens (such as kNumberToken), the value_length_ / value_data_char_raw_ fields are not initialized as a meaningful string payload. Calling Value() on such a token therefore yields a StringView with a garbage pointer/length. The subsequent ToAtomicString() tries to hash/copy from that span, leading to an out-of-bounds memory access.
Bisection
This issue was introduced in commit 27932c039882c41ae25df71df3078a5bbfb38795 ("StyleCascade, Phase 1") by Anders Hartvoll Ruud on 2019-07-23 (CL 1605418).
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
This would trigger ASAN crash shown in asan.txt
Suggested Fix
Treat non-ident first arguments in ConsumeVariableName as untrusted.
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 a debug-only type assertion in ConsumeVariableName, combined with CSS Typed OM allowing unvalidated env() arguments to reach the resolver, lets a non-string-backed token be read as a string.
Impact
A page could trigger an out-of-bounds memory access in the renderer, causing a crash; the text does not claim code execution.
What the attacker needed
Victim loads a malicious page; browser built without debug checks
The fix
The fix should treat non-identifier first arguments in ConsumeVariableName as untrusted and reject them.
How it was found
- Load the provided ASAN build of Chrome.
- Open the proof-of-concept HTML page that sets an unparsed declaration with an invalid env() argument through CSS Typed OM.
- Observe the ASAN crash report.
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 parse CSS and sometimes substitute values like env() into styles. A check that the argument is a name was only active in debug builds, so in normal builds a number could slip through and be treated as text, making the browser read memory it should not. The result is a crash, and possibly worse, when a page supplies the bad value.
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.