Skip to content

NoSQL Injection Risk #103

@prathamtagad

Description

@prathamtagad

sanitize() Only Strips Top-Level $-Prefixed Keys — NoSQL Injection Risk
File: input.validation.js:L287-L295

module.exports.sanitize = (obj) => {
  const clean = {};
  for (const key in obj) {
    if (!key.startsWith("$")) {
      clean[key] = obj[key]; // Here Nested objects with $ keys are NOT sanitized
    }
  }
  return clean;
};

If a user sends { "profile": { "$gt": "" } }, the nested $gt operator passes through unsanitized. This could enable NoSQL injection in nested update operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions