Skip to content

Instantly share code, notes, and snippets.

@schirrmacher
Last active March 6, 2019 14:18
Show Gist options
  • Save schirrmacher/180d06030ad7c925980ea526985d1747 to your computer and use it in GitHub Desktop.
Save schirrmacher/180d06030ad7c925980ea526985d1747 to your computer and use it in GitHub Desktop.
__proto__ attack example
// has the Object prototype
const someObject = {};
// request input is parsed
const maliciousInput = JSON.parse('{ "__proto__": { "toString": "xxx" } }');
// somewhere a bad copy or merge library is used which copies ALL properties including __proto__
someObject.__proto__.toString = maliciousInput.__proto__.toString;
// at some other place
const someOtherObject = {};
console.log(someOtherObject.toString()); // crashes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment