javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-794

h:outputText does not escape quotes - possible HTML injection attack

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.2_09
    • Fix Version/s: unscheduled
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      794

      Description

      The implementation of h:outputText does not escape quotes. If you do...

      <h:outputText value="foo &<>\" bar"/>

      ...you get...

      foo &<>" bar

      ...when I believe you should get...

      foo &<>" bar

      ...otherwise you leave yourself open to HTML injection attacks if you've got
      something like...

      <div style="<h:outputText value="\" this text has broken out"/>"/>

        Activity

        Hide
        kennardconsulting added a comment -

        I think this bug can be traced com.sun.faces.util.HtmlUtils.writeTextChar,
        which escapes ampersands and things but not quotes.

        It manifests itself in several places, not just h:outputText but also
        h:selectOneRadio itemLabels...

        <h:selectOneRadio value="#

        {foo.bar}

        ">
        <f:selectItem itemValue="0" itemLabel="This \" is not escaped"/>
        </h:selectOneRadio>

        ...gives...

        <input type="radio" name="form:j_id_jsp_2054220477_1pc3"
        id="form:j_id_jsp_2054220477_1pc3:0" value="0" />
        <label for="form:j_id_jsp_2054220477_1pc3:0"> This " is not escaped</label>

        ...when it should really give...

        <input type="radio" name="form:j_id_jsp_2054220477_1pc3"
        id="form:j_id_jsp_2054220477_1pc3:0" value="0" />
        <label for="form:j_id_jsp_2054220477_1pc3:0"> This " is not escaped</label>

        Show
        kennardconsulting added a comment - I think this bug can be traced com.sun.faces.util.HtmlUtils.writeTextChar, which escapes ampersands and things but not quotes. It manifests itself in several places, not just h:outputText but also h:selectOneRadio itemLabels... <h:selectOneRadio value="# {foo.bar} "> <f:selectItem itemValue="0" itemLabel="This \" is not escaped"/> </h:selectOneRadio> ...gives... <input type="radio" name="form:j_id_jsp_2054220477_1pc3" id="form:j_id_jsp_2054220477_1pc3:0" value="0" /> <label for="form:j_id_jsp_2054220477_1pc3:0"> This " is not escaped</label> ...when it should really give... <input type="radio" name="form:j_id_jsp_2054220477_1pc3" id="form:j_id_jsp_2054220477_1pc3:0" value="0" /> <label for="form:j_id_jsp_2054220477_1pc3:0"> This " is not escaped</label>
        Hide
        driscoll added a comment -

        Since outputText can write portions of things like javascript, this should be fixed.

        Show
        driscoll added a comment - Since outputText can write portions of things like javascript, this should be fixed.
        Hide
        driscoll added a comment -

        My bug.

        Show
        driscoll added a comment - My bug.
        Hide
        driscoll added a comment -

        Code changes checked in.

        Changed HtmlUtil to urlencode '"' in the same way that it encodes '&'.

        Show
        driscoll added a comment - Code changes checked in. Changed HtmlUtil to urlencode '"' in the same way that it encodes '&'.
        Hide
        kennardconsulting added a comment -

        Thanks guys. Your turnaround time on these bugs has been really awesome. Can't
        wait for the next release.

        Show
        kennardconsulting added a comment - Thanks guys. Your turnaround time on these bugs has been really awesome. Can't wait for the next release.
        Hide
        kennardconsulting added a comment -

        I have now tested this in the nightly builds and can confirm it fixes the
        problem in my application. Thanks guys. Here's to 1.2_10!

        Show
        kennardconsulting added a comment - I have now tested this in the nightly builds and can confirm it fixes the problem in my application. Thanks guys. Here's to 1.2_10!
        Hide
        Manfred Riem added a comment -

        Closing out issue

        Show
        Manfred Riem added a comment - Closing out issue

          People

          • Assignee:
            driscoll
            Reporter:
            kennardconsulting
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: