XSS Vulnerability in the select helper

958 views
Skip to first unread message

Aaron Patterson

unread,
Mar 1, 2012, 1:04:38 PM3/1/12
to rubyonrail...@googlegroups.com
There is a vulnerability for users that generate their own options tags for use with the select helper in Ruby On Rails.

Versions Affected: All.
Fixed Versions: 3.2.2, 3.1.4, 3.0.12

Impact
------
When developers generate html options tags manually, user input concatenated with manually built tags may not be escaped and an attacker can inject arbitrary HTML in to the document.

Only manually generated select tag options are impacted, but all users running an affected release should either upgrade or use one of the work arounds immediately.

Releases
--------
The 3.2.2, 3.1.4, and 3.0.12 releases are available at the normal locations.

Workarounds
-----------
To work around this issue, escape manually built option tags passed to the select helper. For example:

BEFORE (vulnerable):

<%= select('post', 'author_id', "<option value='#{user.id}'>#{user.name}</option>") %>

AFTER (values are escaped):

<%= select('post', 'author_id', content_tag(:option, user.name, :value => user.id) %>

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-select_options.patch - Patch for 3.2 series
* 3-1-select_options.patch - Patch for 3.1 series
* 3-0-select_options.patch - Patch for 3.0 series

Please note that only the 3.2.x, 3.1.x, and 3.0.x series are supported at present. Users of earlier unsupported releases are advised to upgrade as soon as possible.

Credits
-------

Credit for these patches goes to Sergey Nartimov! Thank you!

--
Aaron Patterson
http://tenderlovemaking.com/

3-0-select_options.patch
3-1-select_options.patch
3-2-select_options.patch
Reply all
Reply to author
Forward
0 new messages