Page MenuHomePhabricator

Disallow <! in <script>
ClosedPublic

Authored by vrana on Oct 16 2013, 3:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 17, 11:43 PM
Unknown Object (File)
Fri, Nov 15, 12:09 PM
Unknown Object (File)
Sun, Nov 10, 7:07 AM
Unknown Object (File)
Mon, Nov 4, 2:20 AM
Unknown Object (File)
Fri, Oct 25, 4:37 AM
Unknown Object (File)
Oct 19 2024, 1:06 PM
Unknown Object (File)
Oct 10 2024, 7:31 PM
Unknown Object (File)
Sep 30 2024, 11:34 PM

Details

Reviewers
epriestley
Commits
Restricted Diffusion Commit
rP29391a658e77: Disallow <! in <script>
Summary

HTML5 has this crazy script escaping states:

  • Script data escaped dash dash state
  • Script data double escaped state

https://communities.coverity.com/blogs/security/2012/11/16/did-i-do-that-html-5-js-escapers-3

Perhaps <! is too aggressive but I didn't spend much time searching for a more fine grained expression.

Test Plan

Searched for renderInlineScript().

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Thanks!

Do you think we should also force json_encode() to escape !? I can't imagine it causing problems, so we could probably wait until it does...

I think this is fine. It should be dangerous only inside <script> and we replace all < before sending it there.