Web and API Security, lesson 3
Cross-site scripting and content security policy
Encode output for its context, and back it with a strict content policy.
When a page shows a value its own code didn't write, the browser may read it as markup, the page's HTML, or as script, and the script runs as your page, reaching everything your origin can. You'll encode each value for where it lands, use the browser's safe functions, and back both with a strict content security policy, rolled out without breaking the site. You need the same-origin policy from lesson 02.
Part of Pro
In this lesson
- Data the page reads as script
- Encode for the place a value lands
- A strict content security policy, rolled out safely
Cybersecurity comes with Pro: every lesson in every module.
Web and API Security overviewSpotted a mistake? Tell us.