GHSA-rj75-hqrm-r3gf: Medium severity npm/postcss-selector-parser vulnerability

Published Oct 5, 2026
·
Updated

Impact

. and # are not word delimiters in the tokenizer, so a flat selector such as .a.a.a... reaches splitWord() as a single word token carrying n class or id indexes. Three passes scanned those index arrays linearly for every index, making the parse O(n^2) in the number of indexes rather than in input length: uniqs(), the indices.forEach loop, and the Sass-interpolation filter. Parsing a 400 KB flat selector took ~34 s on a modern laptop, fully occupying a single thread. A benign selector of identical byte size parses in tens of milliseconds, so the cost is driven by the index count, not the input size. The nesting depth of such a selector is 0, so the maxNestingDepth guard added in 7.1.3 offers no protection.

Reachability is deployment dependent. Only consumers that parse untrusted, attacker-supplied selectors synchronously in a request path are exposed, for example CSS sanitizers, CSS-in-JS services and online playgrounds. Ordinary build-time use on trusted sources is not affected.

Patches

Fixed in 7.1.6. The three passes now use Set membership tests, making parsing linear in the number of indexes. There is no behaviour change: parsing is byte-identical on a differential corpus of 8413 selectors.

Workarounds

Cap the size of selectors accepted from untrusted sources before parsing.

Affected Software

1 affected componentFixes available
npm/postcss-selector-parser<7.1.6
7.1.6

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/postcss-selector-parser to a version that resolves this vulnerability.

    Fixed in 7.1.6
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 7.1.6
  3. Compensating control

    Cap the size of selectors accepted from untrusted sources before parsing.

Event History

Oct 5, 2026
Advisory Published
via GitHub·10:53 PM
Data Sourced
via GitHub·10:53 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are realistically exposed to this denial-of-service issue?

Deployments are exposed only when they synchronously parse untrusted, attacker-supplied selectors in a request path, such as CSS sanitizers, CSS-in-JS services, or online playgrounds. Ordinary build-time parsing of trusted sources is not affected.

2

What input would an attacker need to supply?

An attacker would need to provide a flat selector with many repeated class or ID indexes, such as a long sequence using . or # delimiters. This causes quadratic parsing work while keeping nesting depth at zero.

3

Does the maxNestingDepth protection mitigate this issue?

No. The problematic selector has nesting depth 0, so the maxNestingDepth guard added in 7.1.3 does not protect against it.

4

What version fixes the issue?

The issue is fixed in version 7.1.6. The fix replaces the affected linear scans with Set membership tests, making parsing linear in the number of indexes without changing parsing behavior.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203