Claude MCP skill CORS misconfiguration — skill API key and access token management endpoints — SA-SKL-CORS65
SA-SKL-CORS65 documents four CORS misconfiguration vulnerabilities in MCP skill registry API key and access token management endpoints. API key management endpoints govern which credentials exist for a skill, what registry scopes each key carries, and whether integrations depending on those keys remain active. CORS65-001: credential-bearing CORS exposes full API key list including live key values, scopes, and expiry timestamps to any origin; CORS65-002: wildcard ACAO on key creation enables attacker-injected persistent API keys under victim admin identity, surviving session expiry; CORS65-003: timing oracle via Origin reflection identifies skills with high-traffic API key activity as exfiltration targets; CORS65-004: credential-bearing CORS on key revocation disrupts CI/CD pipelines and production integrations by revoking active API keys.
GET /api/skills/:id/api-keys has cors({origin:true,credentials:true}) — any origin reads full API key list including key values, scopes, and expiry dates using victim admin session; reveals active API keys that grant registry API access to attacker; fix: per-route allowlist cors; requireSession + requireRole('admin'); never return raw key values to non-admin callersPOST /api/skills/:id/api-keys has ACAO:* — any page creates attacker-controlled API keys under victim admin identity; attacker creates persistent API key with registry admin scope, maintaining registry access after victim session expires; fix: allowlist CORS; requireRole('admin'); CSRF; Zod ApiKeySchema with scopes enum and expiresAt ceiling; audit log with originGET /api/skills/:id/api-keys/usage reflects Origin before ownership check — timing oracle reveals API key usage velocity identifying skills with high-traffic API key activity as CORS65-001 targets; fix: auth before CORS; unified WHERE; 60ms constant-time floorDELETE /api/skills/:id/api-keys/:keyId has cors({origin:true,credentials:true}) — any origin revokes any API key using victim admin session, disrupting CI/CD pipelines and production integrations that depend on the revoked key; fix: allowlist + requireSession + ownership check + audit log + notify skill ownerCORS65-001 — Credential-bearing CORS on API key list endpoint exposes live key values and scopes
Severity: CRITICAL
The API key list endpoint is configured with cors({origin:true,credentials:true}) applied at the router level, reflecting any Origin header as an allowed origin while setting Access-Control-Allow-Credentials: true. Any web page can issue a credentialed cross-origin request and receive the complete list of API keys for a skill, including live key values, assigned scopes, creation timestamps, and expiry dates.
API key management endpoints in a skill registry contain several tiers of sensitive data: key identifiers and creation metadata visible to auditing tools (low sensitivity), assigned scope strings that reveal which registry API surfaces the key can reach including admin-only operations (high sensitivity — reveals the access surface area of each integration), and the actual key values themselves (critical sensitivity — these are bearer credentials that authenticate against the registry API without requiring a user session). An attacker who reads this response receives ready-to-use API credentials that grant ongoing registry access beyond the duration of the victim's browser session. Keys with admin scope grant the same permissions as an administrative user, allowing the attacker to publish skills, modify registry configuration, and read private audit data using the exfiltrated key value alone, long after the victim has closed their browser.
router.use(cors({ origin: true, credentials: true }));
router.get('/:id/api-keys', requireSession, async (req, res) => {
const keys = await ApiKey.find({ skillId: req.params.id }).sort({ createdAt: -1 });
return res.json(keys); // exposes live key values, scopes, and expiry dates
});
const ALLOWED = process.env.ALLOWED_ORIGINS.split(',');
const keyCors = cors({ origin: ALLOWED, credentials: true });
router.get('/:id/api-keys', keyCors, requireSession, requireRole('admin'), async (req, res) => {
const keys = await ApiKey.find({ skillId: req.params.id, revokedAt: null })
.select('+keyId +scopes +createdAt +expiresAt -keyValue -keySecret')
.sort({ createdAt: -1 });
return res.json(keys.map(k => ({ keyId: k.keyId, scopes: k.scopes, createdAt: k.createdAt, expiresAt: k.expiresAt })));
});
The fix applies CORS on a per-route basis using an explicit allowlist from environment configuration. Raw key values and key secrets are excluded from the query projection and never returned in list responses regardless of caller role. Only the key identifier, assigned scopes, creation timestamp, and expiry date are returned, ensuring that even a compromised admin session reached via CORS cannot extract bearer credentials through the API key list endpoint.
CORS65-002 — Wildcard ACAO on API key creation endpoint enables persistent backdoor key injection
Severity: CRITICAL
The API key creation endpoint returns Access-Control-Allow-Origin: * regardless of requesting origin. The endpoint requires a valid session but no role boundary, no CSRF check, and no input validation schema. Any web page can submit a key creation request using the victim admin's session, with the attacker controlling the key name, assigned scopes, and expiry date.
An attacker who creates an API key with registry admin scope under a victim admin's identity obtains a persistent bearer credential that survives beyond the victim's browser session. Unlike session tokens that expire when the browser closes or when the registry invalidates the session, an API key with a future expiry date or no expiry ceiling remains valid until explicitly revoked. The attacker can use the created key to perform any administrative operation — publish skills, modify registry policy, read private audit logs, revoke other administrators' keys — without ever obtaining the victim's password or session token again. The created key appears in the victim's key list under a plausible name and timestamp, requiring active auditing to detect. Skills in registries that depend on audit log correlation between key-creation events and administrative actions will attribute the attacker's subsequent operations to the legitimate key holder.
router.post('/:id/api-keys', requireSession, async (req, res) => {
const { name, scopes, expiresAt } = req.body;
const keyValue = crypto.randomBytes(32).toString('hex');
const key = await ApiKey.create({
skillId: req.params.id, createdBy: req.session.userId,
name, scopes, expiresAt, keyValue,
});
return res.status(201).json({ keyId: key.id, keyValue });
});
const ApiKeySchema = z.object({
name: z.string().min(3).max(128),
scopes: z.array(z.enum(['read', 'write', 'publish', 'webhooks'])).min(1),
expiresAt: z.string().datetime().refine(v => new Date(v) > new Date(Date.now() + 3600_000), {
message: 'expiresAt must be at least 1 hour in the future',
}).optional(),
});
router.post('/:id/api-keys', keyCors, requireSession, requireRole('admin'), verifyCsrf,
async (req, res) => {
const parsed = ApiKeySchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid API key payload', issues: parsed.error.issues });
const keyValue = crypto.randomBytes(32).toString('hex');
const key = await ApiKey.create({ skillId: req.params.id, createdBy: req.session.userId, ...parsed.data, keyValue });
await AuditLog.create({ action: 'apikey.created', actorId: req.session.userId,
skillId: req.params.id, keyId: key.id, scopes: parsed.data.scopes,
origin: req.headers.origin, at: new Date() });
return res.status(201).json({ keyId: key.id, keyValue });
});
The fix removes the wildcard ACAO and applies the per-route allowlist cors middleware. The admin role requirement ensures that standard session users cannot create API keys on behalf of a skill. The Zod ApiKeySchema enforces that only the predefined scope values are assignable — there is no registry_admin or superuser scope reachable via this API. The audit log records the requesting origin alongside the assigned scopes, enabling post-incident attribution of keys created via cross-origin attack and rapid identification of the scope surface granted to the attacker-controlled key.
CORS65-003 — Timing oracle on API key usage endpoint identifies high-traffic integration targets
Severity: MEDIUM
The API key usage endpoint reflects the Origin header as Access-Control-Allow-Origin before the ownership check executes. This creates a timing oracle: the endpoint serves cached results for skills with recently active API keys in under 5 ms (from an in-memory usage cache updated on every key invocation), while skills with no recent key activity require a full database aggregation query that takes 25–60 ms. The latency difference is cross-origin-detectable without reading the response body — the browser measures round-trip time and determines whether the skill has active API keys in use from response time alone.
High-traffic API key activity clusters around specific deployment contexts: CI/CD pipelines that run on every commit and invoke the registry API dozens of times per hour, production services that use registry API keys to fetch skill metadata on every request, and monitoring integrations that poll registry endpoints continuously. These are exactly the integrations where valid API keys are most likely to be in-use and cached in the usage endpoint's hot path. An attacker who identifies skills with high API key traffic via timing oracle can prioritize CORS65-001 credential-bearing requests against those skills' admin sessions, knowing that live key values present in the response will immediately provide access to actively-exercised registry API surfaces with real-world coverage.
router.get('/:id/api-keys/usage', async (req, res) => {
res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*');
res.setHeader('Access-Control-Allow-Credentials', 'true');
const skill = await Skill.findById(req.params.id);
if (!skill || skill.ownerId !== req.session?.userId) return res.status(403).json({ error: 'Forbidden' });
const usage = apiKeyUsageCache.get(req.params.id) || await ApiKeyUsage.aggregate([{ $match: { skillId: req.params.id } }]);
return res.json(usage);
});
router.get('/:id/api-keys/usage', requireSession, async (req, res) => {
const start = Date.now();
const skill = await Skill.findOne({ _id: req.params.id, ownerId: req.session.userId });
if (!skill) { await sleep(Math.max(0, 60 - (Date.now() - start))); return res.status(404).json({ error: 'Not found' }); }
keyCors(req, res, async () => {
const usage = apiKeyUsageCache.get(req.params.id) || await ApiKeyUsage.aggregate([{ $match: { skillId: req.params.id } }]);
await sleep(Math.max(0, 60 - (Date.now() - start)));
return res.json(usage);
});
});
The fix performs authentication and ownership verification before any CORS headers are emitted. The 60ms constant-time floor applied to both the miss path (404) and the hit path (data returned) eliminates the cache-latency differential that enabled timing-based enumeration. The unified Skill.findOne query combines the existence check and the ownership check into a single database round-trip, ensuring that cache hits and misses produce indistinguishable response timings to cross-origin observers probing for high-traffic API key activity.
CORS65-004 — Credential-bearing CORS on API key revocation disrupts CI/CD pipelines
Severity: CRITICAL
The API key revocation endpoint shares the router-level cors({origin:true,credentials:true}) policy from CORS65-001. Any web page can issue a credentialed DELETE request using the victim admin's session. The endpoint performs no ownership check — any key ID can be revoked, not just keys belonging to the authenticated user's skills.
When an API key is revoked, every integration that uses that key immediately loses registry API access. CI/CD pipelines that use registry API keys to publish skills on every commit begin failing silently with 401 Unauthorized errors. Production services that use registry keys to fetch skill metadata return stale data or errors to end users. Monitoring integrations that depend on registry API access go dark, eliminating visibility into skill health metrics. The impact of key revocation is therefore not just an authentication disruption — it cascades into deployment failures, service degradation, and monitoring blindness across all integrations that depended on the revoked key. Because the revocation is performed with legitimate admin credentials through the standard revocation endpoint, the registry logs will attribute the action to the victim administrator. Without explicit cross-origin attribution logging, the incident appears as an accidental self-revocation rather than a cross-origin attack.
router.delete('/:id/api-keys/:keyId', requireSession, async (req, res) => {
await ApiKey.deleteOne({ _id: req.params.keyId });
return res.status(204).end();
});
router.delete('/:id/api-keys/:keyId', keyCors, requireSession, async (req, res) => {
const key = await ApiKey.findOne({ _id: req.params.keyId, skillId: req.params.id });
if (!key) return res.status(404).json({ error: 'API key not found' });
const isAdmin = req.session.role === 'admin';
const skill = await Skill.findOne({ _id: req.params.id, ownerId: req.session.userId });
const isOwner = !!skill;
if (!isAdmin && !isOwner) return res.status(403).json({ error: 'Forbidden' });
await key.updateOne({ revokedAt: new Date(), revokedBy: req.session.userId });
await AuditLog.create({ action: 'apikey.revoked', actorId: req.session.userId,
keyId: req.params.keyId, skillId: req.params.id, scopes: key.scopes,
origin: req.headers.origin, at: new Date() });
if (!isOwner) await notify(skill?.ownerId, { type: 'apikey.revoked',
keyId: req.params.keyId, skillId: req.params.id, by: req.session.userId });
return res.status(204).end();
});
The fix soft-deletes API keys by setting revokedAt rather than hard-deleting them, preserving the key audit trail and allowing forensic analysis of when and by whom each key was revoked. The ownership check ensures that revocation is restricted to the skill owner and to admin-role users. The notification mechanism alerts the skill owner when a third party revokes a key, enabling rapid detection of cross-origin revocation attacks before CI/CD pipelines begin failing. The audit log records the requesting origin alongside the key's scopes, enabling post-incident reconstruction of which integrations were disrupted by the revocation and attribution to the cross-origin attack rather than operator error.
Run SkillAudit to detect cors({origin:true,credentials:true}) on API key management endpoints, wildcard ACAO on key creation routes, and Origin reflection before auth in your MCP skill registry source code. Join the waitlist for access.