Hub rules-mongoose

rules-mongoose

v3 public Verified

Mongoose

Mongoose is a JavaScript object modeling tool designed to work in an asynchronous environment for MongoDB. These rules ensure proper schema validation, secure middleware usage, and efficient query patterns in Node.js applications using Mongoose.

@sigmashakeinc 2 pulls 6 rules published Apr 8, 2026 synced Nov 22, 2026 sigmashakeinc/rules/rulesets/rules-mongoose →
Severity
3 error 3 warn 0 info
demo.cast
Mongoose is a JavaScript object modeling tool designed to work in an asynchronous environment for MongoDB. These rules ensure proper schema validation, secure middleware usage, and efficient query patterns in Node.js applications using Mongoose.

Rules index

6 governance rules

Indexed from the repository's .rules files, grouped by technology. Expand any rule to read the raw source.

mongoose

mongoose-deprecated-remove-api warning log

Model.remove() is deprecated since Mongoose 7 and removed in Mongoose 8. Use deleteOne() to remove a single document or deleteMany() to remove multiple. These also return a DeleteResult with the count of removed documents for better observability.

Rule source requires an active Pro or Enterprise subscription.
mongoose-no-mass-assignment-via-spread warning log

Mass assignment (CWE-915): constructing a Mongoose document from the full request body allows attackers to set fields like 'role', 'isAdmin', or '__v' that should never be user-controlled. Use a DTO or explicitly pick allowed fields: new UserModel({ name: req.body.name, email: req.body.email }) instead of new UserModel(req.body).

Rule source requires an active Pro or Enterprise subscription.
mongoose-no-populate-user-controlled-path warning log

Mongoose populate() with a user-controlled path or options object can cause unauthorized data disclosure. An attacker can specify a field path that resolves to a sensitive collection (e.g., 'password', '_id' on a related Users document). Always hard-code populate paths and select only needed fields: .populate({ path: 'author', select: 'name' }).

Rule source requires an active Pro or Enterprise subscription.
mongoose-no-strict-false error ask

Mongoose strict: false allows any field not in the schema to be saved to MongoDB. This disables the schema-level protection against mass assignment (CWE-915) — an attacker who controls the input object can persist arbitrary fields, potentially overwriting role, isAdmin, or internal state fields. Keep strict mode enabled (the default) and define all allowed fields explicitly in the schema.

Rule source requires an active Pro or Enterprise subscription.
mongoose-no-user-query-passthrough error block

NoSQL injection (CWE-943): raw HTTP request object passed directly to a Mongoose query method allows operator injection. An attacker submitting { "password": { "$ne": "" } } bypasses equality checks. Always explicitly construct the query from validated fields: Model.findOne({ email: req.body.email }) not Model.findOne(req.body).

Rule source requires an active Pro or Enterprise subscription.
mongoose-no-where-operator error block

MongoDB $where executes arbitrary JavaScript in the server engine for every document scanned (CWE-943). An attacker who controls any part of the value can run server-side code. $where is disabled by default in MongoDB 4.4+ (security.javascriptEnabled: false). Remove $where and rewrite the filter using standard Mongoose query operators.

Rule source requires an active Pro or Enterprise subscription.

Version metadata

Published metadata

The hash-locked record of this published ruleset. When source contents change, the maintainer resyncs and the version bumps.

Version
v3
Published
Apr 8, 2026
Source commits
0
Synced
Nov 22, 2026
Hash
710c474857e1a871d8b0d02918830356d6b79cd93686b2bd2725babbe24412d7
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

Latest commits touching rulesets/rules-mongoose/.sigmashake/rules in sigmashakeinc/rules/rulesets/rules-mongoose. The published version only bumps when a maintainer resyncs.

No commit history available.