EXERCISE 1 — Behaviour under script-src 'self'
================================================
POLICY: Content-Security-Policy: script-src 'self'
Meaning: scripts may only load/execute if they come from the page's OWN
origin as EXTERNAL files. Inline scripts and event-handler attributes are NOT
allowed (no 'unsafe-inline'), and scripts from other domains are blocked.
(a) A legitimate EXTERNAL script from your own origin:
RESULT: RUNS. It's loaded from 'self' (same origin) as an external file,
which script-src 'self' permits. Your real app code keeps working --
provided it's in external files, not inline.
(b) An injected INLINE (or )
RESULT: BLOCKED -- does NOT execute. Inline scripts are not allowed by
'self' (only external same-origin files are). The browser refuses to run
it and reports a CSP violation. Even though the attacker successfully
INJECTED the tag into the HTML, the browser won't EXECUTE it.
(c) An injected event-handler attribute:
RESULT: BLOCKED -- the onerror does NOT fire. Inline event handlers count
as inline script and are forbidden without 'unsafe-inline'. So the classic
no-