← Security advisories

Claude MCP skill CORS misconfiguration — skill API key and token management endpoints — SA-SKL-CORS52

SA-SKL-CORS52 documents four CORS misconfiguration patterns in MCP skill registry API key and token management endpoints. These endpoints control the lifecycle of programmatic access credentials — surfaces with direct and persistent access implications that extend far beyond any single browser session. Credential-bearing CORS on the API key list endpoint exposes the full roster of keys including their raw values, scopes, and usage statistics to any origin visiting with the victim's session. Wildcard ACAO on the key creation endpoint lets any page generate new API keys under the victim's identity with attacker-specified scopes, consuming key quota and granting persistent programmatic access that survives session expiry. A timing oracle on the key usage endpoint identifies the highest-activity keys — the most valuable exfiltration targets — before the CORS52-001 read is performed. And credential-bearing CORS on key deletion allows any origin to revoke any key using the victim admin's session, immediately disrupting all integrations that depend on those credentials.

SA-SKL-CORS52 findings at a glance
CRITICALCORS52-001 — cors({origin:true,credentials:true}) on GET /api/skills/:id/api-keys; any origin reads full API key list including key values, scopes, and usage statistics using victim session; fix: allowlist; requireSession; return only key metadata (prefix, last4, scopes, lastUsedAt) never full key value
HIGHCORS52-002 — ACAO: * on POST /api/skills/:id/api-keys; any page creates new API keys with attacker-specified scopes consuming key quota and granting persistent access; fix: remove wildcard; require session; requireRole('admin'); CSRF token; Zod ApiKeyCreateSchema; validate scope against allowed set
MEDIUMCORS52-003 — ACAO origin reflection on GET /api/skills/:id/api-keys/usage emitted before ownership check; timing oracle reveals API key usage patterns, enumerating high-activity keys as CORS52-001 targets; fix: auth before CORS emission; unified WHERE clause; normalize 403/404 latency
CRITICALCORS52-004 — cors({origin:true,credentials:true}) on DELETE /api/skills/:id/api-keys/:keyId; any origin revokes any API key using victim admin session, breaking integrations that depend on those keys; fix: allowlist + requireRole('admin') + ownership check + audit log + integration disruption notification

CORS52-001 — Credential-bearing CORS on API key list exposes full key values and usage statistics

Severity: CRITICAL

The GET /api/skills/:id/api-keys endpoint is configured with cors({origin:true,credentials:true}), reflecting every origin back as Access-Control-Allow-Origin and setting Access-Control-Allow-Credentials: true. Cross-origin JavaScript can read the full list of API keys for any skill using the victim's session cookie.

The key list document includes the raw API key value for each key — not a prefix or masked version, but the complete secret that grants programmatic access to the skill's audit API, CI webhooks, and configuration endpoints. It also includes each key's assigned scopes, creation timestamp, last-used timestamp, and usage volume statistics. An attacker who reads this list gains persistent programmatic access to the skill that survives beyond the victim's session expiry. Because API keys are long-lived credentials by design, the attacker retains access until the key is manually rotated — often weeks or months after the initial theft. The usage statistics are also commercially sensitive: they reveal integration traffic patterns and audit cadence that constitute competitive intelligence.

Vulnerable
// GET /api/skills/:id/api-keys — cors({origin:true,credentials:true}) inherited from router
router.get('/:id/api-keys', requireSession, async (req, res) => {
  const keys = await ApiKey.find({ skillId: req.params.id });
  return res.json(keys); // includes full key value in keyValue field
});
Fixed
// GET /api/skills/:id/api-keys — per-route allowlist cors + ownership gate
router.get('/:id/api-keys', apiKeyCors, requireSession, async (req, res) => {
  const skill = await Skill.findById(req.params.id);
  if (!skill || skill.ownerId.toString() !== req.session.userId) {
    return res.status(403).json({ error: 'Forbidden' });
  }

  const keys = await ApiKey.find({ skillId: req.params.id }).select(
    'keyPrefix lastFour scopes lastUsedAt createdAt usageCount -_id'
  ); // never return keyValue
  return res.json(keys);
});

CORS52-002 — Wildcard ACAO on key creation generates persistent attacker-scoped keys under victim identity

Severity: HIGH

The POST /api/skills/:id/api-keys endpoint returns Access-Control-Allow-Origin: *. The endpoint processes key creation requests without validating that the caller has admin authority over the skill or that the requested scopes are within the caller's permission set. Any web page that induces the victim admin's browser to issue a cross-origin POST can create new API keys for any skill under the victim's identity.

The resulting key is associated with the victim's account but is fully usable by the attacker, who controls the key value returned in the creation response or who re-reads it via CORS52-001. Crucially, this access persists indefinitely: the attacker can use the key after the victim's session expires, after the victim logs out, and even after the victim rotates their password — because API key validity is independent of session state. The attacker controls the scope of the created key, potentially requesting admin:all scope that grants capabilities beyond what the victim intended to authorize. The key quota consumed by the attacker also denies legitimate key creation for real integration needs.

API key creation is a persistent access grant, not a session action. A CORS misconfiguration on a session-scoped endpoint affects one visit; a CORS misconfiguration on a key creation endpoint creates a persistent backdoor. Wildcard ACAO on any key creation endpoint lets attackers generate long-lived credentials that require explicit rotation to remove. Always gate key creation on CSRF validation, session authentication, and scope validation independently of CORS policy.

CORS52-003 — Timing oracle on key usage endpoint enumerates high-activity keys as exfiltration targets

Severity: MEDIUM

The GET /api/skills/:id/api-keys/usage endpoint reflects the Origin header before performing the ownership check. The usage query aggregates request counts, error rates, and bandwidth metrics per key, and skills with high-volume keys take measurably longer to respond than skills with inactive or no keys. The latency difference is cross-origin-detectable, letting an attacker rank skills by API key activity and prioritize them for CORS52-001 key value exfiltration.

High-activity keys represent active integrations — CI pipelines, automated audit runs, monitoring agents — that will cause immediate operational impact when their values are exposed or revoked. By using the timing oracle to identify active keys before reading their values, an attacker concentrates exfiltration effort on the credentials that will give the most leverage while minimizing the number of requests needed to scan the full skill population.

The fix performs authentication and ownership checks before emitting any CORS header, uses a unified WHERE skillId = ? AND ownerId = ? clause so the ownership and usage queries share the same path, and normalizes 403/404 response latency with a constant-time floor to eliminate the timing signal.

CORS52-004 — Credential-bearing CORS on key deletion revokes active integrations from any origin

Severity: CRITICAL

The DELETE /api/skills/:id/api-keys/:keyId endpoint shares the same cors({origin:true,credentials:true}) policy as CORS52-001. Any web page can instruct the victim admin's browser to revoke any API key for any skill — there is no ownership check on the skill record and no confirmation gate. Revocation takes effect immediately, breaking all integrations that depend on the deleted key.

The most operationally damaging target is a CI pipeline key. CI pipeline keys are used by automated workflows that run on every code push — their deletion immediately breaks build validation for every pending and future commit, and the resulting CI failures appear as generic authentication errors that do not name the specific key that was revoked. Developers investigating the failures must triage all recent authentication changes before identifying the missing key, adding significant incident resolution time. Skills with active paying subscribers are particularly impacted: audit webhooks configured by team-plan customers depend on API keys whose revocation silently disables their compliance integrations, causing policy gates to fail open while appearing configured.

Vulnerable
// DELETE /api/skills/:id/api-keys/:keyId
// No ownership check, no audit log, no notification
router.delete('/:id/api-keys/:keyId', requireSession, async (req, res) => {
  const key = await ApiKey.findById(req.params.keyId);
  if (!key) return res.status(404).json({ error: 'Not found' });
  await key.deleteOne();
  return res.status(204).end();
});
Fixed
// DELETE /api/skills/:id/api-keys/:keyId
router.delete('/:id/api-keys/:keyId', apiKeyCors, requireSession, requireRole('admin'), async (req, res) => {
  const skill = await Skill.findById(req.params.id);
  if (!skill || skill.ownerId.toString() !== req.session.userId) {
    return res.status(403).json({ error: 'Forbidden' });
  }

  const key = await ApiKey.findOne({
    _id: req.params.keyId,
    skillId: req.params.id,
  });
  if (!key) return res.status(404).json({ error: 'Not found' });

  await key.deleteOne();

  await AuditLog.create({
    action: 'skill.apikey.deleted',
    skillId: req.params.id,
    keyId: req.params.keyId,
    keyPrefix: key.keyPrefix,
    actorId: req.session.userId,
    timestamp: new Date(),
  });

  await sendKeyRevocationNotification(req.session.userId, {
    skillId: req.params.id,
    keyPrefix: key.keyPrefix,
    revokedAt: new Date(),
  });

  return res.status(204).end();
});

Remediation summary

FindingSeverityPrimary remediationSecondary hardening
CORS52-001CriticalReplace origin:true with allowlist; gate key list on skill ownership; return only metadata (prefix, last4, scopes, lastUsedAt)Never return full key value after creation; treat key value as write-once secret
CORS52-002HighRemove ACAO: *; require session, requireRole('admin'), CSRF token; validate scopes via Zod ApiKeyCreateSchemaValidate scope does not exceed caller's own permission set; enforce key quota per skill
CORS52-003MediumAuth before CORS header emission; unified WHERE clause with ownership checkConstant-time 403/404 latency floor
CORS52-004CriticalReplace origin:true with allowlist; requireRole('admin'); skill ownership checkAudit log; revocation notification; CI disruption alert for pipeline-associated keys

Find CORS misconfigurations like these before attackers do. SkillAudit scans your MCP skill registry API key endpoints for all four SA-SKL-CORS52 patterns plus the broader CORS advisory series. See the SA-SKL-CORS51 organization member invitation advisory and the SA-SKL-CORS50 billing subscription advisory for related findings. Connect your repository at skillaudit.dev.