← Blog

Claude MCP skill CORS misconfiguration — wildcard, reflect-origin, null origin, regex bypass — SA-SKL-CORS15

Cross-Origin Resource Sharing misconfigurations in MCP skill API endpoints allow attacker-controlled pages to read private user data, bypass authentication checks, or exfiltrate session cookies using legitimate browser fetch calls. Four SA-SKL-CORS15 patterns cover the most common mistakes: wildcard origin on authenticated endpoints, unconditional reflect-origin with null origin bypass, wildcard combined with credentials headers, and CORS origin allowlist regex that is unanchored at the start and matches attacker-controlled subdomains.

By SkillAudit  |  9 Nov 2026
SA-SKL-CORS15 findings at a glance
CRITICALCORS15-001 — Access-Control-Allow-Origin: * on /api/audits endpoint that returns private audit data; attacker's cross-origin page reads full audit report without any authentication token using browser fetch()
HIGHCORS15-002 — reflect-origin pattern: res.set('Access-Control-Allow-Origin', req.headers.origin) set unconditionally; null origin sent from sandboxed iframe bypasses allowlist; fix: check against explicit allowlist before reflecting
MEDIUMCORS15-003 — preflight sets Access-Control-Allow-Credentials: true but Access-Control-Allow-Origin is wildcard; some older browsers and non-standard clients accept wildcard + credentials; fix: never use * when credentials are involved
HIGHCORS15-004 — CORS origin regex /skillaudit\.dev$/ matched by https://attacker.skillaudit.dev.evil.com; regex is not anchored at the start; fix: use /^https:\/\/skillaudit\.dev$/ or exact set comparison

CORS15-001 — Wildcard CORS on private data endpoint

Access-Control-Allow-Origin: * tells browsers that any origin may read the response. This is safe for public, unauthenticated resources like CDN-hosted CSS or public API documentation. It is a critical vulnerability on any endpoint that returns user-specific or authenticated data, because an attacker-controlled page can read the full response body using a simple fetch() call — without needing to steal the user's authentication token or perform any browser exploit. The browser allows the cross-origin read because the server explicitly said all origins are trusted.

// VULNERABLE — CORS15-001 (CRITICAL)
// Access-Control-Allow-Origin: * on an authenticated endpoint.
// Any page on the internet can read this response when a logged-in user visits.
import express from 'express';
import { db } from './db.js';

const router = express.Router();

router.get('/api/audits', authenticate, async (req, res) => {
  // VULNERABLE: wildcard CORS before returning private audit data
  res.set('Access-Control-Allow-Origin', '*');

  const audits = await db.all(
    'SELECT * FROM audits WHERE user_id = ?', [req.user.id]
  );
  res.json(audits);
});
// FIXED — CORS15-001
// Use an explicit allowlist. Only skillaudit.dev and app.skillaudit.dev are allowed.
import express from 'express';
import cors from 'cors';

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

const corsOptions: cors.CorsOptions = {
  origin: (origin, callback) => {
    // Allow requests with no Origin header (server-to-server, curl)
    // but reject any browser origin not in the allowlist
    if (!origin || ALLOWED_ORIGINS.has(origin)) {
      callback(null, true);
    } else {
      callback(new Error('Not allowed by CORS'));
    }
  },
  credentials: true,
};

const router = express.Router();
router.get('/api/audits', cors(corsOptions), authenticate, async (req, res) => {
  const audits = await db.all(
    'SELECT * FROM audits WHERE user_id = ?', [req.user.id]
  );
  res.json(audits);
});

CORS15-002 — reflect-origin with null origin bypass

The reflect-origin pattern — setting Access-Control-Allow-Origin to the value of the Origin request header — is a common attempt to allow multiple specific origins without hardcoding a list. The intent is usually that only trusted origins will send requests. The vulnerability is that the browser sends a special null origin in several situations: sandboxed iframes, data: URI pages, local file:// pages, and certain redirect scenarios. An attacker who creates a sandboxed iframe at https://attacker.com/exploit.html gets a null origin. If the server reflects null back as Access-Control-Allow-Origin: null and also sets Access-Control-Allow-Credentials: true, the browser allows the iframe to read authenticated responses from the victim's session.

// VULNERABLE — CORS15-002 (HIGH)
// Reflect-origin set unconditionally; null origin accepted without check.
app.use((req, res, next) => {
  const origin = req.headers.origin;
  if (origin) {
    // VULNERABLE: reflects any origin including null
    // Sandboxed iframe sends origin: null — this reflects Access-Control-Allow-Origin: null
    res.set('Access-Control-Allow-Origin', origin);
    res.set('Access-Control-Allow-Credentials', 'true');
  }
  next();
});
// FIXED — CORS15-002
// Validate against allowlist before reflecting. Reject null origin.
const ALLOWED_ORIGINS = new Set([
  'https://skillaudit.dev',
  'https://app.skillaudit.dev',
]);

app.use((req, res, next) => {
  const origin = req.headers.origin;
  // Explicitly reject null origin — do NOT reflect it
  if (origin && origin !== 'null' && ALLOWED_ORIGINS.has(origin)) {
    res.set('Access-Control-Allow-Origin', origin);
    res.set('Access-Control-Allow-Credentials', 'true');
    res.set('Vary', 'Origin');  // Required to prevent caching incorrect CORS headers
  }
  next();
});

CORS15-003 — Wildcard CORS with credentials header

Modern browsers (Chrome, Firefox, Safari) correctly reject the combination of Access-Control-Allow-Origin: * and Access-Control-Allow-Credentials: true — the credentials header is ignored when the origin is wildcard, as required by the CORS specification. However, some older browser versions (pre-2020), non-standard browsers, and several HTTP client libraries do not enforce this restriction and will send credentials with a wildcard origin. Additionally, server-to-server callers using tools like undici or custom HTTP clients may not enforce the browser CORS restrictions at all, making the headers purely advisory. The correct rule is simple: never combine Access-Control-Allow-Origin: * with any credential-related header on the same response.

// VULNERABLE — CORS15-003 (MEDIUM)
// Wildcard + credentials: browsers reject this, but older clients may not.
// Also leaks intent confusion — the developer clearly wants credentials but
// also wants to allow all origins, which are mutually exclusive in correct CORS.
app.options('/api/*', (req, res) => {
  res.set('Access-Control-Allow-Origin', '*');           // VULNERABLE
  res.set('Access-Control-Allow-Credentials', 'true');  // contradicts wildcard
  res.set('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
  res.set('Access-Control-Allow-Headers', 'Content-Type,Authorization');
  res.sendStatus(204);
});
// FIXED — CORS15-003
// Never use wildcard when credentials are involved.
// Use an explicit allowlist — always.
const ALLOWED_ORIGINS = new Set(['https://skillaudit.dev', 'https://app.skillaudit.dev']);

app.options('/api/*', (req, res) => {
  const origin = req.headers.origin;
  if (origin && ALLOWED_ORIGINS.has(origin)) {
    res.set('Access-Control-Allow-Origin', origin);         // specific, not wildcard
    res.set('Access-Control-Allow-Credentials', 'true');
    res.set('Vary', 'Origin');
  }
  res.set('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
  res.set('Access-Control-Allow-Headers', 'Content-Type,Authorization');
  res.sendStatus(204);
});

CORS15-004 — CORS origin regex unanchored at start

MCP skill developers sometimes use a regex to validate the origin header when they want to allow multiple subdomains. A regex like /skillaudit\.dev$/ is intended to match only origins ending in skillaudit.dev. It is correct that the dot is escaped. It is incorrect that the regex is not anchored at the start. The regex matches any string ending in skillaudit.dev, including https://attacker.skillaudit.dev.evil.com — which an attacker can register as their own domain. The fix is to anchor the regex at both ends and also explicitly include the protocol: /^https:\/\/skillaudit\.dev$/ or /^https:\/\/[a-z0-9-]+\.skillaudit\.dev$/ for subdomain patterns.

// VULNERABLE — CORS15-004 (HIGH)
// Regex is not anchored at the start. Matches attacker-controlled domains.
function isCORSAllowed(origin: string): boolean {
  // VULNERABLE: /skillaudit\.dev$/ matches:
  //   https://skillaudit.dev              ✓ intended
  //   https://app.skillaudit.dev          ✓ intended
  //   https://attacker.skillaudit.dev.evil.com   ✗ NOT intended — but matched!
  return /skillaudit\.dev$/.test(origin);
}

app.use((req, res, next) => {
  const origin = req.headers.origin ?? '';
  if (isCORSAllowed(origin)) {
    res.set('Access-Control-Allow-Origin', origin);
    res.set('Access-Control-Allow-Credentials', 'true');
  }
  next();
});
// FIXED — CORS15-004
// Anchor regex at both ends. Include protocol. Use exact set for known origins.
// Option A: exact set (preferred when origins are enumerable)
const ALLOWED_ORIGINS = new Set([
  'https://skillaudit.dev',
  'https://app.skillaudit.dev',
  'https://docs.skillaudit.dev',
]);

// Option B: anchored regex for wildcard subdomain pattern
const SUBDOMAIN_PATTERN = /^https:\/\/[a-z0-9-]+\.skillaudit\.dev$/;

function isCORSAllowed(origin: string): boolean {
  // Anchored at start (^) and end ($) — no substring match possible
  return ALLOWED_ORIGINS.has(origin) || SUBDOMAIN_PATTERN.test(origin);
}

app.use((req, res, next) => {
  const origin = req.headers.origin ?? '';
  if (origin && isCORSAllowed(origin)) {
    res.set('Access-Control-Allow-Origin', origin);
    res.set('Access-Control-Allow-Credentials', 'true');
    res.set('Vary', 'Origin');
  }
  next();
});

SkillAudit detection: SA-SKL-CORS15 flags wildcard Access-Control-Allow-Origin on routes with authentication middleware, unconditional reflect-origin patterns, any response with both Access-Control-Allow-Origin: * and Access-Control-Allow-Credentials, and RegExp.test() calls on the origin header without start-of-string anchoring. Run a free audit at skillaudit.dev.

PatternCVSSImpactFix
CORS15-001 wildcard on private endpoint9.3 CriticalCross-origin read of private dataExplicit allowlist; remove wildcard from authenticated routes
CORS15-002 reflect-origin + null bypass8.1 HighSandboxed iframe reads authenticated responseValidate against allowlist; reject null origin explicitly
CORS15-003 wildcard + credentials5.4 MediumOlder clients bypass credential restrictionNever combine wildcard with credentials headers
CORS15-004 unanchored regex8.1 HighAttacker subdomain bypasses allowlistAnchor regex at ^ and $; prefer exact set over regex