fix(#638): escape DOM-sourced email parts in site mailto builder (CodeQL #8)#639
Merged
Merged
Conversation
The email-obfuscation snippet built a mailto: href from the data-u/data-d DOM attributes without escaping, which CodeQL flags as js/xss-through-dom (me2resh#8). Wrap the local-part and domain in encodeURIComponent so meta-characters are escaped before reaching the href sink. Real-world risk was low (author-controlled attributes; mailto: prefix precludes javascript:), but this clears the alert and is a no-op for normal addresses. Closes me2resh#638
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
js/xss-through-dom) insite/index.html. The email-obfuscation snippet assembled amailto:href from thedata-u/data-dDOM attributes (read viagetAttribute) and concatenated them unescaped into thehref— DOM text flowing into a DOM sink.encodeURIComponent('mailto:' + encodeURIComponent(u) + '@' + encodeURIComponent(d) + …). CodeQL recognisesencodeURIComponentas a sanitiser, so the alert clears; meta-characters are escaped before the sink.encodeURIComponent('ahmed')/encodeURIComponent('apexscript.com')are no-ops (alphanumerics +.aren't encoded). The@(@) separator is preserved. Real-world risk was already low (the data attributes are author-set and themailto:prefix precludes ajavascript:URL), so this is defence-in-depth + alert hygiene.Testing
encodeURIComponent— no structural change; the surrounding IIFE still parses.mailto:ahmed@…?subject=…&body=…href.js/xss-through-domrefactor(#100): multi-project only + fork-first install #8 should resolve on the next scan.Closes #638
Glossary
js/xss-through-dom)encodeURIComponentmailto:at runtime to deter naive address scrapers.