Bug 921331 - (CVE-2013-1855) CVE-2013-1855 rubygem-actionpack: css_sanitization: XSS vulnerability in sanitize_css
CVE-2013-1855 rubygem-actionpack: css_sanitization: XSS vulnerability in sani...
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
impact=moderate,public=20130318,repor...
: Security
Depends On: 921352 921355 921358 921361 924297 924298 995659 1030775 1165386 1165387
Blocks: 921344 921347 921348 925747 1000138 1028279
  Show dependency treegraph
 
Reported: 2013-03-13 22:53 EDT by Kurt Seifried
Modified: 2015-08-21 17:18 EDT (History)
22 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
A cross-site scripting (XSS) flaw was found in Action Pack. A remote attacker could use this flaw to conduct XSS attacks against users of an application using Action Pack.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-01-17 00:33:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
2-3-css_sanitize.patch (2.59 KB, patch)
2013-03-19 16:58 EDT, Kurt Seifried
no flags Details | Diff
3-0-css_sanitize.patch (2.41 KB, patch)
2013-03-19 16:59 EDT, Kurt Seifried
no flags Details | Diff
3-1-css_sanitize.patch (2.41 KB, patch)
2013-03-19 16:59 EDT, Kurt Seifried
no flags Details | Diff
3-2-css_sanitize.patch (2.41 KB, patch)
2013-03-19 16:59 EDT, Kurt Seifried
no flags Details | Diff

  None (edit)
Description Kurt Seifried 2013-03-13 22:53:52 EDT
XSS vulnerability in sanitize_css in Action Pack

There is an XSS vulnerability in the `sanitize_css` 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 `sanitize_css` method in Action Pack.  Impacted code will look like this:

    sanitize_css(some_user_input)

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 sanitize_css(style)
      # disallow urls
      style = style.to_s.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 allowed_css_properties.include?(prop.downcase)
          clean <<  prop + ': ' + val + ';'
        elsif shorthand_css_properties.include?(prop.split('-')[0].downcase)
          unless val.split().any? do |keyword|
            !allowed_css_keywords.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-css_sanitize.patch - Patch for 3.2 series 
* 3-1-css_sanitize.patch - Patch for 3.1 series 
* 3-0-css_sanitize.patch - Patch for 3.0 series 
* 2-3-css_sanitize.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!
Comment 8 Kurt Seifried 2013-03-16 01:27:22 EDT
Please note that upstream reports that the patches have an issue and will be reissued this weekend most likely so we might need to respin this fix.
Comment 9 Kurt Seifried 2013-03-18 23:23:03 EDT
I replaced the old (bad) patches with the new ones (same names).
Comment 15 Kurt Seifried 2013-03-19 16:58:35 EDT
Created attachment 712960 [details]
2-3-css_sanitize.patch
Comment 16 Kurt Seifried 2013-03-19 16:59:00 EDT
Created attachment 712961 [details]
3-0-css_sanitize.patch
Comment 17 Kurt Seifried 2013-03-19 16:59:24 EDT
Created attachment 712962 [details]
3-1-css_sanitize.patch
Comment 18 Kurt Seifried 2013-03-19 16:59:50 EDT
Created attachment 712963 [details]
3-2-css_sanitize.patch
Comment 20 Vít Ondruch 2013-03-21 09:58:38 EDT
Can I get tracking bug for F1{7,8}? Thank you.
Comment 21 Jan Lieskovsky 2013-03-21 10:13:34 EDT
Created rubygem-actionpack tracking bugs for this issue

Affects: epel-5 [bug 924297]
Affects: fedora-all [bug 924298]
Comment 22 Murray McAllister 2013-03-27 07:27:25 EDT
Acknowledgements:

Red Hat would like to thank Ruby on Rails upstream for reporting this issue. Upstream acknowledges Charlie Somerville as the original reporter.
Comment 23 errata-xmlrpc 2013-04-02 15:47:22 EDT
This issue has been addressed in following products:

  RHEL 6 Version of OpenShift Enterprise

Via RHSA-2013:0698 https://rhn.redhat.com/errata/RHSA-2013-0698.html
Comment 24 Kurt Seifried 2013-07-26 02:17:59 EDT
The Red Hat Security Response Team has rated this issue as having moderate security impact in CloudForms 1.1. This issue is not currently planned to be addressed in future updates.
Comment 28 Martin Prpic 2014-11-14 11:20:10 EST
IssueDescription:

A cross-site scripting (XSS) flaw was found in Action Pack. A remote attacker could use this flaw to conduct XSS attacks against users of an application using Action Pack.
Comment 29 errata-xmlrpc 2014-11-17 12:08:48 EST
This issue has been addressed in the following products:

  Red Hat Subscription Asset Manager 1.4

Via RHSA-2014:1863 https://rhn.redhat.com/errata/RHSA-2014-1863.html

Note You need to log in before you can comment on or make changes to this bug.