What's the point of CORS if a backend can bypass it?

November 14, 2026 4 answers
Asked by a6~foldgate_251

If a browser blocks a cross-origin request, couldn't a site send it through its own backend instead? What does CORS actually protect, and can another site still make requests that create users or change data?

Answers

Mindle.8q

The main distinction is whose credentials the request carries. A script on a malicious site might try to read an account response from a service where the visitor is already signed in. The browser's same-origin policy normally stops that script from reading the response unless the service permits it through CORS.

A backend can make its own request to that service, but it doesn't automatically get the visitor's cookies for the service. So it generally sees whatever an unauthenticated client can see, not the visitor's private account data.

Tremby.7:

A proxy could still access private data if it somehow had valid credentials. CORS isn't a substitute for keeping those credentials secure.

Reply to this answer
m361+addrstep_9

CORS is better thought of as a controlled exception to the same-origin policy, not a blanket ban on requests to other domains. A server can send CORS headers to tell browsers which origins are allowed to read a response.

Depending on the request, the browser may send it but withhold the response from the script, or it may first send a preflight request and decline to send the actual request if permission isn't granted. That's why seeing a CORS error doesn't always mean the server received nothing.

Reply to this answer
q614+foldgate_9

Yes, another client can try to call your backend. CORS doesn't authenticate users or stop direct server-to-server calls, so your backend still needs to check who can perform each action and validate the input.

Also, blocking a script from reading a response isn't necessarily enough to stop a state-changing request. For cookie-based sessions, use appropriate CSRF defenses, such as CSRF tokens and SameSite cookie settings, rather than relying on CORS alone.

Reply to this answer
u28~porthold_416

CORS isn't an XSS fix either. If an attacker gets script running on a vulnerable site, that script can access data available to that site's own code. Blocking cross-origin response access doesn't necessarily stop it from sending data out.

A Content Security Policy can help restrict where scripts connect, but preventing and fixing the injection itself still matters.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions