Outpost24 AB

11/24/2026 | Press release | Distributed by Public on 11/24/2026 05:31

The SameSite and CORS Trap

The SameSite and CORS Trap

Application Security Last updated: 24 Nov 2026
Written By
Jimmy Bergqvist Application Security Expert, Outpost24

How SameSite affects CORS has never been more misunderstood. But with so many exceptions and overlaps, it's no surprise that everything's a mess.

CORS assessments are typically handed off to automated scanners that flag suspicious configurations without considering the browser and application context that determines exploitability. This leaves security teams spending hours on false positives, while truly vulnerable configurations get lost among similar informational findings.

Understanding how SameSite and CORS actually play out in context lets you separate real risks from what only looks problematic.

What is CORS?

CORS (cross-origin resource sharing) is a feature defined by a set of HTTP headers that tell browsers whether a script running on one site can read a response from another. By default, the same-origin policy blocks this, allowing a site to read data only from its own origin. Without this restriction, sites could freely access each other's data, leaving the web highly insecure.

Two sites are of the same origin only when their scheme, host, and port all match:

Scheme Must be exact - http ≠ https
Host Must be exact, i.e., the domain name and its subdomains - outpost24.com ≠ www.outpost24.com
Port Must be exact, i.e., either the explicit port [:80, :443, …] or the default for the scheme - https://outpost24.com (port 443) ≠ https://outpost24.com:8443

CORS in Practice

Consider the example scenario below:

Site A (https://outpost24.com) has an API endpoint on "/profile/data" that returns the currently authenticated user's account information.

Site B (https://specopssoft.com) wants to read that data with JavaScript and display it.

Normally, when Site B would try this, for example, via the below fetch:

fetch('https://outpost24.com/profile/data', {
  credentials: 'include'
})
  .then(res => res.text())
  .then(body => {
    console.log(body);
  });
fetch('https://outpost24.com/profile/data', { credentials: 'include' })  .then(res => res.text())  .then(body => { console.log(body);  });

The request would be sent, but the browser wouldn't let the response be read (the same-origin policy block) unless site A explicitly allows it, which is where CORS comes in.

CORS does this by having the browser automatically add an Origin header whose value reflects the requesting site (e.g., Origin: https://specopssoft.com).

In response, the endpoint on site A must send back an Access-Control-Allow-Origin header that matches that origin.

This signals to the browser that the response can be read, lifting the same-origin policy restrictions.

As the endpoint in this example requires authentication, the outgoing request must carry valid credentials, such as cookies or certain HTTP authentication headers. For those credentialed requests to succeed, the response must also include the Access-Control-Allow-Credentials: true header.

That is CORS in a nutshell.

The rest of the article builds on this foundation by covering the exceptions, edge cases, and SameSite interactions that make real-world behavior less straightforward.

CORS Exceptions and SameSite Overlaps

The simplest way to fully understand CORS is to focus on the exact conditions an attacker must meet to turn a misconfigured or overly permissive implementation into a vulnerability they can do something with. If there are no conditions, there is no exploit.

For the following scenarios, imagine that https://outpost24.com is the target site.

Static Access-Control-Allow-Origin

The target site returns a static, whitelisted site in its Access-Control-Allow-Origin response header (e.g., https://specopssoft.com) and credentials are allowed (Access-Control-Allow-Credentials: true).

If the whitelisted site's JavaScript can't be tampered with by the attacker, the CORS implementation is correct with trust being explicitly granted to it.

Any request coming from an attacker-controlled site will carry an Origin header value that doesn't match the whitelisted site, so the browser will block it from accessing its data.

Straightforward and effective, this configuration leaves an attacker at a dead end.

Dynamic Access-Control-Allow-Origin of Any Subdomain

The target site reflects the requesting Origin header value in its Access-Control-Allow-Origin header, but only when that origin is a subdomain of the site itself (e.g., https://anything.outpost24.com). Credentialed requests are also allowed, as Access-Control-Allow-Credentials is set to true.

At first, this may seem intentional and similar to a static reflection since an attacker would still need to control the JavaScript on one of these subdomains. But the attack surface is much larger. Not only does the attacker have more subdomains to target for potential JavaScript control, but this configuration also sidesteps a common indirect control that prevents credentials from being sent cross-site: SameSite.

How SameSite Works

SameSite is a cookie attribute that primarily helps prevent cross-site request forgery (CSRF) by controlling when browsers attach cookies to cross-site requests.

Even if an attacker-controlled page is allowed by the target site's Access-Control-Allow-Origin header and credentials are allowed, the browser will omit the session cookie(s) from the request if they would be set as SameSite, causing authentication to fail instead.

Which specific SameSite value is used (Strict, Lax, or None) decides the exact behavior. We'll go through them further in the upcoming examples, but the point is that cookies are still sent from subdomains, since those aren't considered cross-site.

Dynamic Access-Control-Allow-Origin of Any Domain

The target site fully reflects the requesting Origin header value in its Access-Control-Allow-Origin header with credentials being allowed.

Unlike earlier cases, this configuration is drastically over-permissive. Any attacker-controlled domain will be reflected and given credentialed read access to the response. Even so, exploitation may still be limited by several indirect safeguards, most notably the SameSite cookie attribute.

Before examining those protections more in-depth, however, it is important to distinguish between wildcard and null origins.

Wildcards and null Origins

Both values are frequently encountered in CORS configurations. The wildcard (*) is often used by developers seeking broad cross-origin access, while null is sometimes explicitly allowed to support requests from local files, sandboxed documents, or other contexts without a conventional origin, leading it to be mistakenly perceived as a safe or restricted origin.

A common misconfiguration is the use of Access-Control-Allow-Origin: * together with Access-Control-Allow-Credentials: true. While this may appear equivalent to allowing any origin credentialed read access, browsers explicitly reject this combination for safety reasons and prevent access to the response. Any finding identifying this as an issue is a false positive with respect to credentialed data exposure.

Used on its own, without Access-Control-Allow-Credentials: true, the wildcard is permitted, and any site can then read the response to a request sent without credentials. For a public endpoint, that exposes nothing an attacker couldn't already fetch directly from their own machine. The exception is an application that relies on network position instead of credentials, such as an internal tool on a private network. An attacker cannot reach those directly, but a victim's browser inside the network can, and with the wildcard in place, any site the victim visits can read what comes back.

Access-Control-Allow-Origin: null is different. The value intuitively sounds like "nothing" rather than "everything". However, any attacker-controlled page can send requests with a null origin, for example from a sandboxed iframe.

Trusting null together with Access-Control-Allow-Credentials: true is therefore functionally equivalent to granting arbitrary origins credentialed read access to responses. And for this combination, there is no automatic browser-enforced rejection.

The SameSite Limitation

For a credentialed CORS misconfiguration to be exploitable, two separate browser decisions must go the attacker's way. First, the request must carry credentials that authenticate the victim. Second, the attacking origin must be allowed to read the response. A permissive CORS policy with an Access-Control-Allow-Origin value that matches the attacker's origin together with Access-Control-Allow-Credentials: true, can satisfy the second condition, but it has no say over the first. Whether cookies are attached is decided by the browser cookie rules before the server's CORS headers ever arrive.

When session cookies are set to SameSite=Strict or SameSite=Lax, a cross-site fetch() or XHR request from an attacker's site carries none of them. Strict is the tighter of the two. It sends cookies only in same-site contexts, meaning the request must come from the same registrable domain (subdomains included), so the cookies never ride along on a request from an unrelated site.

Lax is more permissive, but it still withholds cookies from the requests an attacker needs. As with Strict, a background fetch() or XHR launched from their page to read a response carries none of them. The difference is that Lax does allow cookies on certain top-level cross-site navigations that use a safe method such as GET, but those navigations cannot disclose a response anyway. A top-level navigation replaces the attacker's page and loads the target site directly, so the response renders inside the target's own origin, and the attacker's JavaScript cannot reach it.

This limitation is what prevents the otherwise weak CORS configuration from automatically becoming an exploitable vulnerability. The browser may allow the attacker-controlled origin to read a response under CORS, but if the request is unauthenticated because the session cookies were withheld, there is no protected data to expose.

The exceptions are when the request still counts as same-site, for example because the attacker can run JavaScript on a subdomain, or the session cookies are deliberately set to SameSite=None. In those cases, the cookies may be sent, and the permissive CORS policy can become exploitable.

There is also a lesser-known Chrome behavior that is easy to mistake for a third exception. When a site sets a cookie without any SameSite attribute, Chrome treats it as Lax by default, but with a short grace period. For the first two minutes after the cookie is set, Chrome also sends it on top-level cross-site POST requests, something regular Lax cookies never allow. This behavior, known as Lax+POST, was added as a temporary measure to keep older single sign-on flows working.

Since this section has focused on when cookies are sent, Lax+POST can look like another exception. It isn't. It only lets cookies ride along on top-level POST navigations, and the response to those loads only in the target's own origin. That makes it a CSRF concern, not a CORS one.

The Non-Cookie Authentication Limitation

SameSite only controls when browsers attach cookies. It does not affect other credentials, so non-cookie authentication must be assessed separately. For CORS to be exploitable in this case, the request must include a valid credential, and the attacker must be able to trigger that request from a page they control.

Exploitability depends on how the credential reaches the request. Some credentials are attached by the browser as part of an existing authentication state. Others must be added by JavaScript before the request is sent.

Apart from cookies, browser-supplied credentials include client certificates and HTTP authentication schemes such as Basic, Digest, NTLM, and Negotiate. The browser can attach them without exposing their value to the attacking script.

Bearer tokens are different and rely on JavaScript to include them in the request. An attacker-controlled site normally cannot read a token stored under the target site's origin, whether it's in local storage or another same-origin location. And without the token, the script cannot make an authenticated bearer-token request.

Preflight Requests

Calls to bearer-token APIs usually begin with a preflight, a quick check the browser sends before the real request.

Not every cross-origin request needs one. Simple requests, such as a basic GET or a POST with a safelisted content type and only safelisted headers, are sent immediately.

Everything else needs the server's approval first. If a request uses a method such as PUT or DELETE, sets a JSON content type, or includes a non-safelisted header like a script-set Authorization header, the browser first sends an OPTIONS preflight.

The preflight asks whether the real request may use the requested method and headers, sending them in the real request only if the server approves them. For the script-set Authorization header to pass through the CORS preflight check, the response must explicitly include it in the Access-Control-Allow-Headers header.

This allowance is irrelevant to an attacker and part of a correct implementation, as it doesn't help one who lacks the token. If they already have the token, they can just send the authenticated request directly.

The Unpredictable Value Limitation

With everything aligned and the victim's credentials riding along, exploitation can still fail if the application requires an unpredictable value that the attacker cannot produce.

Common examples include a CSRF token or a nonce. In that case, the request may be authenticated, but the missing value tells the server that it did not originate from the intended application flow.

This protection holds as long as the value stays out of the attacker's reach, typically because it exists only inside the target site's own pages or responses. If the same permissive CORS policy also covers the page or endpoint that issues the value, the attacker can read it there first and include it in the forged request. Such values tend to guard state-changing actions rather than data, so an endpoint that returns sensitive information on a plain GET is usually not protected by them at all.

A required custom header can block exploitation in a similar way, even when its value is predictable. Adding the header makes the request non-simple and triggers a preflight, and unless the server explicitly allows the header in its preflight response, the browser never sends the real request. Many permissive CORS configurations, however, reflect whatever headers the preflight asks for, which removes this barrier entirely.

How Outpost24 Can Help

Scanners flag a permissive CORS header and move on. Many of those findings turn out to be harmless, and the real ones get lost among them as just another informational line in the report.

In our PTaaS engagements, we look past the header. We test how your origin validation actually behaves, which credentials reach cross-origin requests, how SameSite and preflight handling hold up, and whether anti-forgery tokens and required headers truly stay out of an attacker's reach.

If you're interested in seeing how Outpost24 can help your organization cut through the noise and remediate the issues that pose a threat, book a demo today.

About the Author

Jimmy Bergqvist Application Security Expert, Outpost24

Jimmy is an Application Security Expert at Outpost24 with over 10 years of experience identifying vulnerabilities, evaluating risk, and guiding remediation efforts.

Outpost24 AB published this content on November 24, 2026, and is solely responsible for the information contained herein. Distributed via Public Technologies (PUBT), unedited and unaltered, on November 24, 2026 at 11:31 UTC. If you believe the information included in the content is inaccurate or outdated and requires editing or removal, please contact us at [email protected]