
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
mongodb-security
Advanced tools
Portable business logic of MongoDB security model, mostly string formatting.
var security = require('mongodb-security');
security.humanize({cluster: true})
.should.equal('For the deployment');
security.humanize({collection: 'users', db: 'mscope'})
.should.equal('On mscope.users');
security.humanize({collection: '', db: 'mscope'})
.should.equal('On any any collection in the mscope database');
security.humanize({collection: 'users', db: ''})
.should.equal('On the users collection in any database');
var MongoClient = require('mongodb').MongoClient;
var security = require('../');
var format = require('util').format;
var username = 'reportsUser';
var password = 'foo';
var authDB = 'reporting';
var url = 'mongodb://localhost:30000/%s';
MongoClient.connect(format(url, authDB), function(err, db) {
if (err) {
throw err;
}
// log in as that user
db.authenticate(username, password, function(err, res) {
// get the user info with privileges
db.command({
usersInfo: {
user: username,
db: authDB
},
showPrivileges: true
}, function(err, res) {
if (err) {
throw err;
}
var user = res.users[0];
console.log(JSON.stringify(user, null, 2));
// check if user has listDatabases privilege with cluster resource
var listDatabasesAllowed = security.getResourcesWithActions(
user, ['listDatabases']).length === 1;
// if allowed, run listDatabases command, if not, set to [].
// merge with databases from user info on which the user is allowed to
// call listCollections
var databases = security.getResourcesWithActions(
user, ['listCollections'], 'database').map(function(resource) {
return resource.db;
});
console.log('user can run listCollections on:', databases);
// run listCollections on all databases, gather all namespaces
// add required privilege actions here
// @see https://docs.mongodb.org/manual/reference/privilege-actions/
var compassActions = ['find', 'collStats'];
// combine namespaces with ones that user has find+collStats privilege
var namespaces = security.getResourcesWithActions(
user, compassActions, 'collection').map(function(resource) {
return resource.db + '.' + resource.collection;
});
console.log('user can run find + collStats on:', namespaces);
db.close();
});
});
});
security.humanize(:resource)
Take the :resource
of a MongoDB grant and hand back a literate sentence prefix.
FAQs
Portable business logic of MongoDB security model
The npm package mongodb-security receives a total of 41 weekly downloads. As such, mongodb-security popularity was classified as not popular.
We found that mongodb-security demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 32 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.