QuizzesHeaders, CSP and Common Vulnerabilities — Concept Check
intermediate
nextjs

Headers, CSP and Common Vulnerabilities — Concept Check

Questions on Headers, CSP and Common Vulnerabilities. A handful of response headers block whole categories of attack. A Content-Security-Policy is the strongest and the fiddliest, because Next injects inline scripts of its own.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Headers, CSP and Common Vulnerabilities — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer sets up a Content-Security-Policy (CSP) for a Next.js application but notices that inline scripts are blocked, causing issues. What is a recommended solution?

    • AAdd 'unsafe-inline' to the CSP
    • BDisable CSP for inline scripts
    • CRemove CSP entirely
    • DUse a nonce for each request to allow inline scripts
  2. 2.A security audit reveals that a web application is vulnerable to clickjacking. Which header should be set to mitigate this risk?

    • AX-Content-Type-Options: nosniff
    • BContent-Security-Policy
    • CX-Frame-Options: DENY
    • DStrict-Transport-Security
  3. 3.A Next.js site is experiencing issues with fetch requests failing and showing CORS errors. What could be a likely cause?

    • AThe CSP includes 'unsafe-inline'
    • BThe API is not included in the CSP connect-src directive
    • CThe API server is down
    • DThe CSP is missing 'self' in default-src
  4. 4.Which header helps prevent a user-uploaded file from being executed as a script?

    • AContent-Security-Policy
    • BStrict-Transport-Security
    • CX-Content-Type-Options: nosniff
    • DX-Frame-Options: DENY
  5. 5.A developer configures a strict CSP but notices that styles from Tailwind CSS are not applied. What is a potential solution?

    • AAllow 'unsafe-inline' for style-src
    • BAdd 'self' to style-src
    • CRemove CSP entirely
    • DUse a nonce for styles
  6. 6.During a security review, a vulnerability is found where user input is rendered directly into HTML using dangerouslySetInnerHTML. What is a recommended practice to prevent XSS?

    • AUse 'self' in script-src
    • BRely on CSP alone
    • CUse DOMPurify to sanitize input
    • DAdd 'unsafe-inline' to CSP
  7. 7.An application relies solely on middleware for authentication. What is a potential risk associated with this approach?

    • AInefficient caching
    • BIncreased server load
    • CIncreased latency
    • DMiddleware bypass via crafted headers
  8. 8.Which header is set to prevent downgrade attacks and cookie theft over HTTP?

    • AX-Content-Type-Options: nosniff
    • BStrict-Transport-Security
    • CX-Frame-Options: DENY
    • DReferrer-Policy