Skip to content

Instantly share code, notes, and snippets.

@changhuixu
Created July 25, 2019 15:05
Show Gist options
  • Save changhuixu/5602bce32586a91c268a4a202d3ee9c8 to your computer and use it in GitHub Desktop.
Save changhuixu/5602bce32586a91c268a4a202d3ee9c8 to your computer and use it in GitHub Desktop.
Object.prototype polluted by __proto__
// 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