CVE-2026-40351: Typescript Nosql Injection Via Type Assertion On Request Body

A credential-like field (e.g., password, token, code) destructured from `req.body` via a TypeScript type assertion (`as <Type>`) is passed directly into a Mongoose equality query. TypeScript type assertions are erased at runtime and do not validate input, so an attacker can submit a JSON object such as `{"$ne": ""}` for a field expected to be a string/number

Provally CuratedPublic repositoryHighHigh confidenceVerifiedApache-2.0TS
greprules fetch cve-2026-40351-typescript-nosql-injection-via-type-assertion-on-request-body --engine opengrep

Description

A credential-like field (e.g., password, token, code) destructured from `req.body` via a TypeScript type assertion (`as <Type>`) is passed directly into a Mongoose equality query. TypeScript type assertions are erased at runtime and do not validate input, so an attacker can submit a JSON object such as `{"$ne": ""}` for a field expected to be a string/number