Skip to content

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Apr 2, 2025

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.ts files 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 BadRandomness that 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.

asgerf added 3 commits April 2, 2025 10:12
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.
@github-actions github-actions bot added the JS label Apr 2, 2025
@asgerf asgerf marked this pull request as ready for review April 2, 2025 12:15
Copilot AI review requested due to automatic review settings April 2, 2025 12:15
@asgerf asgerf requested a review from a team as a code owner April 2, 2025 12:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +35 to +38
// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I remember something about bigint in CodeQL? Has that shipped yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, string.toBigInt() is a thing now. But I'd rather leave it for another PR

@asgerf asgerf merged commit bb15f30 into github:main Apr 3, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants