You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made it check translation strings for XSS vectors: dangerous tags (script, iframe, svg, etc.) -> error; event handler attributes, style/srcdoc attrs -> error; javascript:/data: hrefs (including percent-encoded bypasses) -> error; http:// -> warning. then allowed tags beyond your a, i, strong: added em, b, br (already in source strings), span (forward compat), kbd, code, samp (per review). I can make it tighter also, please lmk.
I skipped domain allowlisting since strings legitimately link externally and https:// enforcement covers the actual attack surface. It's easy to add in lint_href if we want later.
67 new CI warnings are <ctrl>/<strg>/<enter> keyboard-key pseudo-tags from the preferences string. it's warnings not errors so they don't block. lmk if you'd prefer a carveout or notices.
edit 1: also fixed a gap where double-encoded entities (&#60;) bypassed the early return. html.unescape now always runs before checking for <.
I'd be grateful if you could add the other inline elements I mentioned in #20196 (kbd, code, samp) to the allow-list, as you are already thinking towards future developments.
I am concerned about browsers' quirks mode. Suppose a malicious actor entered < script > - so with a space before or after. Would a browser evaluate that as a full <script> element?
There is also a scenario of constructing it with unicodes (&#nnn;). Hopefully the parser picks this up.
I don't think < script > with spaces is a risk. HTMLParser needs a letter right after < to recognize a tag so spaced versions would just get treated as text. Quirks mode doesnt change this.
I thin he &#nnn; thing was a real issue though. Double-encoded entities (&#60;) weren't in the early return. I fixed this by always running html.unescape before checking for <.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #20196.
I made it check translation strings for XSS vectors: dangerous tags (
script,iframe,svg, etc.) -> error; event handler attributes,style/srcdocattrs -> error;javascript:/data:hrefs (including percent-encoded bypasses) -> error;http://-> warning. then allowed tags beyond youra,i,strong: addedem,b,br(already in source strings),span(forward compat),kbd,code,samp(per review). I can make it tighter also, please lmk.I skipped domain allowlisting since strings legitimately link externally and
https://enforcement covers the actual attack surface. It's easy to add inlint_hrefif we want later.67 new CI warnings are
<ctrl>/<strg>/<enter>keyboard-key pseudo-tags from the preferences string. it's warnings not errors so they don't block. lmk if you'd prefer a carveout or notices.edit 1: also fixed a gap where double-encoded entities (
&#60;) bypassed the early return.html.unescapenow always runs before checking for<.Tested locally:
python bin/trans-lint translation/source/site.xml0 errorspython bin/trans-lint translation/source/study.xml0 errorspython bin/trans-lint translation/dest/*/*.xml0 errors, 363 warnings, exit code 0