CVE-2013-1855: XSS
The sanitizecss method in lib/actioncontroller/vendor/html-scanner/html/sanitizer.rb in the Action Pack component in Ruby on Rails before 2.3.18, 3.0.x and 3.1.x before 3.1.12, and 3.2.x before 3.2.13 does not properly handle \n (newline) characters, which makes it easier for remote attackers to conduct cross-site scripting (XSS) attacks via crafted Cascading Style Sheets (CSS) token sequences.
Other sources
The sanitizecss method in lib/actioncontroller/vendor/html-scanner/html/sanitizer.rb in the Action Pack component in Ruby on Rails before 2.3.18, 3.0.x and 3.1.x before 3.1.12, and 3.2.x before 3.2.13 does not properly handle \n (newline) characters, which makes it easier for remote attackers to conduct cross-site scripting (XSS) attacks via crafted Cascading Style Sheets (CSS) token sequences.
— MITRE
XSS vulnerability in sanitizecss in Action Pack
There is an XSS vulnerability in the sanitizecss method in Action Pack. This vulnerability has been assigned the CVE identifier CVE-2013-1855.
Versions Affected: All. Not affected: None. Fixed Versions: 3.2.13, 3.1.12
Impact ------ Carefully crafted text can bypass the sanitization provided in the sanitizecss method in Action Pack. Impacted code will look like this:
sanitizecss(someuserinput)
All users running an affected release should either upgrade or use one of the work arounds immediately.
Releases -------- The 3.2.13 and 3.1.12 releases are available at the normal locations.
Workarounds ----------- To work around this issue, you can apply the following monkey patch:
module HTML class WhiteListSanitizer # Sanitizes a block of css code. Used by #sanitize when it comes across a style attribute def sanitizecss(style) # disallow urls style = style.tos.gsub(/url\s\(\s[^\s)]+?\s\)\s/, ' ')
# gauntlet if style !~ /\A([:,;#%.\sa-zA-Z0-9!]|\w-\w|\'[\s\w]+\'|\"[\s\w]+\"|\([\d,\s]+\))\z/ || style !~ /\A(\s[-\w]+\s:\s[^:;](;|$)\s)\z/ return '' end
clean = [] style.scan(/([-\w]+)\s:\s([^:;])/) do |prop,val| if allowedcssproperties.include?(prop.downcase) clean << prop + ': ' + val + ';' elsif shorthandcssproperties.include?(prop.split('-')[0].downcase) unless val.split().any? do |keyword| !allowedcsskeywords.include?(keyword) && keyword !~ /\A(#[0-9a-f]+|rgb\(\d+%?,\d%?,?\d%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)\z/ end clean << prop + ': ' + val + ';' end end end clean.join(' ') end end end
Patches ------- To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset.
3-2-csssanitize.patch - Patch for 3.2 series 3-1-csssanitize.patch - Patch for 3.1 series 3-0-csssanitize.patch - Patch for 3.0 series 2-3-csssanitize.patch - Patch for 2.3 series
Please note that only the 3.1.x and 3.2.x series are supported at present. Users of earlier unsupported releases are advised to upgrade as soon as possible as we cannot guarantee the continued availability of security fixes for unsupported releases.
Credits -------
Thanks to Charlie Somerville for reporting this!
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2013-1855?
CVE-2013-1855 has a medium severity rating, allowing potential remote code execution due to improper handling of newline characters in sanitized CSS.
How do I fix CVE-2013-1855?
To fix CVE-2013-1855, update the Action Pack component to versions 2.3.18, 3.1.12, or 3.2.13 or later.
What versions are affected by CVE-2013-1855?
CVE-2013-1855 affects Ruby on Rails versions before 2.3.18, 3.0.x, and 3.1.x before 3.1.12, and 3.2.x before 3.2.13.
Can CVE-2013-1855 be exploited remotely?
Yes, CVE-2013-1855 can be exploited remotely by attackers to potentially execute arbitrary code.
Is there a patch for CVE-2013-1855?
Yes, patches are available in the fixed versions of Action Pack, specifically 2.3.18, 3.1.12, and 3.2.13.