Why do CORS and a hidden API key not secure a backend?
Understand the idea, explain it in your own words and use the rubric to find your next learning gap.
The idea behind the question
CORS controls what browser scripts may read across origins; it is not general authentication. Anything shipped to a browser can be inspected by its user.
A frontend bundle includes a provider key, and an attacker calls the provider directly without using your UI.
A practical way to learn it
Threat-model a public contact form and a signed-in project-save endpoint separately.
Open online notepadThe related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.
Build an explanation you understand
- State what the concept does in plain language.
- Apply it to the example and make your assumptions explicit.
- Explain a trade-off, failure case and how you would test it.
- Distinguish your actual experience from a proposed approach.
How would you explain it?
Single-question timers reset on refresh. Full mock sessions can resume from this browser.
Strengthen your explanation
Compare reasoning, not identical wording. Reference answers describe a possible approach; replace hypothetical statements with truthful details from your own work.
One way to answer
I would keep privileged keys on a trusted server and authenticate and authorize each protected operation. I would treat all incoming data as untrusted, validate it and apply suitable abuse controls. CORS can restrict browser-origin access but does not stop arbitrary HTTP clients. Cookie-based authentication also requires a deliberate CSRF strategy and secure cookie settings. I would avoid unsafe HTML rendering and review data exposure through responses and logs. The UI should reflect permissions, but the backend must enforce them independently.
What a strong explanation should cover
Tick only the points your own answer addresses. This is self-assessment, not AI scoring.
0 / 3 points self-reportedWatch out for
- Treating an allowed-origin check as user identity.
Now go one level deeper
- How would you protect a cookie-authenticated mutation?
- What data could a verbose error leak?
Further reading
Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.