Skip to content

Uncontrolled recursion in toString AST serialization — CVE-2026-9358 / SNYK-JS-POSTCSSSELECTORPARSER-16873882 #315

Description

@arflenar-sep

Snyk has published advisory SNYK-JS-POSTCSSSELECTORPARSER-16873882 (CVE-2026-9358, medium severity) describing an uncontrolled-recursion flaw in the toString function of the AST serializer. The advisory marks all versions as affected and notes there is no fixed version available.

This is impacting downstream consumers (e.g. eslint-plugin-vue users) who currently have no remediation path other than ignoring the finding in their security tooling. Is there a planned patch release that adds a recursion-depth limit or otherwise mitigates this in toString?

Activity

  1. badin017 commented on May 27, 2026

    @badin017

    Can we get some help on this , it is blocking for development work

  2. alexander-akait commented on May 27, 2026

    @alexander-akait
    Collaborator

    PR welcome to fix it

  3. MoOx commented on Jun 4, 2026

    @MoOx
    Collaborator

    I've put up a fix for this in #316. Happy to iterate on the approach if you'd like it shaped differently.

    Beyond the immediate patch, I wanted to raise the broader ownership question. This package sits deep in a lot of the postcss / CSS tooling ecosystem, so even moderate-severity issues like CVE-2026-9358 propagate widely the moment they hit advisory databases — and dormant repos with open CVEs are increasingly the soft targets of the current supply-chain attack wave (cf. postcss/postcss-url#185 recently).

    For context: I'm a longtime contributor in this space (created cssnext, and a lot of other postcss plugins back in time), and I'm currently in the process of claiming/reclaiming maintenance on several inactive postcss plugins I created or contributed to, with @ai's agreement.

    Given your other commitments across the JS tooling ecosystem, would you be open to me taking this package on as part of that effort? Either as an additional maintainer if you'd like to stay involved on direction, or taking it over entirely if you'd rather hand it off. Happy either way — and the patch above stands regardless of how that conversation lands.

    @ai — looping you in per our discussion about taking on inactive postcss plugins.

  4. ai commented on Jun 4, 2026

    @ai
    Member

    I support the @MoOx in taking maintaince if @alexander-akait need a help

  5. alexander-akait commented on Jun 4, 2026

    @alexander-akait
    Collaborator

    I am 👍 to adding @MoOx in maintainers (and give permissions to merge/release), I don't have time currently for this project , just ping me @ai if you agree with it too

  6. MoOx commented on Jun 4, 2026

    @MoOx
    Collaborator

    Thanks @alexander-akait !

    @arflenar-sep can you have a look to #316 ?

  7. MoOx commented on Jun 4, 2026

    @MoOx
    Collaborator

    Can someone add me on the package https://www.npmjs.com/package/postcss-selector-parser as well ? Thanks ! (~moox)

  8. ai commented on Jun 4, 2026

    @ai
    Member

    @alexander-akait I agree. I added him to GitHub access of this repo. But seems like you need to add him at npm.

  9. alexander-akait commented on Jun 4, 2026

    @alexander-akait
    Collaborator

    @MoOx Sent invite

  10. MoOx commented on Jun 8, 2026

    @MoOx
    Collaborator

    Thanks ! All good !

  11. anji-gt commented on Jun 9, 2026

    @anji-gt

    @MoOx Could you please expedite the release with the above fix?

  12. added a commit that references this issue on Jun 9, 2026
  13. MoOx commented on Jun 9, 2026

    @MoOx
    Collaborator

    @ai Could you give me more write access so I can rename default branch to main ? Thanks !

  14. ai commented on Jun 9, 2026

    @ai
    Member

    @MoOx done

  15. MoOx commented on Jun 9, 2026

    @MoOx
    Collaborator

    Thanks !

  16. adrianso commented on Jun 9, 2026

    @adrianso

    @MoOx Any chance this fix can be back-patched to 6.1.2?
    From the npm stats, 6.1.2 is still the most downloaded version of this library.
    And I am stuck with 6.1.2 because of I am on Tailwind 3.4.17.

  17. MoOx commented on Jun 10, 2026

    @MoOx
    Collaborator

    @adrianso Thanks for flagging the download numbers — that's useful context.

    Before deciding on a 6.x back-patch, it's worth checking whether you're actually exposed, because in a Tailwind setup you almost certainly aren't.

    What the vulnerability actually is: a denial-of-service. A pathologically deep selector (think thousands of nested :not(...)/:is(...)) makes the parser/serializer recurse deep enough to overflow the call stack. The only input that can trigger it is the selector string being parsed.

    Why a Tailwind user is almost certainly not at risk: Tailwind uses this library at build time, on your own, first-party CSS that you author. That input is trusted and never reaches those nesting depths. There's no untrusted, attacker-controlled selector reaching the parser, and a build step isn't a long-lived service a DoS would meaningfully harm. So in practice this is a non-issue for a standard Tailwind pipeline.

    To make sure I'm not missing your case, a couple of questions:

    • Are you ever feeding untrusted / user-supplied selector strings into postcss-selector-parser at runtime (e.g. a server that parses CSS coming from end users)? Or is it purely the Tailwind build step?
    • Is this flagged because of a real exposure, or is it a scanner / compliance finding (Snyk, Dependabot, audit) you need to clear?

    If you do have a genuine runtime exposure to untrusted selectors, tell me and I'll seriously consider a 6.x back-patch. I just don't want to maintain an extra release line unless someone actually needs it. Alternatively, you can check the PR fixing this and make a PR for a 6.x.x branch.

  18. adrianso commented on Jun 10, 2026

    @adrianso

    @MoOx It's flagged by the snyk scanner, in my case, I am required to comply to this as part of the PCI, which is an international standard that governs all websites credit cards.

    I understand not wanting to maintain an old branch, but would humbly ask you to re-consider because lots of other users of this library would be in the same boat, and the download numbers for the 6.x.x branch would certainly lend some weight to that.

  19. MoOx commented on Jun 11, 2026

    @MoOx
    Collaborator

    @adrianso Thanks for the context — PCI compliance is a fair and concrete reason, and you're right that the 6.x line carries most of the usage because Tailwind 3.4.x pins it. That's a strong enough case.

    I back-patched the fix to the 6.x line and just created a 6.1.3 patch release. It's a small, self-contained change (a nesting-depth guard), so this is a one-off patch rather than a branch I'll be actively maintaining.

    One important thing so this actually clears your scan: a published patch only makes Snyk/Dependabot go green if the advisory metadata is updated to mark the fixed version. So alongside the release I'll work on getting the GitHub/Snyk advisory updated to list the patched 6.x (and 7.x) versions — otherwise the scanner keeps flagging regardless of what you install.

  20. MoOx commented on Jun 11, 2026

    @MoOx
    Collaborator
  21. adrianso commented on Jun 11, 2026

    @adrianso

    @MoOx Oh my god! You are amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions