Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

fix(select): block xss on md-select-label #10023

Merged
merged 1 commit into from Dec 1, 2016

Conversation

jelbourn
Copy link
Member

No description provided.

@jelbourn jelbourn added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Nov 15, 2016
@googlebot googlebot added the cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ label Nov 15, 2016
@jelbourn jelbourn force-pushed the md-select-xss branch 4 times, most recently from a5a860e to 1738662 Compare November 15, 2016 23:52
if (attr.mdSelectedHtml) {
if (!$injector.has('$sanitize')) {
throw Error('The ngSanitize module must be loaded in order to use ' +
'md-treat-selected-text-as-html.');
Copy link

@rjamet rjamet Nov 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's no $sanitize, the user will get an $sce:unsafe error from getTrustedHtml, which points to the sanitizer already. It can make sense to not have it (codesize), and rely on $sce.trustAsHtml only instead, and you'll fail hard for them at this point. So from a purely security POV I wouldn't throw here or look for $sanitize, and just let $sce.getTrustedHtml do its thing: you already have the same pattern everywhere ng-bind-html is used.

@rjamet
Copy link

rjamet commented Nov 16, 2016

Besides from the small comment, looks good :) thanks for the super-quick patch !

@jelbourn jelbourn changed the title WIP fix(select): block xss on md-select-label fix(select): block xss on md-select-label Nov 19, 2016
@jelbourn jelbourn added needs: review This PR is waiting on review from the team and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Nov 19, 2016
@jelbourn
Copy link
Member Author

@ThomasBurleson @ErinCoughlan can you review?

Copy link
Contributor

@ErinCoughlan ErinCoughlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// Using getTrustedHtml will run the content through $sanitize if it is not already
// explicitly trusted. If the ngSanitize module is not loaded, this will
// *correctly* throw an sce error.
target.html($sce.getTrustedHtml(text));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@ThomasBurleson ThomasBurleson added P0: critical Critical issues that must be addressed immediately. and removed needs: review This PR is waiting on review from the team labels Nov 19, 2016
@ThomasBurleson ThomasBurleson added this to the 1.1.2 milestone Nov 19, 2016
@ThomasBurleson
Copy link
Contributor

@jelbourn - lgtm.

@jelbourn jelbourn merged commit f7ecb4f into angular:master Dec 1, 2016
@Splaktar
Copy link
Member

This was a breaking change for users upgrading from 1.1.1 to 1.1.4/1.1.5 as mentioned in #10912. I'm going to update the changelog to add this to the breaking changes for 1.1.2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
- Breaking Change cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ P0: critical Critical issues that must be addressed immediately.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants