← Blog

Claude MCP skill CORS misconfiguration — credentialed cross-origin reads and cache poisoning — SA-SKL-CORS18

CORS (Cross-Origin Resource Sharing) is the browser's last line of defence against cross-site data theft. When a skill registry API echoes the request's Origin header back as Access-Control-Allow-Origin without validating it against an allowlist, any attacker page can read private audit results with the victim's credentials attached. SA-SKL-CORS18 covers four patterns: unrestricted origin reflection with credentials, preflight cache poisoning via shared proxy, CDN misconfiguration on private packages, and the null-origin bypass from sandboxed iframes.

By SkillAudit  |  12 Nov 2026
SA-SKL-CORS18 findings at a glance
CRITICALCORS18-001 — Access-Control-Allow-Origin set to req.headers.origin with no allowlist validation; combined with Access-Control-Allow-Credentials: true; attacker page at evil.com sends XHR to /api/skills/mine with victim session cookies; full cross-origin read of private audit results, skill source code, and billing information
HIGHCORS18-002 — OPTIONS preflight response cached by a shared proxy without Vary: Origin; attacker requests preflight with a permissive-looking origin; cached CORS approval served to real users whose origin differs; subsequent credentialed requests from non-allowlisted origins succeed against cached CORS approval
MEDIUMCORS18-003 — CDN-served skill package files at static.skillaudit.dev with ACAO: * inherited from API CORS config; wildcard is acceptable for truly public read-only resources but must be set explicitly with intent rather than inherited, as future changes to the API config could remove it and break CDN behaviour or inadvertently apply credentials to static assets
CRITICALCORS18-004 — Origin: null bypass from a sandboxed <iframe>; attacker page embeds an iframe with the sandbox attribute (without allow-same-origin) which causes the browser to send Origin: null; server checks if (allowedOrigins.includes(origin)) where origin === 'null' (string) may match a misconfigured null entry; credentialed requests succeed from attacker-controlled sandboxed context

CORS18-001 — Origin reflection with Access-Control-Allow-Credentials: true

The most dangerous CORS misconfiguration: a server that echoes any request's Origin header back as Access-Control-Allow-Origin while also responding with Access-Control-Allow-Credentials: true. The browser spec forbids the combination of ACAO: * with credentials, but nothing stops a server from reflecting the specific origin — which the browser treats as an explicit allowlist approval. An attacker page at evil.com sends a credentialed XHR to the registry API and receives the authenticated user's private data because the server dutifully reflected evil.com back as the allowed origin.

// VULNERABLE — CORS18-001
// Origin header reflected directly without validation.
// Any attacker page can send: fetch("https://skillaudit.dev/api/skills/mine", {
//   credentials: "include"
// }) and read the full response body.

app.use((req, res, next) => {
  const origin = req.headers.origin;
  // VULNERABLE: blindly echo back whatever origin the client sends
  res.setHeader('Access-Control-Allow-Origin', origin);
  res.setHeader('Access-Control-Allow-Credentials', 'true');
  res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
  if (req.method === 'OPTIONS') return res.sendStatus(204);
  next();
});
// FIXED — CORS18-001
// Fix: Validate the incoming origin against a strict allowlist before reflecting.
// Never combine ACAO:* with Allow-Credentials — browsers block it, but reflected origins are equivalent.

const ALLOWED_ORIGINS = new Set([
  'https://skillaudit.dev',
  'https://app.skillaudit.dev',
]);

app.use((req, res, next) => {
  const origin = req.headers.origin;

  // FIX: Only reflect origins in the allowlist
  if (origin && ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Access-Control-Allow-Credentials', 'true');
    // FIX: Vary header required whenever ACAO is conditional on request Origin
    res.setHeader('Vary', 'Origin');
  }
  // If origin not in allowlist: no ACAO header — browser blocks the response

  if (req.method === 'OPTIONS') {
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
    res.setHeader('Access-Control-Max-Age', '600');
    return res.sendStatus(204);
  }
  next();
});

Why ACAO: * and credentials is different from reflected origin: Browsers explicitly block fetch(url, {credentials: 'include'}) when the server responds with ACAO: * — this is the spec. But reflecting ACAO: evil.com is functionally identical and the browser permits it. The spec prohibition on wildcard+credentials exists precisely because wildcards can't have credentials — but reflected specific origins can. An allowlist is the only correct fix.

CORS18-002 — CORS preflight cache poisoning via shared proxy

CORS preflight responses can be cached by intermediate proxies (Nginx, CDN, shared corporate proxies). When the CORS middleware correctly validates the Origin header but forgets to include Vary: Origin in the preflight response, the proxy caches the preflight against only the URL path as the cache key. An attacker on a shared network sends the first OPTIONS request from a permissive-looking origin; the proxy caches the response. Subsequent users whose browsers trigger a preflight for the same path receive the cached response which may have already-approved CORS headers, bypassing the allowlist check for the cached duration.

// VULNERABLE — CORS18-002
// CORS preflight cached without Vary: Origin.
// Shared proxy caches the OPTIONS response for 600s.
// First request from attacker origin poisons the cache for all subsequent origins.

app.options('/api/skills/mine', (req, res) => {
  const origin = req.headers.origin;
  if (ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Access-Control-Allow-Credentials', 'true');
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
    // VULNERABLE: Access-Control-Max-Age set without Vary: Origin
    // Proxy caches this preflight response keyed on URL only, not Origin
    res.setHeader('Access-Control-Max-Age', '600');
  }
  res.sendStatus(204);
});
// FIXED — CORS18-002
// Fix: Always include Vary: Origin on CORS responses so proxies key the cache on Origin.
// This prevents one origin's preflight approval from being served to a different origin.

app.options('/api/skills/mine', (req, res) => {
  const origin = req.headers.origin;

  // FIX: Always set Vary: Origin so proxy does not collapse multiple origins into one cache entry
  res.setHeader('Vary', 'Origin');

  if (origin && ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Access-Control-Allow-Credentials', 'true');
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
    res.setHeader('Access-Control-Max-Age', '600');
  }
  // If origin not allowlisted: no ACAO sent; Vary: Origin still set so each origin gets its own cache entry
  res.sendStatus(204);
});

Vary: Origin is cheap insurance: Setting Vary: Origin on all CORS responses has near-zero performance cost (CDNs partition their cache on the extra key) and prevents an entire class of cache-poisoning attack. It also signals to all caching layers — Nginx, Varnish, CloudFlare, shared corporate proxies — that the CORS approval is origin-specific and must not be shared across requestors.

CORS18-003 — CDN ACAO:* inherited from API config on private package files

Many MCP skill registries serve skill package files from a CDN subdomain (static.skillaudit.dev). If the CDN origin-pull is configured to pass through the upstream's CORS headers, and the upstream API emits Access-Control-Allow-Origin: * for all unauthenticated routes, the CDN will cache and serve ACAO: * for all static assets. This is usually fine for truly public files, but it can inadvertently apply to private or gated package files if the upstream does not distinguish between public and private assets in its CORS response logic.

// VULNERABLE — CORS18-003
// API CORS middleware sets ACAO:* for all requests that have no session.
// Private package files (private=true) are still served with ACAO:* because
// the CORS middleware runs before the auth check.

app.use((req, res, next) => {
  if (!req.headers.authorization) {
    // VULNERABLE: assumes no-auth routes are all public, but private package
    // downloads use signed URLs that don't set Authorization header
    res.setHeader('Access-Control-Allow-Origin', '*');
  }
  next();
});

// Private package download — auth via signed URL query param, not header
app.get('/packages/:skillId/:version.tgz', verifySignedUrl, (req, res) => {
  // ACAO:* already set by middleware above — private package readable cross-origin
  streamPackage(req.params.skillId, req.params.version, res);
});
// FIXED — CORS18-003
// Fix: Set ACAO explicitly and intentionally on a per-route basis.
// Public routes: ACAO:* is acceptable and must be explicit.
// Private/gated routes: no ACAO header, or origin-validated ACAO.
// Never inherit ACAO from a blanket middleware for routes that handle private content.

// Public static assets: explicit ACAO:*
app.use('/public/', (req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', '*');
  next();
});

// Private package downloads: no blanket CORS — only allowed from app origin
app.get('/packages/:skillId/:version.tgz', verifySignedUrl, (req, res) => {
  const origin = req.headers.origin;
  // FIX: private packages get allowlist-validated ACAO, not wildcard
  if (origin && ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Vary', 'Origin');
  }
  streamPackage(req.params.skillId, req.params.version, res);
});

CORS18-004 — Origin: null bypass from sandboxed <iframe>

When a browser loads a page inside an <iframe sandbox> without the allow-same-origin flag, it treats the page as a unique origin and sends Origin: null in cross-origin requests. The string "null" (four ASCII characters) is a valid Origin header value. Some CORS implementations accidentally allowlist null: they parse a JSON array of allowed origins, and if null (JSON null) was accidentally serialised into the array, it becomes the string "null". An attacker embeds the registry site in a sandboxed iframe on their own page and makes credentialed XHR requests that the server treats as null-origin approved.

// VULNERABLE — CORS18-004
// allowedOrigins loaded from config file. JSON null in config serializes to "null" string.
// Attacker iframes skillaudit.dev with sandbox (no allow-same-origin):
//   <iframe sandbox="allow-scripts allow-forms" src="https://skillaudit.dev/app">
// Requests from this iframe send Origin: null
// Server's allowedOrigins includes the string "null" from misconfigured JSON

// config.json (misconfigured):
// { "allowedOrigins": ["https://skillaudit.dev", null, "https://app.skillaudit.dev"] }
// JSON.parse → ["https://skillaudit.dev", null, "https://app.skillaudit.dev"]
// array.includes("null") → false (JSON null !== "null") BUT:

// Another common variant: origins loaded as comma-separated string
// CORS_ORIGINS="https://skillaudit.dev,null,https://app.skillaudit.dev"
// split(',') → ["https://skillaudit.dev", "null", "https://app.skillaudit.dev"]
// VULNERABLE: "null" string is in the allowlist

const rawOrigins = process.env.CORS_ORIGINS.split(',');
// rawOrigins = ["https://skillaudit.dev", "null", "https://app.skillaudit.dev"]

app.use((req, res, next) => {
  const origin = req.headers.origin;
  if (rawOrigins.includes(origin)) {
    // VULNERABLE: origin === "null" matches rawOrigins
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Access-Control-Allow-Credentials', 'true');
  }
  next();
});
// FIXED — CORS18-004
// Fix 1: Explicitly filter the string "null" from any origin allowlist.
// Fix 2: Validate that all allowed origins start with https:// (strict prefix check).
// Fix 3: Never allowlist the string "null" as an Origin value.

const rawOrigins = (process.env.CORS_ORIGINS || '').split(',')
  .map(o => o.trim())
  // FIX 1: Reject the string "null" explicitly
  .filter(o => o !== 'null' && o !== '')
  // FIX 2: Only accept https:// origins — no http, no null, no data:
  .filter(o => o.startsWith('https://'));

const ALLOWED_ORIGINS = new Set(rawOrigins);

app.use((req, res, next) => {
  const origin = req.headers.origin;

  // FIX 3: Never allow the string "null" as a CORS origin
  if (origin && origin !== 'null' && ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Access-Control-Allow-Credentials', 'true');
    res.setHeader('Vary', 'Origin');
  }
  if (req.method === 'OPTIONS') return res.sendStatus(204);
  next();
});

How attacker uses null origin: <iframe sandbox="allow-scripts allow-forms" src="https://evil.com/attack.html"> — the attack HTML inside the iframe calls fetch("https://skillaudit.dev/api/skills/mine", {credentials: "include"}). Because the iframe has no allow-same-origin, the browser sends Origin: null. If the server's CORS middleware allowlists "null", the response is returned to the attacker iframe. The null-origin constraint is a browser security guarantee that is entirely undone by server-side allowlisting of the string "null".

Summary — SA-SKL-CORS18 at a glance

PatternRoot causeFixSeverity
CORS18-001Origin reflection + Allow-Credentials: true without allowlistStrict allowlist; only reflect allowlisted originsCRITICAL
CORS18-002Preflight response cached without Vary: OriginAlways set Vary: Origin on all CORS responsesHIGH
CORS18-003ACAO:* inherited by private routes from blanket middlewareSet ACAO explicitly per-route with intentMEDIUM
CORS18-004String "null" in origin allowlist from JSON/env misconfigurationFilter "null" string; validate https:// prefixCRITICAL

SkillAudit's CORS scanner checks all four patterns on every MCP skill registry endpoint: it replays requests with reflected origins, null origins, and OPTIONS preflights, then analyses the CORS response headers for allowlist bypasses, missing Vary headers, and null-origin acceptance. See also SA-SKL-CORS17 (GraphQL and WebSocket CORS) and SA-SKL-CORS16 (regex wildcard edge cases).