SA-SKL-CORS32 — CORS Misconfiguration
CORS misconfiguration in MCP skill registry organization settings and admin dashboard endpoints
SA-SKL-CORS32 documents four CORS vulnerabilities discovered across the organization management surface of an MCP skill registry. Two critical findings exploit credential-bearing origin reflection to read SSO configuration, billing contacts, and live dashboard metrics using a victim admin's browser session. Two high-severity findings expose all org member emails via a wildcard Access-Control-Allow-Origin header and leak organizational structure through a pre-auth timing oracle on the admin activity log endpoint.
GET /api/org/settings reflects Origin with credentials enabled, exposing full org settings including SSO config and SAML entityId to any cross-origin attacker page
GET /api/org/members responds with Access-Control-Allow-Origin: * on an authenticated endpoint, exposing all member emails, roles, and last-active timestamps cross-origin
GET /api/admin/activity reflects Origin before performing a role check, creating a timing oracle that reveals whether an organization has an admin user to any unauthenticated origin
GET /api/org/dashboard reflects Origin with credentials enabled, leaking active user counts, monthly audit totals, and skill vulnerability trend data cross-origin via victim admin session
CORS32-001: Origin reflection with credentials on org settings endpoint
The organization settings endpoint GET /api/org/settings is configured with Express's cors() middleware using {origin: true, credentials: true}. The origin: true option instructs the middleware to reflect whatever value arrives in the request's Origin header back as Access-Control-Allow-Origin. Combined with Access-Control-Allow-Credentials: true, this means any website that can induce an authenticated admin to load a page can read the full org settings payload using the admin's existing browser session cookie — no token theft required.
The settings payload returned by this endpoint includes highly sensitive fields: the SAML entityId and SSO provider metadata URL, the billing contact email address, the org's audit retention policy, and all configured webhook destinations. An attacker operating a malicious site performs a simple cross-origin fetch with credentials: 'include', receives a 200 with the full JSON body, and can exfiltrate the SSO configuration to mount a SAML relay attack or redirect billing contact email to a controlled address. Because the allowlist is effectively the entire internet, there is no CORS protection at all.
// VULNERABLE — cors32-001
// routes/org.js
const cors = require('cors');
const { requireAuth } = require('../middleware/auth');
// origin:true reflects any Origin header back as ACAO
// credentials:true allows cross-origin reads with session cookies
router.get('/api/org/settings', cors({ origin: true, credentials: true }), requireAuth, async (req, res) => {
const org = await db.orgs.findById(req.user.orgId);
res.json({
ssoProvider: org.ssoProvider,
samlEntityId: org.samlEntityId, // SSO config exposed
samlMetadataUrl: org.samlMetadataUrl,
billingEmail: org.billingEmail, // billing contact exposed
webhookDestinations: org.webhooks,
auditRetentionDays: org.retentionDays,
});
});
Fix CORS32-001: Replace origin: true with an explicit Set-based allowlist containing only your first-party dashboard origins. The settings endpoint must also enforce an admin role check — requireAuth alone is insufficient since any org member can read SSO config. Rotate any SSO metadata URLs or billing contacts that may have been read by an unauthorized party before remediation.
// FIXED — cors32-001
// routes/org.js
const cors = require('cors');
const { requireAuth, requireRole } = require('../middleware/auth');
const ALLOWED_ORIGINS = new Set([
'https://app.skillaudit.dev',
'https://admin.skillaudit.dev',
]);
const strictCors = cors({
origin: (origin, cb) => {
if (!origin || ALLOWED_ORIGINS.has(origin)) return cb(null, true);
cb(new Error('Origin not allowed'));
},
credentials: true,
});
router.get('/api/org/settings', strictCors, requireAuth, requireRole('admin'), async (req, res) => {
const org = await db.orgs.findById(req.user.orgId);
res.json({
ssoProvider: org.ssoProvider,
samlEntityId: org.samlEntityId,
samlMetadataUrl: org.samlMetadataUrl,
billingEmail: org.billingEmail,
webhookDestinations: org.webhooks,
auditRetentionDays: org.retentionDays,
});
});
CORS32-002: Wildcard ACAO on authenticated member list endpoint
The member management endpoint GET /api/org/members returns a paginated list of every member in an organization, including their email address, assigned role, and lastActiveAt timestamp. The endpoint requires authentication — requests without a valid session cookie receive a 401 — but it sets Access-Control-Allow-Origin: * unconditionally. This configuration is internally contradictory: the browser specification prohibits sending credentials on wildcard-ACAO requests, yet the response body is still readable if the attacker can arrange for the victim to be the one sending the credentialed request.
In practice, the attack surface is narrower than CORS32-001 but still consequential. An attacker who can load a page in the victim's browser — through a phishing link, a stored XSS on a third-party site the victim uses, or a compromised browser extension — can issue the fetch and receive the full member roster. The member email list enables targeted spear-phishing of high-privilege accounts, and the role metadata identifies which accounts to target. The lastActiveAt field reveals organizational activity patterns. Additionally, some older browsers and non-browser HTTP clients do not enforce the credentials-plus-wildcard prohibition, leaving a secondary attack path open.
// VULNERABLE — cors32-002
// routes/org.js
const { requireAuth } = require('../middleware/auth');
router.get('/api/org/members', requireAuth, async (req, res) => {
// Wildcard ACAO set unconditionally — authenticated endpoint
// cannot safely use * because response body is sensitive
res.setHeader('Access-Control-Allow-Origin', '*');
const members = await db.orgMembers.findAll({
where: { orgId: req.user.orgId },
attributes: ['email', 'role', 'lastActiveAt'],
});
res.json({ members, total: members.length });
});
Fix CORS32-002: An authenticated endpoint that returns user-specific data must never use a wildcard Access-Control-Allow-Origin. Apply the same explicit origin allowlist used in CORS32-001 and pair it with Access-Control-Allow-Credentials: true. If the endpoint must be accessible from multiple first-party apps, enumerate each allowed origin explicitly in a Set and reflect only validated origins.
// FIXED — cors32-002
// routes/org.js
const cors = require('cors');
const { requireAuth } = require('../middleware/auth');
const ALLOWED_ORIGINS = new Set([
'https://app.skillaudit.dev',
'https://admin.skillaudit.dev',
]);
const strictCors = cors({
origin: (origin, cb) => {
if (!origin || ALLOWED_ORIGINS.has(origin)) return cb(null, true);
cb(new Error('Origin not allowed'));
},
credentials: true,
});
router.get('/api/org/members', strictCors, requireAuth, async (req, res) => {
const members = await db.orgMembers.findAll({
where: { orgId: req.user.orgId },
attributes: ['email', 'role', 'lastActiveAt'],
});
res.json({ members, total: members.length });
});
CORS32-003: Timing oracle via Origin reflection before role check on activity log
The admin activity log endpoint GET /api/admin/activity emits a reflected Access-Control-Allow-Origin header as its very first action, before any authentication or authorization check runs. When a request arrives from an unauthorized user, the server still writes the CORS header, processes the role check, and then returns a 403. When the endpoint does not exist for a given organization — meaning the organization has no admin user and therefore no activity log — the server takes a slightly different code path that returns a 404 without the CORS header. A cross-origin attacker can distinguish these two responses by measuring response time and observing whether the CORS header is present in the preflight response.
The practical impact is an unauthenticated enumeration oracle: given only an org identifier (often present in public registry metadata), an attacker can determine whether an organization has at least one admin user. This information refines targeted phishing campaigns — organizations confirmed to have admins are higher-value targets — and in multi-tenant MCP registry deployments can be used to map the administrative surface of the entire platform. The root cause is middleware ordering: CORS header emission should never precede authentication, and the absence or presence of CORS headers should be constant regardless of whether the route exists.
// VULNERABLE — cors32-003
// routes/admin.js
router.get('/api/admin/activity', (req, res, next) => {
// Origin reflected BEFORE auth check — timing oracle
const origin = req.headers['origin'];
if (origin) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
}
next();
}, requireAuth, requireRole('admin'), async (req, res) => {
// 404 path (no admin user) skips the CORS header emission above
// because this handler is not reached — detectable cross-origin
const logs = await db.activityLogs.findAll({ where: { orgId: req.user.orgId } });
if (!logs.length) return res.status(404).json({ error: 'No activity log' });
res.json({ logs });
});
Fix CORS32-003: Move the role check to run before any CORS header is emitted. Apply CORS middleware globally at the router level after authentication, not per-route before it. Ensure that 404 responses on routes that follow a role check are indistinguishable in timing and header structure from 403 responses — both should emit the same CORS headers and use a constant-time response path so no cross-origin timing signal leaks organizational structure.
// FIXED — cors32-003
// routes/admin.js
const cors = require('cors');
const { requireAuth, requireRole } = require('../middleware/auth');
const ALLOWED_ORIGINS = new Set([
'https://app.skillaudit.dev',
'https://admin.skillaudit.dev',
]);
const strictCors = cors({
origin: (origin, cb) => {
if (!origin || ALLOWED_ORIGINS.has(origin)) return cb(null, true);
cb(new Error('Origin not allowed'));
},
credentials: true,
});
// Auth and role checks run first; CORS headers emitted after, uniformly
router.get('/api/admin/activity',
requireAuth,
requireRole('admin'),
strictCors,
async (req, res) => {
const logs = await db.activityLogs.findAll({ where: { orgId: req.user.orgId } });
// Always 200 with empty array rather than 404 — no structural oracle
res.json({ logs });
}
);
CORS32-004: Origin reflection with credentials on dashboard metrics endpoint
The organization dashboard endpoint GET /api/org/dashboard aggregates and returns several operational metrics: active user count for the past 30 days, total monthly audit runs, a breakdown of skill vulnerability findings by category, and a trend line of new critical findings over time. Like CORS32-001, this endpoint is configured with cors({origin: true, credentials: true}), which reflects any Origin header back as Access-Control-Allow-Origin while also permitting credentialed cross-origin reads. Any website can read the full metrics payload from a logged-in admin's browser session.
The metrics exposed by this endpoint have significant intelligence value. The active user count and audit frequency reveal the organization's operational tempo. The vulnerability trend data exposes which categories of MCP skill vulnerabilities the organization is actively tracking — information that helps an attacker prioritize which vulnerability classes are most likely to be unpatched in that organization's deployed skills. The credential-bearing CORS misconfiguration is identical in mechanism to CORS32-001 but affects a different endpoint class. Organizations that patched CORS32-001 without auditing all endpoints that use origin: true remain fully exposed through CORS32-004.
// VULNERABLE — cors32-004
// routes/org.js
const cors = require('cors');
const { requireAuth } = require('../middleware/auth');
// Same origin:true + credentials:true antipattern as CORS32-001
// Any origin can read full dashboard metrics via victim admin session
router.get('/api/org/dashboard', cors({ origin: true, credentials: true }), requireAuth, async (req, res) => {
const orgId = req.user.orgId;
const [activeUsers, monthlyAudits, vulnTrends] = await Promise.all([
db.sessions.countActiveUsers(orgId, 30),
db.audits.countMonthly(orgId),
db.findings.getVulnTrends(orgId),
]);
res.json({ activeUsers, monthlyAudits, vulnTrends });
});
Fix CORS32-004: Replace origin: true with the same explicit Set-based allowlist applied to CORS32-001 and CORS32-002. Audit every route that uses cors() middleware to identify all instances of origin: true or origin: (o, cb) => cb(null, true) and replace them with allowlist validation. Additionally, consider whether aggregate statistics like active user count need to be gated behind an admin role or whether they can be safely served without credentials to reduce the credential-bearing CORS surface.
// FIXED — cors32-004
// routes/org.js
const cors = require('cors');
const { requireAuth, requireRole } = require('../middleware/auth');
const ALLOWED_ORIGINS = new Set([
'https://app.skillaudit.dev',
'https://admin.skillaudit.dev',
]);
const strictCors = cors({
origin: (origin, cb) => {
if (!origin || ALLOWED_ORIGINS.has(origin)) return cb(null, true);
cb(new Error('Origin not allowed'));
},
credentials: true,
});
router.get('/api/org/dashboard', strictCors, requireAuth, requireRole('admin'), async (req, res) => {
const orgId = req.user.orgId;
const [activeUsers, monthlyAudits, vulnTrends] = await Promise.all([
db.sessions.countActiveUsers(orgId, 30),
db.audits.countMonthly(orgId),
db.findings.getVulnTrends(orgId),
]);
res.json({ activeUsers, monthlyAudits, vulnTrends });
});
Compound attack chain
An attacker who can induce a victim org admin to visit a single malicious page can chain all four findings into a comprehensive org takeover. The malicious page opens by exploiting CORS32-004 to read the dashboard metrics and confirm the target organization is active. It then exploits CORS32-001 to extract the SAML entityId and SSO metadata URL, which it uses to craft a SAML assertion replay attack against the identity provider. Simultaneously it exploits CORS32-002 to retrieve the full member roster with emails and roles, identifying other admin-role accounts. CORS32-003 is used in the reconnaissance phase before any authenticated access — the attacker can enumerate which org identifiers in the MCP registry have admin users to build a target list, then send phishing emails to the billing contacts harvested from CORS32-001 to maximize the probability of a victim admin clicking the malicious link. The combined chain moves from unauthenticated enumeration through credential-free SSO bypass to full organizational takeover without ever needing to compromise an authentication token directly.
Detection with SkillAudit tree-sitter queries
; Detect cors() calls with origin:true (reflects all origins)
(call_expression
function: (identifier) @fn (#eq? @fn "cors")
arguments: (arguments
(object
(pair
key: [(property_identifier)(string)] @key (#match? @key "^origin$")
value: (true) @val))))
; Detect res.setHeader calls setting ACAO before requireAuth/requireRole middleware
(call_expression
function: (member_expression
object: (identifier) @obj (#eq? @obj "res")
property: (property_identifier) @prop (#eq? @prop "setHeader"))
arguments: (arguments
(string (string_fragment) @header
(#eq? @header "Access-Control-Allow-Origin"))
[(identifier)(member_expression)] @origin_val))
Summary
| ID | Severity | Endpoint | Root cause | Fix |
|---|---|---|---|---|
| CORS32-001 | Critical | GET /api/org/settings |
cors({origin:true,credentials:true}) reflects all origins; SSO config and billing email readable cross-origin |
Explicit Set-based allowlist; add requireRole('admin') before handler |
| CORS32-002 | High | GET /api/org/members |
Unconditional ACAO: * on authenticated endpoint exposes all member emails and roles cross-origin |
Remove wildcard; apply explicit allowlist with credentials: true |
| CORS32-003 | High | GET /api/admin/activity |
Origin reflected before role check; 404 vs 403 response delta leaks org admin existence |
Role check before CORS emission; constant-time 200 with empty array instead of 404 |
| CORS32-004 | Critical | GET /api/org/dashboard |
cors({origin:true,credentials:true}) exposes active users, audit counts, and vuln trends cross-origin |
Explicit Set-based allowlist; add requireRole('admin') before handler |
Run a free SkillAudit scan on any public MCP skill repository at skillaudit.dev. Reports include CORS misconfiguration checks alongside SSRF, injection, privilege escalation, and 40+ other categories.