Page MenuHomePhabricator

Disallow <! in <script>
ClosedPublic

Authored by vrana on Oct 16 2013, 3:49 PM.
Tags
None
Referenced Files
F18299682: D7329.id16503.diff
Sat, Aug 23, 6:30 PM
F18284046: D7329.diff
Sat, Aug 23, 2:27 AM
F18115433: D7329.id16504.diff
Wed, Aug 13, 6:47 AM
F18112755: D7329.id.diff
Tue, Aug 12, 8:20 PM
F18108579: D7329.diff
Mon, Aug 11, 7:53 AM
F17643065: D7329.id16504.diff
Jul 11 2025, 9:09 PM
F17638730: D7329.id16503.diff
Jul 11 2025, 4:59 PM
F17630803: D7329.diff
Jul 10 2025, 11:56 AM

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.