Repository navigation
Description
Description of the issue
PackageExports::getALibraryInputParameter() treats every parameter of a function exported from a named package.json as untrusted library input, including packages marked "private": true, which npm refuses to publish. In a pnpm monorepo, a private workspace package that the app's own server and client import becomes thousands of sources for js/prototype-polluting-assignment and js/polynomial-redos.
In Pasta-Devs/Marinara-Engine (CodeQL 2.27.4, build-mode: none, default query suite):
@marinara-engine/sharedis private and re-exports its API fromsrc/index.ts. 4,459 of the 7,316 sources ofjs/prototype-polluting-assignmentare its function parameters.js/prototype-polluting-assignmenttakes about 26 minutes on a GitHub-hosted runner, more than half of the full scan.Flow::Stage4::fwdFlow1reaches 215 million tuples.- The query is diff-informed, so a pull request scan runs it in full whenever the diff touches one of its sources or sinks. That holds for every scan of such a PR, which takes 20 to 38 minutes each time instead of about 4. Over five days, 30 of 215 PRs (14%) ended with a slow scan; for one contributor whose PRs often touch server code, 9 of 31. Each new push cancels the running scan, so one PR spent 118 minutes on 7 cancelled scans before its final 22-minute scan.
- All 5 of its alerts are false positives; 4 have a library input as their source.
- Query filters don't help: codeql-action enables overlay analysis for JavaScript only with the default query suite, so excluding the query makes every PR scan a full scan.
NPM.qll already has PackageJson.isPrivate(). Skipping private packages in PackageExports.qll:
- getAnExportFromModule(any(PackageJson pack | exists(pack.getPackageName())).getExportedModule(_))
+ getAnExportFromModule(any(PackageJson pack | exists(pack.getPackageName()) and not pack.isPrivate()).getExportedModule(_))- func.getFile() = any(PackageJsonEx pack).getMainFileOrBestGuess()
+ func.getFile() = any(PackageJsonEx pack | not pack.isPrivate()).getMainFileOrBestGuess()Measured on the same database with --threads=4 --ram=14500, the limits codeql-action uses on a hosted runner:
| Query | Before | After |
|---|---|---|
js/prototype-polluting-assignment |
586 s, 5 results | 43 s, 0 results |
js/polynomial-redos |
165 s, 0 results | 34 s, 0 results |
The change also removes the one alert whose source is a remote flow source (req.body in packages/server/src/routes/connections.routes.ts:825, sink in packages/server/src/utils/stored-secrets.ts:179). That alert is a false positive: the property name comes from a constant list stored in the same tuple array as the tainted object. I couldn't find why removing library-input sources removes a path that starts at a remote source.
To reproduce, at commit 77c60cce8d798f5b885f81ffab42ae8794123aa9:
codeql database create db --language=javascript --build-mode=none --source-root=. --codescanning-config=config.yml
codeql database run-queries db codeql/javascript-queries:Security/CWE-915/PrototypePollutingAssignment.ql --threads=4 --ram=14500
with config.yml:
paths-ignore:
- scripts/regressions
- e2e
Activity
jketema commentedon Nov 19, 2026
Hi @kolacheee,
Thanks for the report. I've passed this on to the responsible team.