Last active
March 6, 2019 14:18
-
-
Save schirrmacher/180d06030ad7c925980ea526985d1747 to your computer and use it in GitHub Desktop.
__proto__ attack example
This file contains 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 characters
// 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