Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. const u1 = {firstName: 'Foo'}
  2. const u2 = {firstName: 'John'}
  3.  
  4. const body = JSON.parse('{"__proto__": {"admin": true}}')
  5.  
  6. function vulnerableExtend(dst, src) {
  7. Object.entries(src)
  8. .forEach(([k, v]) => {
  9. if (k in dst) {
  10. vulnerableExtend(dst[k], src[k]);
  11. } else {
  12. dst[k] = src[k];
  13. }
  14. })
  15. }
  16.  
  17. console.log(u1.admin)
  18. console.log(u2.admin)
  19.  
  20. vulnerableExtend(u1, body);
  21.  
  22. console.log(u1.admin)
  23. console.log(u2.admin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement