Project

General

Profile

Actions

Bug #6861

closed

ERB::Util.escape_html is not escaping single quotes

Added by spastorino (Santiago Pastorino) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
-
ruby -v:
2.0.0dev
Backport:
[ruby-core:47138]

Description

We just fixed this issue in Rails
https://groups.google.com/forum/#!msg/rubyonrails-security/kKGNeMrnmiY/r2yM7xy-G48J%5B1-25%5D

Ruby's ERB is not escaping single quotes and this could lead to
security issues like ...

My Link!
being link = " '; alert(hax) "

OWASP suggest escaping &, <, >, ", ' and /
https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content

About / I don't think could lead to issues but that's another story.

You have the right code in CGI.escapeHTML
https://github.com/ruby/ruby/blob/c47cca2f/lib/cgi/util.rb#L36 so my
suggestion is to reuse CGI.escapeHTML from ERB::Util

I've sent a pull request https://github.com/ruby/ruby/pull/156


Files

noname (500 Bytes) noname Anonymous, 08/14/2012 12:23 AM
noname (500 Bytes) noname Anonymous, 08/17/2012 03:23 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #5485: ERB html_escape should follow OWASP recommendationsClosedshugo (Shugo Maeda)10/26/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0