CVE-2026-61847: Crass: A large number of adjacent CSS comments can trigger a SystemStackError
By default, the Ruby CSS parser Crass discards comments by recursively consuming the next token. A stylesheet with a very large number of adjacent comments triggers `SystemStackError`. Crass before 1.0.7 is affected. Upgrade to 1.0.7, or set `:preserve_comments` to true.
Published Oct 29, 2026 · Analysis Oct 31, 2026
What an attacker can do
With the :preserve_comments option off, which is the default, each comment is dropped and the parser then calls itself to read the following token. A stylesheet made of tens of thousands of back-to-back comments therefore builds a call stack as deep as the comment count, and Ruby raises SystemStackError. The recursion is uncontrolled (CWE-674).
The attacker needs to get a stylesheet in front of a Crass call: an upload, a user-supplied style field or any pipeline that runs Crass on third-party CSS. No account is needed if the input is public. The outcome is an exception that can fail the request or kill a worker, which is a denial of service on that process. It does not give code execution or data access. The CVSS 4.0 vector rates only low availability impact, with a precondition on the target setup.
The payload is trivially small and needs no CSS knowledge: repeated /**/.
Who is affected
The crass gem below 1.0.7 is affected when :preserve_comments is not enabled, which is the default. Find the installed version, including as a transitive dependency:
bundle list | grep crassAn app that already passes preserve_comments: true is not affected by this one, because recursion does not occur when comments are preserved.
crass
- Ecosystem
- RubyGems
- Affected
- < 1.0.7
- Fixed in
- 1.0.7
- Check
bundle info crass
How to fix it
Upgrade to Crass 1.0.7, which no longer recurses when discarding comments.
bundle update crassThe advisory's workaround is to set the :preserve_comments option to true if keeping comments in the parse output is acceptable for your use case.
How to tell if you were hit
Look in logs and error trackers for SystemStackError: stack level too deep with a Crass tokenizer or parser frame at the top of the backtrace. Check the matching requests for stylesheet bodies made of very long runs of comments. Repeated worker crashes right after CSS input are a hint.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Impact
When the :preserve_comments option is not enabled (which is the default behavior), Crass discards CSS comments by recursively consuming the next token. An attacker who provides a stylesheet containing a very large number of adjacent comments can cause excessive recursion and trigger a SystemStackError.
Patches
This is fixed in Crass 1.0.7, which no longer recurses when discarding comments.
Workarounds
Set the :preserve_comments option to true if this is acceptable to your use case (recursion doesn't occur when comments are preserved).
Credited to hourianto, rgrove.
Questions
- Does setting preserve_comments avoid the problem?
Yes, per the advisory. Recursion does not occur when comments are preserved, so
:preserve_comments => trueis a workaround.- Is this the same bug as CVE-2026-61846?
No. That advisory is about deeply nested blocks and functions. This one is about many adjacent comments in default mode. Both are fixed in 1.0.7.
- Is CVE-2026-61847 exploited in the wild?
No source reports exploitation, and it is not in CISA's KEV catalog.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More RubyGems vulnerabilities
All RubyGems entriesCVE-2026-61846
Crass: Deeply nested CSS blocks and functions can trigger a SystemStackError or excessive memory usage
medium6.3Oct 29, 2026CVE-2026-61848
Crass: Non-ASCII characters cause superlinear CPU consumption
medium6.3Oct 29, 2026CVE-2026-116695
Crass: Incorrect tokenization of bad URLs enables CSS sanitizer bypass
medium5.3Oct 28, 2026CVE-2026-61845
Crass : Large numeric exponents cause CPU and memory denial of service
high8.9Oct 20, 2026
