Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #39 from LinusU/prototype-pollution-test
Browse files Browse the repository at this point in the history
Add tests for protoype pollution
  • Loading branch information
Raynos committed Jun 20, 2018
2 parents 82bd7f0 + 9655c70 commit 69a08ab
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,23 @@ test("null prototype mutable", function (assert) {
assert.equal(a.bar, "baz")
assert.end()
})

test("prototype pollution", function (assert) {
var a = {}
var maliciousPayload = '{"__proto__":{"oops":"It works!"}}'

assert.strictEqual(a.oops, undefined)
extend({}, maliciousPayload)
assert.strictEqual(a.oops, undefined)
assert.end()
})

test("prototype pollution mutable", function (assert) {
var a = {}
var maliciousPayload = '{"__proto__":{"oops":"It works!"}}'

assert.strictEqual(a.oops, undefined)
mutableExtend({}, maliciousPayload)
assert.strictEqual(a.oops, undefined)
assert.end()
})

0 comments on commit 69a08ab

Please sign in to comment.