Claude MCP skill CORS misconfiguration — webhook subscription and event delivery configuration endpoints
SA-SKL-CORS34 documents four CORS vulnerabilities in MCP skill registry webhook subscription and event delivery configuration endpoints. Credential-bearing CORS on the webhook list endpoint leaks internal CI/CD pipeline trigger URLs and Slack channel hooks to any origin, wildcard ACAO on the creation endpoint enables any attacker page to register event receivers on the victim's account, Origin reflection before secret verification creates a timing oracle over webhook ID existence, and credential-bearing CORS on the delivery log endpoint exposes complete audit finding payloads in request and response bodies.
cors({origin:true,credentials:true}); any origin reads all webhook URLs including internal CI/CD pipeline trigger endpoints and Slack channels using victim session cookie
ACAO:*; attacker page creates webhook pointing to attacker server which then receives all audit events from victim account cross-origin without needing victim credentials on the creation call
cors({origin:true,credentials:true}); any origin reads full delivery history including request bodies containing complete audit finding payloads and response bodies with acknowledgement data
CORS34-001 (Critical): Credential-bearing CORS on webhook list exposes internal CI/CD and Slack URLs
MCP skill registries commonly integrate with downstream systems via webhooks: CI/CD pipeline trigger endpoints, Slack incoming webhook URLs, PagerDuty integration URLs, and internal notification services. The webhook list endpoint GET /api/webhooks allows the account owner to manage these integrations. When this endpoint is configured with cors({origin:true,credentials:true}) — which dynamically echoes any supplied Origin value as Access-Control-Allow-Origin while simultaneously setting Access-Control-Allow-Credentials: true — any page on the web can issue a credentialed cross-origin GET and read the complete response using the victim's browser session.
The data exposed goes beyond ordinary configuration leakage. Internal CI/CD trigger URLs typically embed pipeline-specific secrets in the path or query string (e.g., https://ci.internal/api/v1/pipelines/prod-deploy/trigger?token=...). Slack incoming webhook URLs grant the ability to post messages to private Slack channels without authentication. PagerDuty integration URLs enable creating incidents in the victim's on-call rotation. An attacker who reads these URLs via CORS can invoke them directly, triggering production deployments, posting messages to private security channels, or spamming the victim's on-call rotation — all using credentials already embedded in the URLs themselves. CVSS 9.1 (AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N).
// VULNERABLE — webhook list endpoint uses cors({origin:true,credentials:true})
// File: routes/webhooks.js
const cors = require('cors');
const router = require('express').Router();
// VULNERABILITY: origin:true reflects any Origin header back as ACAO
// credentials:true allows session cookies to accompany cross-origin request
// Combined: any attacker page reads all webhook URLs with victim's session
router.get('/webhooks', cors({ origin: true, credentials: true }), authenticate, async (req, res) => {
const userId = req.user.sub;
const { rows } = await db.query(
`SELECT id, name, url, events, secret_hint, enabled, created_at
FROM webhooks
WHERE user_id = $1
ORDER BY created_at DESC`,
[userId]
);
// url field contains full webhook URL including embedded credentials
res.json({ webhooks: rows });
});
Fix: Replace cors({origin:true,credentials:true}) with an explicit allowlist of trusted origins. Additionally, strip or redact embedded secrets from webhook URLs before returning them in the list response — return only the hostname and a masked path for non-admin users. Internal endpoint URLs (CI/CD, Slack, PagerDuty) should never appear in full in list responses. If the full URL must be retrievable, expose it only on a separate authenticated single-webhook GET endpoint, never in the bulk list.
// FIXED — explicit origin allowlist; internal URLs redacted in list response
// File: routes/webhooks.js
const cors = require('cors');
const router = require('express').Router();
const webhookCors = cors({
origin: ['https://skillaudit.dev'], // explicit allowlist; never origin:true
credentials: true,
});
function redactWebhookUrl(url) {
try {
const u = new URL(url);
// Return only scheme + host; strip path (may contain embedded tokens)
return `${u.protocol}//${u.hostname}/***`;
} catch { return '[invalid url]'; }
}
router.get('/webhooks', webhookCors, authenticate, async (req, res) => {
const userId = req.user.sub;
const { rows } = await db.query(
`SELECT id, name, url, events, enabled, created_at
FROM webhooks
WHERE user_id = $1
ORDER BY created_at DESC`,
[userId]
);
const sanitized = rows.map(r => ({ ...r, url: redactWebhookUrl(r.url) }));
res.json({ webhooks: sanitized });
});
CORS34-002 (High): Wildcard ACAO on webhook creation enables cross-origin attacker receiver registration
The webhook creation endpoint POST /api/webhooks allows authenticated users to register new event receivers. When this endpoint responds with Access-Control-Allow-Origin: *, an attacker page can register a new webhook pointing to an attacker-controlled server without triggering a preflight check if the content type is a simple type. For registries that also accept Bearer token authentication via Authorization headers stored in localStorage, cross-origin JavaScript can read and forward these tokens directly, bypassing the cookie-only restriction that CORS enforces when ACAO:* is set.
Once an attacker-controlled webhook is registered on the victim's account, every future security audit event — new vulnerabilities discovered, severity changes, skill scan completions — is delivered to the attacker's server in real time. The attacker receives a persistent, ongoing feed of the victim's security findings for all monitored MCP skills and repositories. Unlike credential theft, this attack does not require intercepting a session: the webhook delivers findings to the attacker server-to-server, persisting even after the victim rotates their password. CVSS 7.1 (AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N).
// VULNERABLE — webhook creation endpoint serves ACAO:* allowing cross-origin POST
// File: routes/webhooks.js
// VULNERABILITY: wildcard ACAO on write endpoint
// If auth uses Bearer token in localStorage, attacker JS can read and forward it
router.post('/webhooks',
(req, res, next) => { res.setHeader('Access-Control-Allow-Origin', '*'); next(); },
authenticate,
async (req, res) => {
const userId = req.user.sub;
const { name, url, events, secret } = req.body;
const { rows } = await db.query(
`INSERT INTO webhooks (user_id, name, url, events, secret_hash)
VALUES ($1, $2, $3, $4, $5) RETURNING id`,
[userId, name, url, JSON.stringify(events), hashSecret(secret)]
);
res.status(201).json({ id: rows[0].id });
}
);
Fix: Remove the Access-Control-Allow-Origin: * header from all write endpoints. Webhook registration is a privileged write operation that modifies account state; it should require a preflight check, which the same-origin policy enforces by default for application/json requests when no permissive CORS header is present. Additionally, enforce a per-account webhook count limit to prevent flooding, and validate that the webhook URL targets a public internet host (not localhost, RFC 1918 addresses, or link-local ranges) to prevent SSRF via attacker-controlled delivery.
// FIXED — no ACAO on write endpoint; count limit; URL validation
// File: routes/webhooks.js
const { isPublicIp } = require('./utils/ip-validation');
// No cors() on write endpoints — same-origin policy enforces preflight by default
router.post('/webhooks', authenticate, validateWebhookInput, async (req, res) => {
const userId = req.user.sub;
const { name, url, events, secret } = req.body;
// Enforce per-account webhook limit
const { rows: countRows } = await db.query(
'SELECT COUNT(*) FROM webhooks WHERE user_id = $1', [userId]);
if (parseInt(countRows[0].count) >= 20) {
return res.status(429).json({ error: 'Webhook limit reached (max 20)' });
}
// Block SSRF via attacker webhook pointing to internal services
const targetHost = new URL(url).hostname;
if (!await isPublicIp(targetHost)) {
return res.status(400).json({ error: 'Webhook URL must target a public internet host' });
}
const { rows } = await db.query(
`INSERT INTO webhooks (user_id, name, url, events, secret_hash)
VALUES ($1, $2, $3, $4, $5) RETURNING id`,
[userId, name, url, JSON.stringify(events), hashSecret(secret)]
);
res.status(201).json({ id: rows[0].id });
});
CORS34-003 (Medium): Origin reflection before secret verification creates webhook-ID timing oracle
The webhook test-fire endpoint POST /api/webhooks/:id/test sends a sample delivery to the configured URL, verifying that the webhook is reachable. When this endpoint reflects the incoming Origin header as Access-Control-Allow-Origin before performing a webhook secret verification or ownership check, the CORS reflection is unconditional. The subsequent processing path creates a measurable timing difference: a request targeting a valid webhook ID belonging to the requesting user proceeds through secret validation and fires a test delivery (slower); a request targeting a valid webhook ID belonging to another user returns a 403 after a database lookup (medium); a request targeting an entirely non-existent webhook ID returns a 404 immediately with no database round-trip (fastest).
An attacker with a known webhook ID format can enumerate the entire webhook ID space from a cross-origin page by measuring these response-time differences. Because the Origin is reflected unconditionally, the attacker's JavaScript receives the response — including timing metadata — for every probe. The oracle identifies which webhook IDs are valid system-wide (not just for the requesting user), enabling targeted follow-on attacks using CORS34-001 and CORS34-004 against specific victim IDs. CVSS 5.3 (AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N).
// VULNERABLE — Origin reflected before ownership and secret check; timing oracle
// File: routes/webhooks.js
router.post('/webhooks/:id/test', (req, res, next) => {
// VULNERABILITY: CORS reflection is unconditional — happens before any auth check
// Timing delta between 404 (no DB), 403 (DB lookup), and 200 (full flow) leaks ID status
res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*');
res.setHeader('Access-Control-Allow-Credentials', 'true');
next();
}, authenticate, async (req, res) => {
const { id } = req.params;
const userId = req.user.sub;
const { rows } = await db.query(
'SELECT user_id, url, secret_hash FROM webhooks WHERE id = $1',
[id]
);
if (!rows.length) return res.status(404).json({ error: 'Webhook not found' });
if (rows[0].user_id !== userId) return res.status(403).json({ error: 'Forbidden' });
await deliverTestPayload(rows[0].url, rows[0].secret_hash);
res.json({ delivered: true });
});
Fix: Perform authentication and ownership verification before emitting any CORS header. Use a single WHERE id = $1 AND user_id = $2 query to collapse the 404-vs-403 timing difference into a constant-time response path — both "not found" and "not owned" return 403 with no CORS header, so cross-origin JavaScript cannot read the response or distinguish the error cases. Apply CORS middleware only after successful ownership verification via an explicit allowlist.
// FIXED — CORS applied only after ownership verified; unified query eliminates timing oracle
// File: routes/webhooks.js
const webhookCors = cors({ origin: ['https://skillaudit.dev'], credentials: true });
router.post('/webhooks/:id/test', authenticate, async (req, res) => {
const { id } = req.params;
const userId = req.user.sub;
// Single query: ownership check included — eliminates 404 vs 403 timing distinction
const { rows } = await db.query(
'SELECT url, secret_hash FROM webhooks WHERE id = $1 AND user_id = $2',
[id, userId]
);
if (!rows.length) {
// No CORS headers emitted — attacker page cannot read response status
return res.status(403).json({ error: 'Forbidden' });
}
await deliverTestPayload(rows[0].url, rows[0].secret_hash);
// CORS headers emitted only after successful ownership verification
webhookCors(req, res, () => {});
res.json({ delivered: true });
});
CORS34-004 (Critical): Credential-bearing CORS on delivery log exposes full audit finding payloads
The webhook delivery log endpoint GET /api/webhooks/:id/deliveries returns the history of all delivery attempts for a webhook: the HTTP request body sent (containing the full audit event payload), the HTTP response body received (containing the receiver's acknowledgement), response status codes, and delivery timestamps. When this endpoint is configured with cors({origin:true,credentials:true}), any attacker page can issue a credentialed cross-origin GET and read the full delivery history for any webhook accessible to the victim's session.
The request bodies in delivery history contain complete audit finding objects: vulnerability identifiers, severity ratings, affected file paths, line numbers, code snippets, remediation recommendations, and skill registry metadata. This is typically the most granular security intelligence the registry produces — more detailed than any summary or dashboard view. The response bodies expose the content and status of the receiving system (the CI/CD pipeline or Slack channel handler), which may itself contain internal service metadata. Combined with the missing ownership check that frequently accompanies this CORS pattern, an attacker can read delivery histories across all accounts in the system, not just their own. CVSS 9.1 (AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N).
// VULNERABLE — delivery log endpoint uses cors({origin:true,credentials:true})
// File: routes/webhooks.js
// VULNERABILITY: same misconfiguration as CORS34-001 on delivery history endpoint
// request_body contains full audit finding JSON; response_body contains receiver ack
router.get('/webhooks/:id/deliveries',
cors({ origin: true, credentials: true }),
authenticate,
async (req, res) => {
const { id } = req.params;
const userId = req.user.sub;
// Note: missing ownership check — any authenticated user reads any webhook's deliveries
const { rows } = await db.query(
`SELECT delivered_at, request_body, response_body, response_status, duration_ms
FROM webhook_deliveries
WHERE webhook_id = $1
ORDER BY delivered_at DESC
LIMIT 50`,
[id]
);
res.json({ webhookId: id, deliveries: rows });
}
);
Fix: Replace cors({origin:true,credentials:true}) with an explicit origin allowlist. Add an ownership check by joining against the webhooks table, confirming that the webhook belongs to the requesting user before returning any delivery data. Consider whether full request_body and response_body content should appear in the delivery log at all — truncate or hash the bodies in stored records if the full payload is not needed for debugging, reducing the blast radius of any future misconfiguration.
// FIXED — explicit CORS allowlist + ownership check on delivery log endpoint
// File: routes/webhooks.js
const webhookCors = cors({ origin: ['https://skillaudit.dev'], credentials: true });
router.get('/webhooks/:id/deliveries', webhookCors, authenticate, async (req, res) => {
const { id } = req.params;
const userId = req.user.sub;
// JOIN enforces ownership — no delivery data returned for webhooks owned by other users
const { rows } = await db.query(
`SELECT d.delivered_at, d.request_body, d.response_body, d.response_status, d.duration_ms
FROM webhook_deliveries d
JOIN webhooks w ON w.id = d.webhook_id
WHERE d.webhook_id = $1
AND w.user_id = $2 -- ownership enforced at query level
ORDER BY d.delivered_at DESC
LIMIT 50`,
[id, userId]
);
if (!rows.length) return res.status(404).json({ error: 'Webhook not found or no deliveries' });
res.json({ webhookId: id, deliveries: rows });
});
Compound attack chain: webhook enumeration to persistent audit event surveillance
The four CORS34 vulnerabilities compose into a persistent surveillance chain against a victim's MCP skill registry account, requiring only a single page visit with no additional interaction.
Phase 1 — ID enumeration (CORS34-003). The attacker's malicious page fires POST requests to sequentially numbered or UUID-formatted webhook IDs. The timing oracle from unconditional Origin reflection distinguishes valid IDs from non-existent ones, building a list of active webhook IDs in the system. Session-authenticated 200 responses identify IDs belonging to the victim.
Phase 2 — Webhook URL theft (CORS34-001). With the victim's session cookie present in the browser, the attacker page issues a credentialed GET to /api/webhooks. The cors({origin:true,credentials:true}) configuration delivers the full webhook list, including internal CI/CD trigger URLs and Slack channel hooks. The attacker can now invoke these URLs directly — triggering production pipeline runs or posting to private security Slack channels.
Phase 3 — Audit payload exfiltration (CORS34-004). Using the webhook IDs from Phase 1, the attacker issues credentialed GETs to /api/webhooks/:id/deliveries for each identified ID. Full audit finding payloads in delivery request bodies expose every vulnerability the registry has discovered across all monitored skills and repositories.
Phase 4 — Persistent receiver registration (CORS34-002). With full knowledge of the event schema from Phase 3, the attacker registers a new webhook pointing to their own server using the ACAO:* creation endpoint. This webhook receives all future audit events in real time, persisting beyond any password rotation because the delivery is server-to-server.
Chain severity: This chain achieves persistent, real-time access to all future security findings for the victim's registered MCP skills, plus the ability to trigger internal CI/CD pipelines and post to private Slack channels. The persistence of Phase 4 is particularly damaging — unlike session theft, a registered webhook survives credential rotation and continues delivering intelligence until the victim explicitly audits and removes their webhook registrations.
Detection with tree-sitter queries
The highest-value patterns in this advisory are the cors({origin:true,credentials:true}) misconfiguration (CORS34-001, CORS34-004), the unconditional CORS header emission before auth checks (CORS34-003), and wildcard ACAO on write endpoints (CORS34-002). The following tree-sitter queries identify all three patterns in Node.js codebases.
Query 1 — cors({origin:true}) with credentials. Matches cors() call expressions where the options object contains origin: true and credentials: true. Every match is a credential-bearing CORS misconfiguration exposing authenticated endpoints to any origin.
; tree-sitter query: cors({origin:true,credentials:true}) misconfiguration
; Matches CORS34-001 and CORS34-004 patterns
(call_expression
function: (identifier) @fn (#eq? @fn "cors")
arguments: (arguments
(object
(pair
key: (property_identifier) @origin-key (#eq? @origin-key "origin")
value: (true) @origin-val
)
(pair
key: (property_identifier) @creds-key (#eq? @creds-key "credentials")
value: (true) @creds-val
)
)
)
) @finding
; Each @finding is a potential SA-SKL-CORS34-001 / CORS34-004 instance.
; Confirm: is this endpoint authenticated? Does it serve sensitive per-user data?
; Fix: replace origin:true with origin:['https://your-domain.com'] explicit allowlist.
Query 2 — setHeader('Access-Control-Allow-Origin') in route handler body. Matches route handler functions where res.setHeader is called with ACAO inline, before any db.query ownership check — the structural signature of CORS34-003.
; tree-sitter query: inline ACAO setHeader before ownership DB query (CORS34-003)
; Matches res.setHeader('Access-Control-Allow-Origin', ...) preceding db.query(...)
(arrow_function
body: (statement_block
(expression_statement
(call_expression
function: (member_expression
object: (identifier) @res (#match? @res "res")
property: (property_identifier) @method (#eq? @method "setHeader")
)
arguments: (arguments
(string) @hdr (#match? @hdr "Access-Control-Allow-Origin")
(_) @origin-value
)
)
)
(_)*
(variable_declaration
(variable_declarator
value: (await_expression
(call_expression
function: (member_expression
property: (property_identifier) @db-method (#match? @db-method "query|findOne|find")
)
)
)
)
)
)
) @ordering-issue
; Each @ordering-issue: CORS emitted before DB ownership check.
; Fix: move ownership check before CORS header emission.
Query 3 — Wildcard ACAO set via setHeader on write route. Matches router.post / router.put / router.patch / router.delete handler chains where an inline middleware calls setHeader with Access-Control-Allow-Origin set to the string '*' — the CORS34-002 pattern.
; tree-sitter query: ACAO:* set inline on write endpoints (CORS34-002)
; Matches router.post/put/patch/delete with inline setHeader('ACAO', '*')
(call_expression
function: (member_expression
object: (identifier) @router
property: (property_identifier) @verb
(#match? @verb "^(post|put|patch|delete)$")
)
arguments: (arguments
(string)
(arrow_function
body: (statement_block
(expression_statement
(call_expression
function: (member_expression
property: (property_identifier) @method (#eq? @method "setHeader")
)
arguments: (arguments
(string) @hdr (#match? @hdr "Access-Control-Allow-Origin")
(string) @val (#eq? @val "*")
)
)
)
)
)
)
) @wildcard-write-cors
; Each @wildcard-write-cors: wildcard ACAO on a write endpoint.
; Fix: remove ACAO from write endpoints; require preflight via same-origin policy.
Summary
| ID | Severity | Surface | Root cause | Fix |
|---|---|---|---|---|
| CORS34-001 | Critical | GET /api/webhooks — webhook list | cors({origin:true,credentials:true}) reflects any Origin; full webhook URL list including embedded CI/CD tokens exposed |
Explicit origin:['https://skillaudit.dev'] allowlist; redact internal URLs in list response |
| CORS34-002 | High | POST /api/webhooks — webhook creation | ACAO:* on write endpoint; attacker registers receiver on victim account for persistent event delivery |
Remove wildcard ACAO from write endpoints; validate webhook URL targets public IP; enforce count limit |
| CORS34-003 | Medium | POST /api/webhooks/:id/test — test fire | Origin reflected before ownership check; 404/403/200 timing delta leaks webhook ID existence system-wide | Apply CORS after ownership check; unified WHERE id=$1 AND user_id=$2 query eliminates timing oracle |
| CORS34-004 | Critical | GET /api/webhooks/:id/deliveries — delivery log | cors({origin:true,credentials:true}) + missing ownership check; full audit finding payloads in request bodies exposed |
Explicit origin allowlist; JOIN webhooks WHERE user_id=$2 ownership filter |
Checklist for MCP skill registry operators: (1) Grep all route files for cors({ and audit every instance — flag any using origin:true or origin:'*'. (2) Confirm credentials:true is paired only with explicit string or array origin values. (3) Audit all CORS middleware placement — it must run after authentication and ownership verification, never before. (4) Search for inline setHeader('Access-Control-Allow-Origin', '*') on POST/PUT/PATCH/DELETE handlers. (5) Review all webhook URL storage — confirm embedded secrets are never returned in bulk list responses. (6) Verify webhook creation validates target URL is a public internet host to prevent SSRF. (7) Check all delivery log endpoints for ownership checks in the query. (8) Run the three tree-sitter queries above in CI to prevent regressions across the full SA-SKL-CORS series. See also: SA-SKL-CORS33 for the same pattern on audit scheduling endpoints.
Related advisories: SA-SKL-SSRF36 — SSRF via attacker-controlled webhook URL targets; SA-SKL-INJECTION24 — injection via webhook-triggered CI/CD pipelines; SA-SKL-PRIVESC17 — privilege escalation via org management endpoint.
Scan your MCP skills for CORS34 and 2400+ other patterns
SkillAudit continuously audits MCP server and Claude skill codebases for CORS misconfigurations, injection vulnerabilities, deserialization flaws, SSRF, and privilege escalation. Get findings in minutes.
Get started at skillaudit.dev