Hub rules-mongodb

rules-mongodb

v3 public Verified

MongoDB

MongoDB is a source-available, cross-platform, document-oriented database program. These rules govern MongoDB operations to prevent insecure queries, misconfigured authentication, and accidental data exposure in NoSQL environments.

@sigmashakeinc 3 pulls 7 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-mongodb →
Severity
6 error 1 warn 0 info
demo.cast
MongoDB is a source-available, cross-platform, document-oriented database program. These rules govern MongoDB operations to prevent insecure queries, misconfigured authentication, and accidental data exposure in NoSQL environments.

Rules index

7 governance rules

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

mongodb

mongodb-no-drop-collection-unconditional error ask

db.drop() / collection.drop() / dropDatabase() permanently destroys all documents in a collection or entire database. MongoDB has no built-in recycle bin. Confirm the collection name, verify a backup or Atlas snapshot is available, and ensure this is not reachable from an unauthenticated code path.

Rule source requires an active Pro or Enterprise subscription.
mongodb-no-function-operator error block

MongoDB $function and $accumulator operators execute arbitrary JavaScript in aggregation pipelines (CWE-943). Like $where, these are disabled when security.javascriptEnabled is false. They create the same injection surface: any user-controlled string embedded in the function body becomes server-side code execution. Rewrite with native aggregation operators ($filter, $reduce, $map) instead.

Rule source requires an active Pro or Enterprise subscription.
mongodb-no-hardcoded-connection-string error block

Hardcoded MongoDB connection string with credentials (CWE-798). The URI format 'mongodb://user:password@host' embeds credentials that will persist in git history after removal. Use environment variables: process.env.MONGODB_URI or os.environ['MONGODB_URI']. Atlas users should use API-key auth or IAM instead of username/password URIs.

Rule source requires an active Pro or Enterprise subscription.
mongodb-no-mapreduece-user-input error block

User input in mapReduce function strings is server-side JavaScript injection. MongoDB's mapReduce accepts JS function bodies as strings — embedding user input creates RCE at the database tier. mapReduce is deprecated as of MongoDB 5.0; replace with the aggregation pipeline. If mapReduce must be used, ensure function bodies are static constants with no user input.

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

NoSQL injection (CWE-943): raw HTTP request objects passed directly to MongoDB query methods allow operator injection. An attacker submitting { "username": { "$ne": "" } } will bypass equality checks entirely. Always validate and explicitly construct the query object from known fields: find({ username: req.body.username }) rather than find(req.body).

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

MongoDB $where executes arbitrary JavaScript in the server's JS engine for every document scanned (CWE-943). An attacker who controls any part of the value can run server-side JavaScript, enumerate data, or cause CPU exhaustion. $where is disabled by default in MongoDB 4.4+ (security.javascriptEnabled: false). Remove $where and rewrite the filter using standard query operators ($eq, $gt, $regex, etc.).

Rule source requires an active Pro or Enterprise subscription.
mongodb-outdated-insert-api warning log

collection.insert() is deprecated since MongoDB 3.2 and removed in the Node.js driver v4+. Use insertOne() for a single document or insertMany() for bulk inserts — these return typed results and are consistent with the modern driver API.

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
Oct 11, 2026
Hash
5c663c821dafc174d4e72da38cd12821fd759eb535524c03c84af590353941f0
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

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

No commit history available.