diff --git a/lib/internal/iterator.js b/lib/internal/iterator.js index 15c6fddb4..24056effd 100644 --- a/lib/internal/iterator.js +++ b/lib/internal/iterator.js @@ -27,6 +27,9 @@ function createObjectIterator(obj) { var len = okeys.length; return function next() { var key = okeys[++i]; + if (key === '__proto__') { + return next(); + } return i < len ? {value: obj[key], key: key} : null; }; } diff --git a/mocha_test/mapValues.js b/mocha_test/mapValues.js index 612feffcb..640060ffd 100644 --- a/mocha_test/mapValues.js +++ b/mocha_test/mapValues.js @@ -39,6 +39,17 @@ describe('mapValues', function () { done(); }); }); + + it('prototype pollution', (done) => { + var input = JSON.parse('{"a": 1, "b": 2, "__proto__": { "exploit": true }}'); + + async.mapValues(input, (val, key, next) => { + next(null, val) + }, (err, result) => { + expect(result.exploit).to.equal(undefined) + done(err); + }) + }) }); context('mapValues', function () {