Skip to content

fix: use $eq for history.prime query in getAllVersions - #316

Merged
cubap merged 1 commit into
mainfrom
cubap-jubilant-goggles
Sep 24, 2026
Merged

cubap merged 1 commit into
mainfrom
cubap-jubilant-goggles

Conversation

@cubap

@cubap cubap commented Sep 24, 2026

Copy link
Copy Markdown
Member

Summary

Ports the one still-relevant change from #211 (which is being closed as superseded): the NoSQL injection fix in getAllVersions.

controllers/utils.js builds a MongoDB query from a user-derived @id:

db.find({ __rerum.history.prime: rootObj['@id'] })

If @id is a query object (e.g. {$ne: null}), MongoDB interprets it as an operator, allowing query injection. Wrapping the value in $eq forces it to be treated as a literal:

db.find({ __rerum.history.prime: { $eq: rootObj['@id'] } })

This is the same fix that closed code-scanning alert #69 on the #211 branch; the equivalent alert remains open on main (js/sql-injection, controllers/utils.js).

Validation

  • __tests__/utils.test.js + __tests__/routes_mounted.test.js: 70/70 pass
  • routes/__tests__/release.test.js: 3/3 pass (release logic uses getAllVersions)

Related

Wrap the user-derived @id in a MongoDB $eq operator so it is treated as
a literal value rather than a query object, closing the NoSQL injection
code-scanning alert (js/sql-injection) in getAllVersions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@cubap
cubap requested a review from thehabes as a code owner September 24, 2026 16:41
@cubap
cubap deployed to development September 24, 2026 16:41 — with GitHub Actions Active
@cubap cubap changed the title fix: use \ for history.prime query in getAllVersions fix: use $eq for history.prime query in getAllVersions Sep 24, 2026
@cubap
cubap merged commit 5cb5bbe into main Sep 24, 2026
3 checks passed
@cubap
cubap deleted the cubap-jubilant-goggles branch September 24, 2026 16:44

This branch was successfully deployed

1 active deployment
development — 10186339 Deployed Sep 24, 2026 by cubap via deploy (24, vlcdhp02) #570
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant