Created
October 2, 2019 13:24
-
-
Save yjaaidi/0136a9dbea62f0efd6fbead32d261da4 to your computer and use it in GitHub Desktop.
Revisions
-
yjaaidi created this gist
Oct 2, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ const u1 = {firstName: 'Foo'} const u2 = {firstName: 'John'} const body = JSON.parse('{"__proto__": {"admin": true}}') function vulnerableExtend(dst, src) { Object.entries(src) .forEach(([k, v]) => { if (k in dst) { vulnerableExtend(dst[k], src[k]); } else { dst[k] = src[k]; } }) } console.log(u1.admin) console.log(u2.admin) vulnerableExtend(u1, body); console.log(u1.admin) console.log(u2.admin)