HTML5 & Web APIs (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Content Security Policy (CSP) in HTML Meta Tags: Preventing XSS.
senior LevelMost AskedSecurity & AuthSystem Design
In Simple Words:
A Content Security Policy restricts where scripts, images, styles, and frames can be loaded from. It can be delivered via HTTP header or HTML <meta http-equiv="Content-Security-Policy">:
default-src 'self': Only load assets from the origin domain.script-src 'self' 'nonce-rAnd0m': Only executes scripts bearing a cryptographic nonce generated per-request, blocking injected inline script XSS payloads.