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

Commit

Permalink
Add tests for protoype pollution
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusU committed May 13, 2018
1 parent 82bd7f0 commit 9655c70
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 9655c70

Please sign in to comment.