Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive - DOMParser().parseFromString is treated as XSS sink #12882

Open
tyage opened this issue Apr 20, 2023 · 0 comments
Open

False positive - DOMParser().parseFromString is treated as XSS sink #12882

tyage opened this issue Apr 20, 2023 · 0 comments

Comments

@tyage
Copy link
Contributor

tyage commented Apr 20, 2023

Description of the false positive

CodeQL considers DOMParser().parseFromString as XSS sink but I think it is no longer XSS sink.

Though there was a bug in Safari some years ago, but the method is designed not to execute JavaScript as far as I read the discussions in GoogleChrome/web.dev#6890 and the spec.

https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring-dev

Note that script elements are not evaluated during parsing, and the resulting document's encoding will always be UTF-8.

Code samples or links to source code

https://github.com/microsoft/vscode/blob/57bceb67381bd630e4e7bac7a8ea170fd2f0b01e/extensions/markdown-language-features/preview-src/index.ts#L133-L134

var target = document.location.search
var parser = new DOMParser();
parser.parseFromString(target, "application/xml"); // NOT OK

URL to the alert on GitHub code scanning (optional)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants