Page MenuHomePhabricator

Disallow <! in <script>
ClosedPublic

Authored by vrana on Oct 16 2013, 3:49 PM.
Tags
None
Referenced Files
F15414261: D7329.id16504.diff
Wed, Mar 19, 11:46 PM
F15407520: D7329.diff
Tue, Mar 18, 6:03 PM
Unknown Object (File)
Mon, Mar 3, 6:30 AM
Unknown Object (File)
Fri, Feb 28, 12:04 PM
Unknown Object (File)
Thu, Feb 27, 3:14 AM
Unknown Object (File)
Thu, Feb 27, 3:14 AM
Unknown Object (File)
Thu, Feb 27, 3:14 AM
Unknown Object (File)
Feb 14 2025, 7:24 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.