Skip to content

Commit e1ecdbf

Browse files
committed
Fix prototype pollution vulnerability
1 parent fc9ba65 commit e1ecdbf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/internal/iterator.js

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ function createObjectIterator(obj) {
2626
var len = okeys.length;
2727
return function next() {
2828
var key = okeys[++i];
29+
if (key === '__proto__') {
30+
return next();
31+
}
2932
return i < len ? {value: obj[key], key} : null;
3033
};
3134
}

test/mapValues.js

+11
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ describe('mapValues', () => {
6060
done();
6161
}, 50);
6262
});
63+
64+
it('prototype pollution', (done) => {
65+
var input = JSON.parse('{"a": 1, "b": 2, "__proto__": { "exploit": true }}');
66+
67+
async.mapValues(input, (val, key, next) => {
68+
next(null, val)
69+
}, (err, result) => {
70+
expect(result.exploit).to.equal(undefined)
71+
done(err);
72+
})
73+
})
6374
});
6475

6576
context('mapValues', () => {

0 commit comments

Comments
 (0)