Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

Can Any Website Read Your API Responses With Your Users’ Cookies?

Another site can read a cookie-authenticated API response only when the browser sends credentials and the API permits that origin to read it. Here’s how to identify unsafe CORS policies and fix them.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Only under specific conditions. A site’s JavaScript can read a cookie-authenticated API response from another origin only if the browser sends the credentials and the API’s CORS policy allows that requesting origin to read the response. The risky setup is not simply “wildcard CORS”: browsers reject Access-Control-Allow-Origin: * for credentialed response sharing. The danger is an origin policy that trusts too much—such as reflecting arbitrary Origin values—while allowing credentials.

How a cross-origin API request can expose a response

Browsers apply the same-origin policy to script-initiated requests. Cross-origin Fetch and XMLHttpRequest requests use CORS, which lets an API specify which requesting origins may read a response. The Access-Control-Allow-Origin response header carries that decision. MDN’s CORS guide explains the browser’s response-sharing rules.

As an Amazon Associate I earn from qualifying purchases.

A simple cross-origin request may reach the API before the browser decides whether the calling JavaScript can read the response. For a request that is not simple—for example, one using certain methods or headers—the browser first sends an OPTIONS preflight. It sends the actual request only if the preflight response permits it. A failed CORS check generally prevents JavaScript from reading the response; it does not necessarily mean the request was never sent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The cookie must actually accompany the request

Fetch uses credentials: "same-origin" by default. Cross-origin code must normally request credentials explicitly with credentials: "include" for cookies to accompany the request. Even then, browser cookie rules still apply: cookies marked SameSite=Strict or SameSite=Lax are not sent cross-site, and third-party-cookie restrictions may block them. MDN’s Fetch credentials documentation describes these conditions.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

The API must permit that origin to read the response

For credentialed CORS, the response must name a specific allowed origin in Access-Control-Allow-Origin and include Access-Control-Allow-Credentials: true. The wildcard value * is not valid for credentialed response sharing. So a wildcard alone does not let arbitrary sites read a user’s credentialed API response.

A more serious flaw is an unsafe origin decision: for example, accepting attacker-controlled origins or returning the request’s Origin value without checking it, while also permitting credentials. MDN warns against reflecting Origin blindly. Its CORS guidance notes: “Failure to set Access-Control-Allow-Origin appropriately will allow unauthorized origins to read the contents of any page on your site.” The same guide recommends limiting credentialed access to explicitly allowed origins.

Rank #2
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

Choose the CORS policy that matches the API

API use Origin policy Credentials Key consideration
Public data intended to be readable by any website Access-Control-Allow-Origin: * may be appropriate Do not permit credentials Use this only when the resource is genuinely public and does not need user-specific credentials.
Private or user-specific API used by selected browser clients Allow only deliberately selected origins; return the matching approved origin Set Access-Control-Allow-Credentials: true only where needed Keep the allowlist narrow and maintain it as client origins change.
No cross-origin browser access is required Do not send CORS permission headers Not applicable Apply the policy only to the API resources that need it, rather than enabling it site-wide.

When the server chooses a response origin dynamically from an allowlist, include Vary: Origin. This tells caches that the response can differ according to the incoming origin. MDN’s CORS configuration guidance covers this cache behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to check whether your API is exposed

  1. Inspect actual API responses. For representative allowed, disallowed, and absent Origin values, check Access-Control-Allow-Origin and Access-Control-Allow-Credentials. Confirm that the server returns an origin only after matching it against the intended allowlist.
  2. Check the origin-selection logic. Look for code or configuration that copies the incoming Origin header into the response without validating it. Also confirm that credential permission is not added to resources or origins that do not need it.
  3. Review preflight handling. For methods and headers that trigger preflight, inspect the OPTIONS response and verify that it permits only the necessary origins, methods, and headers. Also check the normal response to the actual request.
  4. Test authorization separately. Confirm that the API checks whether the requesting user may access each resource. CORS governs browser access to responses; it is not an authorization system and does not stop non-browser clients from making requests.
  5. Review CSRF defenses. If the application uses cookies for authentication, keep appropriate server-side protections against cross-site request forgery. A CORS policy does not replace them.

The OWASP Web Security Testing Guide v4 archive discusses checking CORS behavior and cautions that Origin can be spoofed outside a browser. Treat its testing guidance as historical and verify implementation details against current platform documentation.

Rank #3
Yubico - YubiKey 5C NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What CORS does not protect

Browsers enforce CORS for browser JavaScript, but a server cannot rely on it to authenticate callers. Non-browser clients can send requests without obeying browser response-sharing rules, and an Origin header is not a trustworthy identity credential by itself. Keep application-level authorization on the server and validate access to each protected operation or record. For cookie-authenticated actions, retain CSRF protections as well.

The practical rule is narrow: allow only the browser origins that need access, use credential permission only where necessary, and enforce access independently of CORS.

Rank #4
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.