SV-265929r1028804_rule
V-265929
SRG-APP-000251-DB-000160
MD7X-00-005700
CAT II
10
Disable the javascriptEnabled option in the MongoDB configuration file (default location: /etc/mongod.conf) to include the following:
security:
javascriptEnabled: false
If document validation is needed, it should be configured according to the documentation page at: https://www.mongodb.com/docs/v7.0/core/schema-validation/.
As a client program assembles a query in MongoDB, it builds a BSON object, not a string. Thus traditional SQL injection attacks are not a problem. However, MongoDB operations permit arbitrary JavaScript expressions to be run directly on the server.
To check, run the following command from the MongoDB shell:
> db.col.find({ $where: "return true;"} )
If the response does not return an error, this is a finding.
If javascript has been correctly disabled, the correct error would indicate that the javascript global engine has been disabled. For example:
MongoServerError: no globalScriptEngine in $where parsing}
V-265929
False
MD7X-00-005700
As a client program assembles a query in MongoDB, it builds a BSON object, not a string. Thus traditional SQL injection attacks are not a problem. However, MongoDB operations permit arbitrary JavaScript expressions to be run directly on the server.
To check, run the following command from the MongoDB shell:
> db.col.find({ $where: "return true;"} )
If the response does not return an error, this is a finding.
If javascript has been correctly disabled, the correct error would indicate that the javascript global engine has been disabled. For example:
MongoServerError: no globalScriptEngine in $where parsing}
M
5637