Skip to content

Interview question · Application & API Security

Explain the same-origin policy, CORS and CSRF. Does using JWTs prevent CSRF?

Three browser rules that candidates mix up constantly. The JWT follow-up exposes whether you know which one depends on cookies.

mediumEssentialNewPreparation tags: Google, Meta, MicrosoftUpdated Nov 2026

Three browser rules that candidates mix up constantly. The JWT follow-up exposes whether you know which one depends on cookies.

Make your first attempt

What would you say before reading the answer?

  1. 01 State the assumptions your answer depends on.
  2. 02 Explain the mechanism and choose a control.
  3. 03 Name a condition that would change your decision.

The worked answer includes an approach, scoring criteria and follow-up questions. Compare the reasoning with your own.

signing in unlocks more free answers per topic

What if · the follow-ups in this answer

The answer works through 6 follow-ups like an interviewer would

A banking site uses a session cookie, and a malicious page the user visits contains a form that posts to the bank's transfer endpoint.

  1. What does the same-origin policy stop, and what does it not?
  2. What is CSRF here?
  3. How do you defend against it?
  4. What is CORS, and is it a CSRF defence?
  5. Do JWTs prevent CSRF?
  6. How would you protect the transfer endpoint?

Each rung has a nudge, a model answer, the principle that carries over and the weak answer to avoid. Sign in free to open it.

UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.