Recall & Review
beginner
What is Content Security Policy (CSP)?
Content Security Policy (CSP) is a security feature that helps prevent attacks like cross-site scripting (XSS) by controlling which resources a web page can load and execute.
Click to reveal answer
beginner
How does CSP improve website security?
CSP restricts the sources of scripts, styles, images, and other content, so only trusted sources are allowed. This reduces the chance of malicious code running on the site.
Click to reveal answer
intermediate
What is a 'directive' in CSP?
A directive is a rule in CSP that specifies what types of content can be loaded and from where. For example, 'script-src' controls which scripts can run.
Click to reveal answer
beginner
What happens if a resource violates the CSP rules?
The browser blocks the resource from loading or running, protecting the user from potential attacks like malicious scripts.
Click to reveal answer
intermediate
Name two common CSP directives and their purpose.
1. script-src: Controls which JavaScript sources are allowed.<br>2. img-src: Controls which image sources are allowed.
Click to reveal answer
What is the main purpose of Content Security Policy (CSP)?
✗ Incorrect
CSP helps improve security by controlling which resources can be loaded and run on a web page.
Which CSP directive controls which JavaScript files can run on a page?
✗ Incorrect
'script-src' directive specifies allowed sources for JavaScript.
If a script tries to load from an untrusted source not allowed by CSP, what happens?
✗ Incorrect
CSP blocks resources that violate its rules to protect users.
Which of these is NOT a benefit of using CSP?
✗ Incorrect
CSP improves security but does not fix bugs automatically.
How is CSP usually delivered to the browser?
✗ Incorrect
CSP is commonly sent as HTTP headers from the server to the browser.
Explain what Content Security Policy (CSP) is and why it is important for web security.
Think about how websites can block harmful scripts.
You got /3 concepts.
Describe how CSP directives work and give examples of at least two directives.
Directives tell the browser what is allowed.
You got /3 concepts.