Fix CVE-2026-9358 (NVD) / SNYK-JS-POSTCSSSELECTORPARSER-16873882 - #316
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds AVA regression coverage to ensure deeply nested selectors no longer cause uncontrolled recursion/stack overflow (CVE-2026-9358 / SNYK-JS-POSTCSSSELECTORPARSER-16873882), and that failures surface as catchable errors.
Changes:
- Adds parse-time regression tests for deeply nested
:not(...)selectors exceeding the maximum depth. - Adds serialization (toString) regression test by building a deep AST that bypasses parsing guards.
- Adds tests for the
maxNestingDepthoption (tightening and loosening the limit).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #315
The fix basically prevent stack overflow on deeply nested selectors (CVE-2026-9358)
Deeply nested selectors (e.g.
:not(:not(:not(…)))) caused uncontrolled recursion in both parsing andtoString()serialization, overflowing the call stack with an uncatchable RangeError (CWE-674 / SNYK-JS-POSTCSSSELECTORPARSER-16873882).Add a nesting-depth limit (default 256, far beyond any real selector) that raises a clear, catchable Error instead of crashing:
maxNestingDepthparser option