QuizzesCORS & CSRF — Concept Check
intermediate
spring-boot

CORS & CSRF — Concept Check

Questions on CORS & CSRF. CORS allows browsers to make cross-origin API calls. CSRF protects stateful (cookie-based) apps from forged requests. Stateless REST APIs with JWT disable CSRF and configure CORS explicitly.

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 CORS & CSRF — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer is configuring CORS for a new web application. They set allowed origins to '*'. What is a potential risk of this configuration?

    • ABlocking all cross-origin requests
    • BPreventing the application from using cookies
    • CIncreased risk of CSRF attacks
    • DExposing the server to cross-origin requests from any domain
  2. 2.A stateless REST API using JWT is being developed. What is an appropriate security configuration?

    • ADisable both CSRF and CORS protections
    • BDisable CSRF protection and configure CORS globally
    • CEnable both CSRF and CORS protections
    • DEnable CSRF protection and configure CORS globally
  3. 3.A developer notices that their web app's API calls are being blocked by the browser. What is the likely cause?

    • AThe server is not sending CSRF tokens
    • BThe server is not sending the correct CORS headers
    • CJWT tokens are not being used
    • DThe server is using session cookies
  4. 4.Which of the following scenarios requires CSRF protection to remain enabled?

    • AA traditional web app using session cookies
    • BA stateless REST API using JWT
    • CAn API that only uses GET requests
    • DA web app using localStorage for tokens
  5. 5.A developer uses @CrossOrigin on every controller in their Spring application. What is a better practice?

    • ADisable CORS entirely
    • BEnable CSRF protection instead
    • CUse '*' for allowed origins
    • DConfigure CORS globally via CorsConfigurationSource
  6. 6.What does CSRF protection do in a stateful application?

    • AGenerates a secret token stored in session and requires it in requests
    • BEncrypts session cookies
    • CBlocks all cross-origin requests
    • DUses JWT tokens to prevent forgery
  7. 7.A developer is setting up a CORS configuration for their API. Which of the following is NOT a recommended practice?

    • AUsing '*' for allowed origins in production
    • BSetting allowed headers explicitly
    • CConfiguring allowed methods explicitly
    • DExposing necessary headers only
  8. 8.What is a key difference between CORS and CSRF?

    • ACORS is a browser mechanism; CSRF exploits cookies
    • BCORS uses JWT; CSRF uses session tokens
    • CCORS is server-side only; CSRF is client-side only
    • DCORS prevents cookie theft; CSRF allows cross-origin requests