JS: Some preliminary fixes from name resolution branch#19192
JS: Some preliminary fixes from name resolution branch#19192asgerf merged 6 commits intogithub:mainfrom
Conversation
This code resulted in bad join orders in response to certain library changes. The actual library changes have to be split into smaller pieces but I'd like to ensure I don't run into the bad join again.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces some preliminary fixes from the name resolution branch aimed at improving the detection of DOM element references and addressing a previously identified issue with BadRandomness.
- Introduces a test function in the DOM-based XSS test file to trigger a potential XSS scenario.
- Updates the change notes to document the improved detection of DOM element references.
Reviewed Changes
Copilot reviewed 2 out of 7 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/dom.js | Adds a new test function to expose potential DOM-based XSS via innerHTML assignment. |
| javascript/ql/src/change-notes/2025-04-02-name-resolution-independent-fixes.md | Updates change notes to document the improved detection of DOM references. |
Files not reviewed (5)
- javascript/ql/lib/semmle/javascript/DOM.qll: Language not supported
- javascript/ql/src/Security/CWE-327/BadRandomness.ql: Language not supported
- javascript/ql/test/library-tests/DOM/Customizations.expected: Language not supported
- javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/Xss.expected: Language not supported
- javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/XssWithAdditionalSources.expected: Language not supported
Comments suppressed due to low confidence (1)
javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/dom.js:3
- [nitpick] The variable name 'e2' is ambiguous; consider using a more descriptive name such as 'childElement' or 'barElement' for improved readability.
const e2 = elm.getElementsByTagName("bar")[0];
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
| // Getting around the 32 bit ints in QL. These are some hex values of the form 0x10000000 | ||
| result.asExpr().(NumberLiteral).getValue() = | ||
| ["281474976710656", "17592186044416", "1099511627776", "68719476736", "4294967296"] | ||
| or |
There was a problem hiding this comment.
I think I remember something about bigint in CodeQL? Has that shipped yet?
There was a problem hiding this comment.
Yes, string.toBigInt() is a thing now. But I'd rather leave it for another PR
Some general improvements that came up while investigating regressions in the name/type resolution branch, but aren't specifically related to type/name resolution.
TypeScript ships with
.d.tsfiles for the DOM, and when we stop extracting types, we're relying on our DOM model to recover the same information. This pointed out some minor issues with our current model.There was also a bad join in
BadRandomnessthat came up in response to certain library changes, and I'd like to get the fix in there so it doesn't pop up again.