RubySec

Providing security resources for the Ruby community

GHSA-pq4g-8rxf-4g29 (crass): Incorrect tokenization of bad URLs enables CSS sanitizer bypass

Incorrect tokenization of bad URLs enables CSS sanitizer bypass

Published: October 21, 2026

SECURITY IDENTIFIERS

GEM

crass

PATCHED VERSIONS

>= 1.0.8

DESCRIPTION

Summary

Crass's tokenizer didn't terminate a bad URL token at a ) that followed an escaped backslash (\). As a result, Crass consumed more input as part of the bad URL than a spec-compliant browser does. CSS sanitizers that parse untrusted CSS with Crass and re-emit it could be tricked into passing through declarations, style rules, or at-rules (including @import) that the sanitizer would otherwise have removed, but that a browser would then parse and apply.

Impact

Crass by itself only mis-tokenizes input. The security impact is on CSS sanitizers that use Crass to make allow/deny decisions and then re-serialize the CSS. Exploitation requires a sanitizer that doesn't reject bad URL tokens wherever they occur. Confirmed examples:

  • Sanitize (all versions through 7.0.0): Sanitize::CSS.properties, style attributes, Sanitize::CSS.stylesheet, and <style> elements.
  • Loofah (Loofah::HTML5::Scrub.scrub_css, used for style attributes), and therefore rails-html-sanitizer (sanitize_css, and sanitize when style is a permitted attribute).

RELATED