0
0
Cybersecurityknowledge~20 mins

Content Security Policy (CSP) in Cybersecurity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSP Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of Content Security Policy (CSP)?

Choose the best description of what CSP is designed to do.

ATo manage user authentication and sessions
BTo prevent unauthorized scripts and resources from loading on a web page
CTo speed up website loading by caching resources
DTo encrypt all data sent between a browser and server
Attempts:
2 left
💡 Hint

Think about how CSP controls what content a browser can load.

📋 Factual
intermediate
2:00remaining
Which HTTP header is used to implement Content Security Policy?

Select the correct HTTP header name that delivers CSP rules to browsers.

AX-Content-Security-Policy
BX-Frame-Options
CStrict-Transport-Security
DContent-Security-Policy
Attempts:
2 left
💡 Hint

Look for the header that directly mentions 'Content-Security-Policy'.

🔍 Analysis
advanced
2:00remaining
What will happen if a CSP rule includes script-src 'self' but the page tries to load an inline script?

Analyze the effect of this CSP directive on inline scripts.

AThe inline script will run only if it has a nonce attribute
BThe inline script will run normally without restrictions
CThe inline script will be blocked and not executed
DThe inline script will run only if it is loaded from an external trusted domain
Attempts:
2 left
💡 Hint

Consider what 'self' allows and how inline scripts are treated by default.

Comparison
advanced
2:00remaining
Compare the difference between default-src and script-src directives in CSP.

Which statement correctly explains their relationship?

A<code>default-src</code> sets fallback rules for all resource types; <code>script-src</code> overrides it specifically for scripts
B<code>script-src</code> sets fallback rules for all resource types; <code>default-src</code> overrides it specifically for scripts
CBoth directives control the same resources and have equal priority
D<code>default-src</code> only controls images; <code>script-src</code> controls scripts
Attempts:
2 left
💡 Hint

Think about how CSP applies general and specific rules.

Reasoning
expert
2:00remaining
Given this CSP header: Content-Security-Policy: default-src 'none'; img-src https://images.example.com; script-src 'self' 'nonce-abc123', which of the following is true?

Analyze which resources are allowed to load or execute.

AOnly images from https://images.example.com; scripts from the same origin or with nonce 'abc123' are allowed; all other resources are blocked
BAll images and scripts from any source are allowed because of the nonce
CScripts from any origin are allowed if they have the nonce; images from any source are allowed
DNo resources are allowed because default-src is 'none'
Attempts:
2 left
💡 Hint

Consider how each directive limits resource loading and the role of 'none' in default-src.