Potential XSS Problem with mail_to :encode => :javascript

426 views
Skip to first unread message

Michael Koziarski

unread,
Feb 8, 2011, 3:53:48 PM2/8/11
to rubyonrail...@googlegroups.com
There is a vulnerability in mail_to helper in Ruby on Rails when used
with the :encode => :javascript option. This vulnerability has been
assigned the CVE identifier CVE-2011-0446.

Versions Affected: All.
Not affected: Applications which don't use :encode => :javascript
Fixed Versions: 3.0.4, 2.3.11

Impact
------
An attacker could specify a malicious name or email value which could
enable an XSS attack. All users running an affected release should
either upgrade or use one of the work arounds immediately.

Releases
--------
The 3.0.4 and 2.3.11 releases are available at the normal locations.

Workarounds
-----------
The simplest work around is to specify :encode => :hex instead, for
example:

Before:
<%= mail_to user.email, user.name, :encode => :javascript %>

After:
<%= mail_to user.email, user.name, :encode => :hex %>

Those requiring the javascript encoding should escape the javascript
passed to both values.

Before:
<%= mail_to user.email, user.name, :encode => :javascript %>

After:
<%= mail_to escape_javascript(user.email),
escape_javascript(user.name), :encode => :javascript %>


Patches
-------
To aid users who aren't able to upgrade immediately we have provided a
patch for the supported release series. It is in git-am format and
consists of a single changeset.

* 3-0-mailto.patch - Patch for 3.0 series
* 2-3-mailto.patch - Patch for 2.3 series

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

Credits
-------
Thanks to Brendan Coles of IT Security Solutions and Rick Olson of
Github reporting the vulnerability to us.

--
Cheers,

Koz

2-3-mailto.patch
3-0-mailto.patch
signature.asc
Reply all
Reply to author
Forward
0 new messages