Skip to content

g:select tag has reflected/stored XSS vulnerability in grails 2 and 3 #10256

@gschueler

Description

@gschueler

Steps to Reproduce

  1. Use the <g:select ../> tag
  2. Either Provide a set of key/value pairs using optionKey or a list of strings with the from attribute
  3. Any unescaped strings, or objects with unescaped key are not encoded
  4. Values via URL params, or from stored domain object would cause XSS

Example:

<%
  def data=[["key":"\"></option></select><script>alert('hi')</script>", value: "option"]]
%>

<g:select name="test" from="${data}" optionKey="key" optionValue="value" />

<%
  def data2=["abc","\"></option></select><script>alert('hi')</script>"]
%>

<g:select name="test" from="${data2}" />

Expected Behaviour

The value= attribute of the <option> that is generated should be properly HTML encoded.

<select name="test">
<option value="&quot;&gt;&lt;/option&gt;&lt;/select&gt;&lt;script&gt;alert(&#39;hi&#39;)&lt;/script&gt;">option</option>
</select>

Actual Behaviour

The value= attribute of the <option> that is generated is not HTML encoded.

<select name="test">
<option value=""></option></select><script>alert('hi')</script>">option</option>
</select>

Environment Information

  • Operating System: Mac OS X 10.11.6
  • Grails Version: 2.5.5, 3.2.1
  • JDK Version: 1.8
  • Container Version (If Applicable): any

Example Application

  • TODO: link to github repository with example that reproduces the issue

if necessary i can create an example repo, but it is simple to reproduce

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions