← Security advisories

Claude MCP skill CORS misconfiguration — skill permission and access control management endpoints — SA-SKL-CORS57

SA-SKL-CORS57 documents four CORS misconfiguration patterns in MCP skill registry skill permission and access control management endpoints. Permission management endpoints are uniquely sensitive: they hold durable override tokens issued for incident response that bypass normal auth enforcement, role-to-permission bindings governing what each team member can do with a skill, and temporary elevated access grants created during on-call escalations. A CORS misconfiguration here exposes these credentials and access maps to any origin, allows injection of attacker-controlled permission grants under a victim admin identity, enables identification of skills undergoing active permission changes via a timing oracle, and permits silent revocation of CI service account grants that break automated deployment pipelines without alerting the access control owner.

SA-SKL-CORS57 findings at a glance
CRITICALCORS57-001 — cors({origin:true,credentials:true}) on GET /api/skills/:id/permissions; any origin reads full permission map including per-user override tokens, role-to-permission bindings, and temporary elevated access grants using victim admin session; override tokens are durable credentials that bypass normal auth enforcement; fix: allowlist; requireSession + requireRole('admin'); return only caller's own permissions for non-admin callers; override tokens admin-only field
CRITICALCORS57-002 — ACAO: * on POST /api/skills/:id/permissions; any page creates attacker-controlled permission grants under victim admin identity, granting external attacker elevated access to private skills and admin-tier capabilities; fix: remove wildcard; require session; requireRole('admin'); CSRF token; Zod PermissionGrantSchema; audit log; rate-limit per userId+skillId
MEDIUMCORS57-003 — ACAO origin reflection on GET /api/skills/:id/permissions/audit emitted before ownership check; timing oracle reveals permission change velocity tiers identifying skills with active access control changes as CORS57-001 targets; fix: auth before CORS emission; unified WHERE clause; normalize 403/404 latency
CRITICALCORS57-004 — cors({origin:true,credentials:true}) on DELETE /api/skills/:id/permissions/:grantId; any origin revokes any permission grant using victim admin session, breaking CI service accounts and revoking access for legitimate users without notification; fix: allowlist + requireSession + ownership check + audit log on permission grant revocation events

CORS57-001 — Credential-bearing CORS on permission map exposes override tokens and role bindings

Severity: CRITICAL

The GET /api/skills/:id/permissions endpoint is configured with cors({origin:true,credentials:true}) applied at the router level. Any origin can read the full permission map document using the victim's session. The document includes per-user override tokens — durable credential strings issued during incident response that bypass normal session-based auth enforcement and allow any bearer to perform admin operations without an active session. It also includes role-to-permission bindings documenting exactly which actions each team role is authorized to perform, and temporary elevated access grants created during on-call escalations that expose which users currently hold time-limited admin privileges. For a non-admin caller this represents a full picture of the skill's internal access control model.

Override tokens are durable credentials. Unlike session tokens that expire on logout, permission override tokens issued for incident response are typically long-lived and stored independently of the session store. Reading the permission map via CORS57-001 hands the attacker a credential that persists after the victim logs out, enabling continued access to protected skill management operations.

Vulnerable
// GET /api/skills/:id/permissions — cors({origin:true,credentials:true}) at router level
router.use(cors({ origin: true, credentials: true }));

router.get('/:id/permissions', requireSession, async (req, res) => {
  const perms = await Permission.find({ skillId: req.params.id })
    .select('+overrideToken +roleBindings +elevatedGrants');  // includes credentials
  return res.json(perms);
});
Fixed
// GET /api/skills/:id/permissions — per-route allowlist cors + role-scoped fields
const permCors = cors({
  origin: process.env.ALLOWED_ORIGINS.split(','),
  credentials: true,
});

router.get('/:id/permissions', permCors, requireSession, async (req, res) => {
  const isAdmin = await Skill.exists({
    _id: req.params.id,
    admins: req.session.userId,
  });

  if (!isAdmin) {
    // non-admins see only their own permission record — no override tokens
    const myPerm = await Permission.findOne({
      skillId: req.params.id,
      userId: req.session.userId,
    }).select('-overrideToken -elevatedGrants');
    return res.json(myPerm || {});
  }

  const perms = await Permission.find({ skillId: req.params.id })
    .select('-overrideToken');  // override tokens never returned via API
  return res.json(perms);
});

CORS57-002 — Wildcard ACAO on permission grant creation enables external privilege escalation

Severity: CRITICAL

The POST /api/skills/:id/permissions endpoint returns Access-Control-Allow-Origin: *. Any web page can create permission grants under the victim admin's identity with attacker-controlled parameters. The attacker injects a grant that assigns an attacker-controlled user account the admin role or the registry_operator permission for a private skill, then accesses that skill directly using their own session without further CORS exploitation. Because the grant is created under the victim's admin identity, the audit log attributes the access expansion to the victim rather than the attacker. Organizations monitoring access control changes via the audit log see a seemingly-legitimate admin operation and do not trigger an incident response.

Vulnerable
// POST /api/skills/:id/permissions — ACAO:* with no role check or CSRF
router.post('/:id/permissions', requireSession, async (req, res) => {
  const { targetUserId, role, permissions, expiresAt } = req.body;
  const grant = await Permission.create({
    skillId: req.params.id,
    grantedBy: req.session.userId,
    targetUserId,          // attacker's own userId injected here
    role,                  // 'admin' injected
    permissions,           // ['read_private', 'manage_config'] injected
    expiresAt,
  });
  return res.status(201).json(grant);
});
Fixed
// POST /api/skills/:id/permissions — allowlist cors + admin role + CSRF + Zod + audit
const PermissionGrantSchema = z.object({
  targetUserId: z.string().uuid(),
  role: z.enum(['viewer', 'contributor', 'maintainer', 'admin']),
  permissions: z.array(z.enum(['read_public', 'read_private', 'manage_config', 'manage_members'])).max(8),
  expiresAt: z.string().datetime().optional(),
});

router.post(
  '/:id/permissions',
  permCors,
  requireSession,
  verifyCsrf,
  rateLimit({ windowMs: 60_000, max: 20, keyGenerator: r => `perm:${r.session.userId}:${r.params.id}` }),
  async (req, res) => {
    const isAdmin = await Skill.exists({ _id: req.params.id, admins: req.session.userId });
    if (!isAdmin) return res.status(403).json({ error: 'Admin role required' });

    const parsed = PermissionGrantSchema.safeParse(req.body);
    if (!parsed.success) return res.status(400).json({ error: 'Invalid permission grant' });

    const grant = await Permission.create({
      skillId: req.params.id,
      grantedBy: req.session.userId,
      ...parsed.data,
    });

    await AuditLog.create({
      action: 'permission.granted',
      actorId: req.session.userId,
      grantId: grant.id,
      skillId: req.params.id,
      targetUserId: parsed.data.targetUserId,
      role: parsed.data.role,
      origin: req.headers.origin,
      at: new Date(),
    });

    return res.status(201).json({ id: grant.id });
  }
);

CORS57-003 — Timing oracle on permission audit endpoint reveals active access control change targets

Severity: MEDIUM

The GET /api/skills/:id/permissions/audit endpoint reflects the Origin header before performing the ownership check. Skills with an active permission change event within the last 60 seconds have their audit trail cached in memory, responding in under 4 ms. Skills with no recent changes require a full database query, responding in 18–45 ms. Cross-origin RTT measurement across a sample of skill IDs identifies which skills are currently undergoing access control modifications — the most valuable CORS57-001 targets for override token exfiltration during a live admin session performing a permission grant operation. The fix performs the ownership check before CORS emission and enforces a constant-time floor of 60 ms on all responses.

Vulnerable
// GET /api/skills/:id/permissions/audit — Origin reflected before auth
router.get('/:id/permissions/audit', async (req, res) => {
  res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*');
  res.setHeader('Access-Control-Allow-Credentials', 'true');
  // ownership check runs after CORS header — timing oracle
  const skill = await Skill.findOne({ _id: req.params.id, admins: req.session?.userId });
  if (!skill) return res.status(403).json({ error: 'Forbidden' });
  const events = auditCache.get(req.params.id) || await AuditLog.find({ skillId: req.params.id, action: /^permission\./ });
  return res.json(events);
});
Fixed
// GET /api/skills/:id/permissions/audit — auth before CORS + constant-time floor
router.get('/:id/permissions/audit', requireSession, async (req, res) => {
  const start = Date.now();
  const skill = await Skill.findOne({ _id: req.params.id, admins: req.session.userId });
  if (!skill) {
    await sleep(60 - (Date.now() - start));
    return res.status(404).json({ error: 'Not found' });
  }
  permCors(req, res, async () => {
    const events = auditCache.get(req.params.id)
      || await AuditLog.find({ skillId: req.params.id, action: /^permission\./ }).sort('-at').limit(100);
    await sleep(Math.max(0, 60 - (Date.now() - start)));
    return res.json(events);
  });
});

CORS57-004 — Credential-bearing CORS on grant revocation breaks CI service accounts silently

Severity: CRITICAL

The DELETE /api/skills/:id/permissions/:grantId endpoint shares the same router-level credential-bearing CORS policy. Any page can revoke any permission grant using a victim admin session. The highest-impact target is a CI service account grant — a permission record that authorizes the organization's automated deployment pipeline to read private skill configuration, trigger skill version updates, or publish audit reports. Revoking this grant silently breaks the CI pipeline at the next run without any notification to the access control owner. The pipeline fails with an authorization error that appears to operators as a transient authentication issue rather than an intentional revocation. The attacker repeats the revocation for each newly-created replacement grant to maintain the denial of service.

Vulnerable
// DELETE /api/skills/:id/permissions/:grantId
// cors({origin:true,credentials:true}) from router.use()
// No ownership check, no audit log
router.delete('/:id/permissions/:grantId', requireSession, async (req, res) => {
  await Permission.deleteOne({ _id: req.params.grantId });
  return res.status(204).end();
});
Fixed
// DELETE /api/skills/:id/permissions/:grantId
// Per-route allowlist CORS + ownership check + notification + audit log
router.delete('/:id/permissions/:grantId', permCors, requireSession, async (req, res) => {
  const grant = await Permission.findOne({ _id: req.params.grantId, skillId: req.params.id });
  if (!grant) return res.status(404).json({ error: 'Grant not found' });

  const isAdmin = await Skill.exists({ _id: req.params.id, admins: req.session.userId });
  if (!isAdmin) return res.status(403).json({ error: 'Admin role required' });

  await grant.deleteOne();

  await AuditLog.create({
    action:       'permission.revoked',
    actorId:      req.session.userId,
    grantId:      req.params.grantId,
    skillId:      req.params.id,
    targetUserId: grant.targetUserId,
    role:         grant.role,
    origin:       req.headers.origin,
    at:           new Date(),
  });

  // notify the affected user so CI teams can investigate pipeline failures
  await Notification.create({
    userId:  grant.targetUserId,
    type:    'permission.revoked',
    skillId: req.params.id,
    grantId: req.params.grantId,
    at:      new Date(),
  });

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

Related advisories:   SA-SKL-CORS56 (changelog/release notes)  |  SA-SKL-CORS55 (review/feedback)  |  SA-SKL-CORS55 blog