Created
July 25, 2019 15:05
-
-
Save changhuixu/5602bce32586a91c268a4a202d3ee9c8 to your computer and use it in GitHub Desktop.
Object.prototype polluted by __proto__
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 characters
// you can play with the following code snippet in browser console. | |
let person = {name: 'John Doe'} | |
console.log(person.name) | |
// John Doe | |
person.__proto__.toString = () => {alert('evil')} | |
console.log(person.name) | |
// an alert box with "evil" pops up | |
let person2 = {} | |
console.log(person2) | |
// {} | |
// an alert box with "evil" pops up | |
// if you stay in the browser, | |
// clicking any place in the page, you will see a new alert box pop up... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment