Skip to content

Find a way to safely match on options.text #1150

Closed

Description

@pfiller

When Chosen was built, searches matched on options.text, not on options.html. This created a possible xss issue that needed to be addressed. You can read the thread for all the details, but the path chosen at the time was to match on options.html.

It is clear at this point that demand exists for matching on options.text (#581, #1119, #927, #905, #807) that we should find a way to do this safely (perhaps adding it as a configureable "use at your own risk" option).

Any PR that closes this issue must demonstrate clearly that it can fix the issues discovered in #73.

Activity

  1. pfiller commented on Apr 18, 2013

    @pfiller
    ContributorAuthor

    This is especially a problem with ember.js which includes script tags in select options.

    Like this:

    <ul class="chzn-results">
      <li id="ember592_chzn_o_1" class="ember-view active-result" style="">
        <script id="metamorph-5-start" type="text/x-placeholder"></script>
        item 1
        <script id="metamorph-5-end" type="text/x-placeholder"></script>
      </li>
      <li id="ember592_chzn_o_2" class="ember-view active-result" style="">
        <script id="metamorph-6-start" type="text/x-placeholder"></script>
        item 2
        <script id="metamorph-6-end" type="text/x-placeholder"></script>
      </li>
    </ul>
  2. pfiller commented on Jul 11, 2013

    @pfiller
    ContributorAuthor

    #1343 Adds a method for escaping text. I think this can be used to go back to option.text instead of option.html. I'll do some experimenting after it lands in master.

  3. GaryChamberlain commented on Jul 15, 2013

    @GaryChamberlain

    +1 for this. I haven't looked too deeply, so maybe I am over-simplifying. Isn't it just a matter of changing the winnow_results function to not search within option.html? How about option.value? As long as you keep the rendering the same, doesn't that avoid the xss issue? If it's because of the wrapping of an around the search text, I personally would rather see that removed so we can have custom html inside the option.

    I'd like to use Chosen to have a drop down list with one OptGroup for named fills (e.g. a configured linear gradient) and another one with standard web colors (e.g. DarkGoldenRod). I'd like show a small box with the background color matching the named color, but cannot because of this issue.

    thx!

  4. Globegitter commented on Aug 1, 2013

    @Globegitter

    👍 For now we just modified it ourselves to option.text to get it to work with ember.js but would be good if there is an official fix.

  5. stof commented on Nov 6, 2013

    @stof
    Contributor

    @pfiller I think that for the search matching itself, using the text should be fine and will solve related issues. The matching string is not reinjected in the DOM as html. I think the PR fixing the XSS vulnerabilities changed all references to option.text without checking how it was used, thus changing too much

  6. simonexmachina commented on Nov 6, 2013

    @simonexmachina

    @stof, yes I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions