Grokking the Modern Frontend System Design Interview
Vote

0% completed

​

Cross Site Scripting and Content Security Policy

const comment = { text: '<img src="x" onerror="window.ran = true">Fresh and crisp apples' } list.innerHTML = '<li>' + comment.text + '</li>'

The first line is a product review as Basket's API returns it, written by a shopper. The second line is how a product page might show it. The shopper reading the page sees only "Fresh and crisp apples", but the browser also created an image with a broken address, and its onerror attribute ran the reviewer's code inside Basket's page.

Here that code only sets a flag

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content