-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JS: Improve Express middleware taint tracking #19784
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
base: main
Are you sure you want to change the base?
Conversation
4918962
to
7252874
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Implements enhanced taint tracking in Express middleware by leveraging getALocalSource()
and adding req._parsedUrl
as an input source.
- Introduce a test (
serverSide2.js
) to validate default-value and_parsedUrl
handling. - Update QL library to recognize
_parsedUrl
properties and usegetALocalSource()
in routing analysis. - Refresh expected outputs and add change notes for these enhancements.
Reviewed Changes
Copilot reviewed 7 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
javascript/ql/test/query-tests/Security/CWE-918/serverSide2.js | New test exercising middleware flows with req._parsedUrl and defaults |
javascript/ql/test/query-tests/Security/CWE-918/RequestForgery.expected | Updated expected alerts/provenance for the new test |
javascript/ql/lib/semmle/javascript/frameworks/Express.qll | Extended remote input source matching to include _parsedUrl |
javascript/ql/lib/semmle/javascript/Routing.qll | Added getALocalSource() to the middleware data-flow assignment rule |
javascript/ql/lib/change-notes/2025-06-16-middleware-express.md | Documented the middleware taint-tracking improvements |
Comments suppressed due to low confidence (2)
javascript/ql/test/query-tests/Security/CWE-918/serverSide2.js:10
- req.parsedQuery is never initialized before assigning to its url property, which will cause a runtime error. Consider adding
req.parsedQuery = {}
before this line.
req.parsedQuery.url = req.url || {}; // $Source[js/request-forgery]
javascript/ql/test/query-tests/Security/CWE-918/serverSide2.js:11
- req.SomeObject is undefined when assigning to its url property, leading to a TypeError. Initialize
req.SomeObject = {}
before this assignment.
req.SomeObject.url = req.url; // $Source[js/request-forgery]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small suggestion, otherwise LGTM. 👍
Co-authored-by: Taus <[email protected]>
Improves Express middleware taint tracking by:
getALocalSource()
to better handle default value expressions and similar patterns in middleware data flowreq._parsedUrl
as a remote input source