Introduction
Websites often face risks from harmful scripts or content that can steal information or damage the site. Content Security Policy helps stop these risks by controlling what content a website can load and run.
Imagine a nightclub that only lets in guests on a special list. The bouncer checks each person and stops anyone not approved from entering. This keeps the club safe from troublemakers.
┌─────────────────────────────┐
│ Website Server │
│ Sends CSP Policy to Browser │
└─────────────┬───────────────┘
│
│
┌─────────────▼───────────────┐
│ Browser │
│ Receives CSP Policy Header │
│ Checks Content Sources │
│ Blocks Unapproved Content │
└─────────────┬───────────────┘
│
▼
Safe Content Displayed