Skip to content

Fix: Nested rule parser#1

Draft
frondeus wants to merge 1 commit into
frondeus/fix-trimming-declarationsfrom
frondeus/fix-nested-rule-parser
Draft

Fix: Nested rule parser#1
frondeus wants to merge 1 commit into
frondeus/fix-trimming-declarationsfrom
frondeus/fix-nested-rule-parser

Conversation

@frondeus

@frondeus frondeus commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Nested at-rules and style rules are parsed by recursive descent with no depth bound, so untrusted input with deep nesting overflows the thread stack and aborts the process. Enforce MAX_NESTING_DEPTH (32) in NestedRuleParser::parse_nested, returning ParserError::MaximumNestingDepth once exceeded (or skipping the rule under error recovery). The limit fits within a 512 KiB stack in release builds; real CSS never nests this deep.

This is not a real problem for parcel bundler but may be for using lightningcss in other applications like email processing

Nested at-rules and style rules are parsed by recursive descent with no
depth bound, so untrusted input with deep nesting overflows the thread
stack and aborts the process. Enforce MAX_NESTING_DEPTH (32) in
NestedRuleParser::parse_nested, returning ParserError::MaximumNestingDepth
once exceeded (or skipping the rule under error recovery). The limit fits
within a 512 KiB stack in release builds; real CSS never nests this deep.

This is not a real problem for parcel bundler but may be for using
`lightningcss` in other applications like email processing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant