All jobs / Backend developer / Security
Backend developer interview question · 1–3 years
The interviewer asks: “We set CORS to our frontend origin. Are we safe?” Strongest answer?
The strongest answer
CORS is a browser rule about who can read a response. It is not authentication or authorization. curl, mobile apps and servers ignore it. I still auth every request.
Why it works
Exactly. A missing CORS header stops a browser page, not an attacker. Authz is still the API's job.
What a good answer covers
- CORS ≠ authn/authz.
- Browsers care; curl does not.
- Still authenticate every call.
- Never * with cookies.
Answers that fall short
- Close, but not the strongest: Yes — other origins can't call us, so we're safe.
Non-browser clients don't play CORS. Origin allowlists are not a capability model. - Weak: Disable CORS entirely so nothing is blocked.
Disabling CORS (or reflecting any Origin) is how you let a hostile page read the user's data with their cookies. - Red flag: Access-Control-Allow-Origin: * with credentials so partners can integrate faster.
* plus credentials is forbidden by spec for a reason — and if you fake it, you've opened credentialed cross-site reads.
Who gets asked this
More Security questions
- The interviewer asks: “How do services get secrets in production?” Strongest answer?
- The interviewer asks: “What must never land in logs or traces?” Strongest answer?
- The interviewer asks: “A user asks us to delete their data. What does a backend actually do?” Strongest…
- The interviewer asks: “Threat-model this order service. Where do you start?” Strongest answer?
- The interviewer asks: “A customer requires their data stay in the EU. What do you actually implement?”…
- The interviewer asks: “The API pod's cloud role can read all buckets and impersonate other roles. What's…
- The interviewer asks: “Privacy by design — what does the backend actually ship?” Strongest answer?
- The interviewer asks: “A popular npm/NuGet/Maven package you use was compromised. What should already have…