SA-SKL-CORS30 — CORS Misconfiguration

CORS Misconfigurations in MCP Skill Registry Audit Webhook Replay and Delivery Confirmation Endpoints

Webhook delivery management endpoints — replay, delivery history, retry, and test — control the flow of audit result notifications to downstream CI/CD systems. SA-SKL-CORS30 covers four CORS misconfigurations that allow cross-origin pages to replay arbitrary past deliveries, read full delivery request bodies, probe delivery record existence via timing, and trigger test deliveries to victim CI/CD webhooks using the victim's admin session.

SA-SKL-CORS30 findings at a glance
CRITICALCORS30-001 — POST /api/webhooks/:id/replay has ACAO: *; attacker page replays any past delivery using victim admin session cross-origin, flooding the target endpoint with replayed audit events and triggering rate-limit locks on the destination
HIGHCORS30-002 — GET /api/webhooks/:id/deliveries has cors({origin:true,credentials:true}); any origin reads full delivery history including request bodies (which contain full audit report payloads) cross-origin using victim session
HIGHCORS30-003 — POST /api/webhooks/:id/deliveries/:deliveryId/retry reflects Origin before auth check; timing difference between owned and unowned delivery records acts as an oracle revealing delivery record existence
CRITICALCORS30-004 — POST /api/webhooks/:id/test has ACAO: *; attacker page sends a test delivery to any of the victim's configured CI/CD webhook URLs cross-origin, triggering builds and deployments without victim knowledge

CORS30-001 — Wildcard ACAO on webhook replay POST

The webhook replay endpoint POST /api/webhooks/:id/replay re-delivers a previously sent audit event payload to the webhook's configured target URL. It is designed for developers who need to re-trigger a downstream pipeline after a transient delivery failure. With ACAO: * applied, any attacker origin can POST to this endpoint using the victim's session cookie, replaying any past delivery record associated with the victim's webhook.

The impact is a targeted flood attack on the victim's CI/CD infrastructure: the attacker page loops over all delivery IDs harvested from CORS30-002 and replays each one, sending hundreds of audit event payloads to the victim's CI/CD webhook URL in rapid succession. Each replayed delivery triggers a fresh pipeline run. The pipeline's rate-limit kicks in and locks out legitimate deliveries, while the CI/CD system's concurrent job queue fills with redundant audit-triggered runs consuming build minutes.

Vulnerable
// CORS30-001 — VULNERABLE
// ACAO:* on replay POST — any origin replays any past delivery using victim session.

router.post('/:id/replay', requireSession, requireWebhookOwner, async (req, res) => {
  res.header('Access-Control-Allow-Origin', '*'); // VULNERABLE
  const delivery = await db.deliveries.findById(req.body.deliveryId);
  await webhookQueue.add('replay', { webhookId: req.params.id, delivery });
  res.json({ ok: true });
});

Fix: Replace ACAO: * with an explicit origin allowlist via cors(allowlistOptions) applied as middleware. Add a per-webhook replay rate limit (max 5 replays per hour). Add a CSRF token requirement. Log all replay actions to the webhook audit trail with actor ID, delivery ID, and timestamp. Reject replay requests for delivery records that are not owned by the authenticated user's webhook.

// CORS30-001 — FIXED
const { webhookCorsOptions } = require('../config/cors'); // explicit allowlist
const replayRateLimit = rateLimit({ windowMs: 3600000, max: 5, keyGenerator: req => `replay:${req.params.id}` });

router.post('/:id/replay', cors(webhookCorsOptions), replayRateLimit,
  requireSession, requireWebhookOwner, verifyCsrfToken, requireContentType('application/json'),
  async (req, res) => {
    const delivery = await db.deliveries.findByIdAndWebhookId(req.body.deliveryId, req.params.id);
    if (!delivery) return res.status(404).json({ error: 'Delivery not found' });
    await webhookQueue.add('replay', { webhookId: req.params.id, deliveryId: delivery.id });
    await db.webhookAudit.create({ action: 'delivery_replayed', webhookId: req.params.id,
      deliveryId: delivery.id, actorId: req.session.userId, ip: req.ip, at: new Date() });
    res.json({ ok: true });
  });

CORS30-002 — Origin reflection on delivery history GET leaks request bodies

The delivery history endpoint GET /api/webhooks/:id/deliveries returns a paginated list of past delivery attempts, including the full request body sent to the target URL. In an audit-result webhook, the request body contains the complete audit report payload: vulnerability findings, severity scores, affected skill IDs, remediation hints, and the audit metadata. The endpoint uses cors({origin:true,credentials:true}), reflecting any origin as ACAO and enabling credentialed cross-origin reads.

Vulnerable
// CORS30-002 — VULNERABLE
// cors({origin:true,credentials:true}) reflects any origin — attacker reads full delivery history.

router.get('/:id/deliveries', cors({ origin: true, credentials: true }), // VULNERABLE
  requireSession, requireWebhookOwner, async (req, res) => {
    const deliveries = await db.deliveries.findByWebhookId(req.params.id, { page: req.query.page });
    res.json(deliveries); // includes full requestBody with audit report payload
  });

Fix: Replace origin:true with an explicit allowlist. Strip the requestBody and responseBody fields from the list response — return only id, status, createdAt, and httpStatus. Full body fields are served only via a detail endpoint (GET /api/webhooks/:id/deliveries/:deliveryId) which requires explicit navigation and can be further restricted to same-site requests only.

// CORS30-002 — FIXED
router.get('/:id/deliveries', cors(webhookCorsOptions), requireSession, requireWebhookOwner,
  async (req, res) => {
    const deliveries = await db.deliveries.findByWebhookId(req.params.id, { page: req.query.page });
    res.json(deliveries.map(d => ({
      id: d.id, status: d.status, httpStatus: d.httpStatus, createdAt: d.createdAt
      // requestBody and responseBody NOT included in list view
    })));
  });

CORS30-003 — Origin reflection before auth on retry POST — timing oracle

The delivery retry endpoint POST /api/webhooks/:id/deliveries/:deliveryId/retry emits CORS headers inside the route handler before the authorization check runs. An attacker who sends retry requests from a cross-origin page observes timing differences: requests for delivery IDs that exist take longer (DB lookup + ownership check) than requests for IDs that do not exist (early 404 from the lookup). Because the ACAO header is emitted before these branches, the attacker can read the header and correlate timing to enumerate delivery IDs across all accounts on the platform.

Vulnerable
// CORS30-003 — VULNERABLE
// CORS headers emitted before auth — timing oracle via response latency after ACAO emission.

router.post('/:id/deliveries/:deliveryId/retry', requireSession, async (req, res) => {
  res.header('Access-Control-Allow-Origin', req.headers.origin || '*'); // VULNERABLE: before auth
  const delivery = await db.deliveries.findById(req.params.deliveryId); // timing varies by existence
  if (!delivery || delivery.webhookId !== req.params.id) {
    return res.status(404).json({ error: 'Not found' });
  }
  if (delivery.webhook.userId !== req.session.userId) {
    return res.status(403).json({ error: 'Forbidden' }); // shorter path after ACAO emitted
  }
  await webhookQueue.add('retry', { deliveryId: delivery.id });
  res.json({ ok: true });
});

Fix: Apply cors(allowlistOptions) as route middleware before the handler. Perform auth and ownership check using a combined findByIdAndWebhookIdAndUserId() query that returns null for both not-found and not-owned (eliminating the timing delta). Return 404 for both cases. Add CSRF token verification.

// CORS30-003 — FIXED
router.options('/:id/deliveries/:deliveryId/retry', cors(webhookCorsOptions));
router.post('/:id/deliveries/:deliveryId/retry', cors(webhookCorsOptions),
  requireSession, verifyCsrfToken, requireContentType('application/json'),
  async (req, res) => {
    // Combined query: null for not-found AND not-owned — no timing oracle
    const delivery = await db.deliveries.findByIdAndWebhookIdAndUserId(
      req.params.deliveryId, req.params.id, req.session.userId);
    if (!delivery) return res.status(404).json({ error: 'Delivery not found' });
    await webhookQueue.add('retry', { deliveryId: delivery.id });
    res.json({ ok: true });
  });

CORS30-004 — Wildcard ACAO on webhook test POST triggers CI/CD deployments

The webhook test endpoint POST /api/webhooks/:id/test sends a sample audit event payload to the webhook's configured target URL. It is used by developers to verify their CI/CD pipeline integration before the first real audit. With ACAO: *, any attacker origin can trigger test deliveries to any of the victim's configured webhook URLs using the victim's admin session, causing the downstream CI/CD system to process a fake audit event and potentially trigger a build or deployment.

Vulnerable
// CORS30-004 — VULNERABLE
// ACAO:* on test POST — attacker triggers test deliveries to victim CI/CD webhooks.

router.post('/:id/test', requireSession, requireWebhookOwner, async (req, res) => {
  res.header('Access-Control-Allow-Origin', '*'); // VULNERABLE
  await webhookQueue.add('test', { webhookId: req.params.id });
  res.json({ ok: true });
});

Fix: Replace ACAO: * with explicit origin allowlist. Add a CSRF token requirement. Add a per-org rate limit on test deliveries (max 3 per hour). Log all test delivery triggers to the webhook audit trail.

// CORS30-004 — FIXED
const testRateLimit = rateLimit({ windowMs: 3600000, max: 3, keyGenerator: req => `test:${req.session.userId}` });
router.post('/:id/test', cors(webhookCorsOptions), testRateLimit,
  requireSession, requireWebhookOwner, verifyCsrfToken, requireContentType('application/json'),
  async (req, res) => {
    await webhookQueue.add('test', { webhookId: req.params.id });
    await db.webhookAudit.create({ action: 'test_delivery_triggered', webhookId: req.params.id,
      actorId: req.session.userId, ip: req.ip, at: new Date() });
    res.json({ ok: true });
  });

Summary

FindingPatternSeverityFix
CORS30-001ACAO: * on webhook replay POSTCRITICALExplicit allowlist + CSRF + replay rate limit + audit log
CORS30-002cors({origin:true,credentials:true}) on delivery history GETHIGHExplicit allowlist; strip request/response bodies from list view
CORS30-003Origin reflection before auth on retry POSTHIGHCORS as middleware; combined ownership query; constant-time 404
CORS30-004ACAO: * on webhook test POSTCRITICALExplicit allowlist + CSRF + per-org rate limit + audit log

Related: SA-SKL-CORS29 (API key management CORS), SA-SKL-CORS28 (webhook secret rotation and audit configuration CORS). Run SkillAudit to detect all CORS30 patterns in your MCP skill registry alongside the full SA-SKL catalog.