Skip to content

chore(security): document sanitization breaking change.#8510

Closed
mprobst wants to merge 0 commit intoangular:masterfrom
mprobst:document-breaking-css-value
Closed

chore(security): document sanitization breaking change.#8510
mprobst wants to merge 0 commit intoangular:masterfrom
mprobst:document-breaking-css-value

Conversation

@mprobst
Copy link
Copy Markdown
Contributor

@mprobst mprobst commented May 6, 2016

See #8491.

@ericmartinezr
Copy link
Copy Markdown
Contributor

With all due respect this is simply stupid

this.safeStyleValue = sanitizer.bypassSecurityTrustStyle('rotate(90deg)')

Angular2 should have an internal list of dangerous styles and pass them through that ugly function without the user knowing about, this way sanitization can even be optional `provide(Sanitization, {useValue: true/false`` (or whatever)

PLEASE don't make the dom handling the new router, PLEASE

@mprobst
Copy link
Copy Markdown
Contributor Author

mprobst commented May 6, 2016

@ericmartinezr we should improve our CSS sanitization whitelist, stuff like rotate(7deg) should be reasonable to detect. We'll have an issue on that.

That being said, you cannot build security by detecting dangerous patterns. There's always some odd browser or some crazy escaping hack that would break app security, so having a list of dangerous patterns won't work. See e.g. OWASP's resources on XSS prevention for more documentation.

@ericmartinezr
Copy link
Copy Markdown
Contributor

you cannot detect all dangerous patterns

In that case angular2 shouldn't do anything about it, or you provide full security or you provide none. Let the user handle the security of his/her own application, and in that case (again), Sanitization optional would be a solution/workaround. If I know angular2 can't provide full security, I turn sanitization off and I do it myself, if I know it will provide little security (and I'm ok with that) I turn it on and I fill the gaps ng2 can't (use that ugly function above, or any other).

CHANGELOG.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be

MyComponent {
  constructor(sanitizer: DomSanitizationService) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I was trying to be brief and failed :-) done.

@CaptainCodeman
Copy link
Copy Markdown

Yes, please let this be opt-in or at least able to be turned off.

If your styles are 100% app code generated or you properly sanitize content then it's not required.

@mprobst mprobst mentioned this pull request May 6, 2016
17 tasks
@mprobst mprobst force-pushed the document-breaking-css-value branch from 2ca48ce to a0655c2 Compare May 6, 2016 15:45
@mprobst
Copy link
Copy Markdown
Contributor Author

mprobst commented May 6, 2016

I filed #8511 for a general tracking bug on this, let's move the discussion there (this PR is only about documenting it).

@mprobst
Copy link
Copy Markdown
Contributor Author

mprobst commented May 6, 2016

@ericmartinezr the whitelist implementation is fully secure, by only allowing known to be safe values. I'm just explaining why we cannot have a blacklist based implementation as you suggested.

@mprobst mprobst added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 9, 2016
CHANGELOG.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's usually safer to use tripple back-tick style escaping of code blocks. using indentation is error prone and can get messed up with reformatting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@IgorMinar
Copy link
Copy Markdown
Contributor

lgtm

@IgorMinar IgorMinar added pr_state: LGTM action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels May 10, 2016
@mprobst mprobst closed this May 10, 2016
@mprobst mprobst force-pushed the document-breaking-css-value branch from a0655c2 to cf73ad7 Compare May 10, 2016 15:37
@mprobst mprobst deleted the document-breaking-css-value branch May 10, 2016 15:37
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants