Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91f003a

Browse files
authored
Merge pull request #10053 from 418sec/1-npm-mongoose
Security Fix for Prototype Pollution - huntr.dev
2 parents 00e059d + 3ed44ff commit 91f003a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/schema.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,11 @@ Schema.prototype.add = function add(obj, prefix) {
466466
}
467467

468468
prefix = prefix || '';
469+
// avoid prototype pollution
470+
if (prefix === '__proto__.' || prefix === 'constructor.' || prefix === 'prototype.') {
471+
return this;
472+
}
473+
469474
const keys = Object.keys(obj);
470475

471476
for (const key of keys) {

0 commit comments

Comments
 (0)