Skip to content

Commit

Permalink
chore(merge): add tests for "__proto__" key (#38)
Browse files Browse the repository at this point in the history
* fixed issue#33 CVE-2022-25645 added test for it

* Apply suggestions from code review

Co-authored-by: Timo Machel <[email protected]>
Co-authored-by: Luke Edwards <[email protected]>
  • Loading branch information
3 people authored May 3, 2022
1 parent 2d156c7 commit 845879b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/suites/pollution.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,15 @@ export default function (dset) {
});
});

// Test for CVE-2022-25645 - CWE-1321
pollution('should ignore JSON.parse crafted object with "__proto__" key', () => {
let a = { b: { c: 1 } };
assert.is(a.polluted, undefined);
assert.is({}.polluted, undefined);
dset(a, "b", JSON.parse('{"__proto__":{"polluted":"Yes!"}}'));
assert.is(a.polluted, undefined);
assert.is({}.polluted, undefined);
});

pollution.run();
}

0 comments on commit 845879b

Please sign in to comment.