Skip to content

Commit

Permalink
Merge pull request #1 from zpbrent/patch-2
Browse files Browse the repository at this point in the history
Security Fix for Prototype Pollution in mongoose
  • Loading branch information
huntr.dev | the place to protect open source committed Mar 22, 2021
2 parents fba3457 + 468ab22 commit 3ed44ff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/schema.js
Expand Up @@ -466,6 +466,11 @@ Schema.prototype.add = function add(obj, prefix) {
}

prefix = prefix || '';
// avoid prototype pollution
if (prefix === '__proto__.' || prefix === 'constructor.' || prefix === 'prototype.') {
return this;
}

const keys = Object.keys(obj);

for (const key of keys) {
Expand Down

0 comments on commit 3ed44ff

Please sign in to comment.