Claude MCP skill CORS misconfiguration — reporting and analytics endpoints — SA-SKL-CORS24
Reporting and analytics APIs are among the highest-value targets for cross-origin data theft: they aggregate sensitive findings, source code snippets, usage patterns, and organizational metadata into single API responses. SA-SKL-CORS24 covers four CORS misconfiguration patterns in MCP skill registry reporting and analytics endpoints — a credential-reflecting wildcard origin that hands attackers a victim's full audit report, a public analytics endpoint that exposes internal engineering metrics, a CDN caching interaction that turns a benign wildcard into a credentialed cross-origin read, and a multi-tenant IDOR where the CORS policy is derived from the wrong organization.
GET /api/reports/:id has CORS middleware configured as origin: true (reflect any origin) with credentials: true — attacker page fetches victim's private audit reports cross-origin using the victim's session cookie; the report contains full static analysis output including source code snippets, file trees, and dependency graphsGET /api/analytics/usage returns Access-Control-Allow-Origin: * — any origin can read aggregated usage statistics; the endpoint leaks total audit counts per org, feature usage breakdown, and internal metric names used in engineering discussionsGET /api/reports/:id/export?format=csv has Access-Control-Allow-Origin: * without Vary: Origin — CDN caches the wildcard ACAO header on a public response and then serves that cached header on a subsequent credentialed request, enabling a cross-origin attacker to read the credentialed response bodycorsAllowedOrigins array rather than the report owner's org — attacker with a free-tier API key patches their own CORS config to include https://attacker.com then reads reports owned by any other org cross-originBackground: why reporting endpoints attract CORS attacks
CORS misconfiguration is well understood at the authentication and account endpoints level, but developers often apply looser policies to reporting and analytics APIs under the assumption that the data is "just logs." In an MCP skill registry context, audit reports are extremely sensitive: they contain static analysis findings, excerpted source code from scanned skills, resolved dependency trees, and security scores that may not be shared publicly. An attacker who can read a victim's audit report gains a detailed map of the victim's codebase structure and known vulnerabilities — a significant advantage for follow-on attacks.
The four SA-SKL-CORS24 findings each exploit a different failure in the CORS policy decision. CORS24-001 is the classic origin: true + credentials: true combination that the CORS specification explicitly prohibits the browser from honoring, yet many CORS middleware implementations permit. CORS24-002 and CORS24-003 share the wildcard root cause but differ in severity: CORS24-002 is a direct information leak, while CORS24-003 is an indirect cache poisoning attack that creates a credentialed read window. CORS24-004 is a logic error in multi-tenant CORS policy derivation that amounts to a CORS-based IDOR.
Related patterns: SA-SKL-CORS23 (webhook and event stream CORS), SA-SKL-CORS22 (admin panel CORS), SA-SKL-AUTH16 (broken authentication on report access).
CORS24-001 — CRITICAL — origin:true with credentials:true reflects any origin on audit report endpoint
The audit report retrieval endpoint uses the cors npm middleware with { origin: true, credentials: true }. The origin: true option instructs the middleware to reflect the value of the incoming Origin request header back as the Access-Control-Allow-Origin response header — effectively granting any origin access. Combined with credentials: true, the response also includes Access-Control-Allow-Credentials: true. The CORS specification requires browsers to block credentialed cross-origin requests when ACAO is a wildcard, but reflecting the attacker's origin bypasses this safeguard: the browser sees a specific matching origin and allows the credentialed response to be read by the attacker's page.
An attacker hosts a page at https://attacker.com/steal.html that sends fetch('https://api.skillaudit.dev/api/reports/TARGET_REPORT_ID', { credentials: 'include' }). The browser attaches the victim's session cookie, the server reflects Origin: https://attacker.com back as ACAO: https://attacker.com plus ACAC: true, and the browser allows the attacker's JavaScript to read the full response body — the complete audit report including source code snippets and the security finding list.
The fix is to replace origin: true with an explicit allowlist array of known frontend origins. The allowlist must be maintained as a configuration value and never accept arbitrary request-supplied origins. Attempting to validate the origin with a regex that permits subdomains (e.g., /skillaudit\.dev$/) is insufficient — an attacker can register evilskillaudit.dev; use === equality against each member of the allowlist.
// VULNERABLE — CORS24-001
// middleware/cors.js
const cors = require('cors');
// BUG: origin: true reflects any Origin header back as ACAO
// Combined with credentials: true this grants cross-origin credentialed read
// to any page on the internet — attacker steals victim's session-authenticated reports
app.use('/api/reports', cors({
origin: true, // reflects Origin header verbatim
credentials: true, // adds Access-Control-Allow-Credentials: true
methods: ['GET', 'HEAD'],
}));
app.get('/api/reports/:id', authenticate, async (req, res) => {
const report = await Report.findOne({
_id: req.params.id,
orgId: req.user.orgId,
});
if (!report) return res.status(404).json({ error: 'Not found' });
res.json(report); // full report including source code snippets
});
// FIXED — CORS24-001
// middleware/cors.js
const cors = require('cors');
// Explicit allowlist — never use origin: true with credentials: true
const ALLOWED_ORIGINS = [
'https://app.skillaudit.dev',
'https://skillaudit.dev',
// Add staging origin only in non-production environments
...(process.env.NODE_ENV !== 'production'
? ['https://staging.skillaudit.dev']
: []),
];
function originAllowlist(origin, callback) {
// No origin header = same-origin or non-browser request (curl, Postman)
// Allow through — authentication middleware will enforce access control
if (!origin) return callback(null, true);
if (ALLOWED_ORIGINS.includes(origin)) {
return callback(null, true);
}
// Log rejected origin for monitoring
logger.warn('CORS24-001: rejected origin', { origin });
return callback(new Error(`CORS: origin not allowed: ${origin}`));
}
app.use('/api/reports', cors({
origin: originAllowlist, // explicit allowlist — never origin: true
credentials: true,
methods: ['GET', 'HEAD'],
allowedHeaders: ['Content-Type', 'Authorization'],
}));
app.get('/api/reports/:id', authenticate, async (req, res) => {
const report = await Report.findOne({
_id: req.params.id,
orgId: req.user.orgId,
});
if (!report) return res.status(404).json({ error: 'Not found' });
res.json(report);
});
CORS24-001 impact: Complete cross-origin read of any audit report the victim has access to, including source code excerpts, finding details, dependency graphs, and file trees. The attack requires only that the victim visits the attacker's page while authenticated. No phishing of credentials is needed — the browser's cookie jar does the work. SkillAudit detects this by scanning all cors() middleware invocations for origin: true or origin: (req, cb) => cb(null, true) combined with credentials: true, and flags any such combination as CORS24-001 regardless of the specific route it is applied to.
CORS24-002 — HIGH — Wildcard ACAO on analytics endpoint leaks org usage metrics
The analytics dashboard API endpoint returns aggregated usage statistics for an organization: total audits run, breakdown of findings by severity, feature usage counts, API call volumes, and internal metric names like audit.deepScan.invocations and report.export.pdf.count. The endpoint is protected by an API key but returns Access-Control-Allow-Origin: * unconditionally. Wildcard ACAO means any page on the internet can send a cross-origin request to the endpoint and read the response body — no credentials are needed because the response is keyed to the API key in the query string or Authorization header, not to a session cookie.
The concrete attack scenario: a victim engineer visits a compromised third-party site while logged into the SkillAudit dashboard in another tab. The compromised page has the victim's API key (obtained via phishing or a previous XSS). It sends fetch('/api/analytics/usage?apiKey=VICTIM_KEY'); the wildcard ACAO lets the attacker's JavaScript read the response and exfiltrate the org's audit cadence, security posture trends, and internal metric names that reveal product development priorities.
Even without a stolen API key, the endpoint leaking internal metric names is a medium-severity information disclosure: metric names like audit.deepScan.betaFeature.invocations reveal upcoming product features that may be competitively sensitive. Private analytics endpoints must require credentials and use an explicit origin allowlist — wildcard ACAO is appropriate only for endpoints that are intentionally public and contain no sensitive data.
// VULNERABLE — CORS24-002
// routes/analytics.js
// BUG: wildcard ACAO on a private analytics endpoint
// Any origin can read the response — leaks org metrics and internal metric names
app.use('/api/analytics', (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Authorization, Content-Type');
if (req.method === 'OPTIONS') return res.sendStatus(204);
next();
});
app.get('/api/analytics/usage', authenticateApiKey, async (req, res) => {
const stats = await Analytics.getOrgStats(req.apiKey.orgId);
// stats contains: auditCount, findingBreakdown, featureUsage, internalMetrics
res.json(stats);
});
// FIXED — CORS24-002
// routes/analytics.js
const cors = require('cors');
// Private analytics: require credentials + explicit origin allowlist
// Never use wildcard on endpoints that return org-scoped or sensitive data
const ALLOWED_ORIGINS = [
'https://app.skillaudit.dev',
'https://skillaudit.dev',
];
app.use('/api/analytics', cors({
origin: (origin, cb) => {
// Reject requests from unlisted origins; allow no-origin (server-to-server)
if (!origin || ALLOWED_ORIGINS.includes(origin)) return cb(null, true);
logger.warn('CORS24-002: rejected origin on analytics endpoint', { origin });
return cb(new Error('CORS: origin not allowed'));
},
credentials: true,
methods: ['GET', 'OPTIONS'],
allowedHeaders: ['Authorization', 'Content-Type'],
}));
app.get('/api/analytics/usage', authenticateApiKey, async (req, res) => {
const stats = await Analytics.getOrgStats(req.apiKey.orgId);
// Set Cache-Control: private so CDNs and shared caches cannot serve this response
// to other users — defense-in-depth complementing the CORS fix
res.setHeader('Cache-Control', 'private, no-store');
res.json(stats);
});
CORS24-002 impact: Cross-origin read of organizational usage statistics including total audit counts, feature engagement breakdown, and internal metric names. Even without a stolen API key, the internal metric names constitute an information disclosure that may reveal unreleased product features or internal tooling. With a compromised API key the attacker reads the full analytics payload cross-origin without requiring any user interaction beyond page load. SkillAudit flags any route that sets Access-Control-Allow-Origin: * and also invokes an authentication middleware (authenticateApiKey, authenticate, requireAuth), since the combination indicates a private endpoint incorrectly treated as a public one.
CORS24-003 — HIGH — Missing Vary:Origin on export endpoint causes CDN to serve wildcard ACAO on credentialed request
The report export endpoint at GET /api/reports/:id/export?format=csv returns Access-Control-Allow-Origin: *. Per the CORS specification, browsers do not send cookies or Authorization headers on requests to wildcard ACAO endpoints — so the endpoint itself is not directly exploitable for a credentialed cross-origin read. However, the endpoint is served behind a CDN (CloudFront, Fastly, or similar) and does not include a Vary: Origin response header.
The attack proceeds in two stages. First, an unauthenticated request to the export URL causes the CDN to cache the response (including Access-Control-Allow-Origin: *). Second, a victim makes a credentialed request to the same export URL with the same cache key (same path and query string). The CDN serves the cached response — including the cached Access-Control-Allow-Origin: * header — for the credentialed response body. An attacker page then fetches the same URL without credentials; the browser sees ACAO: * in a response whose body was generated for the authenticated victim, and allows the attacker to read the victim's export data. This is a CDN cache poisoning attack via absent Vary: Origin.
The fix has three components: (1) replace the wildcard with an explicit origin allowlist so the ACAO header is computed per-origin; (2) add Vary: Origin to all CORS responses so CDNs cache separate responses per requesting origin; (3) add Cache-Control: private, no-store so CDNs do not cache authenticated export responses at all. All three are needed: the allowlist prevents the initial wildcard header; Vary: Origin prevents CDN collapsing of responses across origins; Cache-Control: private is the belt-and-suspenders that prevents caching of credentialed export responses regardless of CORS configuration.
// VULNERABLE — CORS24-003
// routes/reports-export.js
// BUG 1: wildcard ACAO on an authenticated endpoint
// BUG 2: no Vary: Origin — CDN caches the same ACAO:* header
// across both unauthenticated and authenticated responses
// Attack: CDN caches ACAO:* on first request; attacker reads victim's
// authenticated export data via the CDN-served cached response
app.get('/api/reports/:id/export', authenticate, async (req, res) => {
const report = await Report.findOne({
_id: req.params.id,
orgId: req.user.orgId,
});
if (!report) return res.status(404).json({ error: 'Not found' });
const format = req.query.format || 'csv';
const data = await ExportService.generate(report, format);
res.setHeader('Access-Control-Allow-Origin', '*'); // BUG 1: wildcard
// BUG 2: no Vary: Origin header — CDN uses path as sole cache key
res.setHeader('Content-Type', format === 'pdf' ? 'application/pdf' : 'text/csv');
res.setHeader('Content-Disposition', `attachment; filename="report-${report._id}.${format}"`);
res.send(data);
});
// FIXED — CORS24-003
// routes/reports-export.js
const cors = require('cors');
const ALLOWED_ORIGINS = [
'https://app.skillaudit.dev',
'https://skillaudit.dev',
];
// Apply CORS middleware explicitly on this route
app.get('/api/reports/:id/export', cors({
origin: (origin, cb) => {
if (!origin || ALLOWED_ORIGINS.includes(origin)) return cb(null, true);
return cb(new Error('CORS: origin not allowed'));
},
credentials: true,
methods: ['GET'],
// cors() automatically adds Vary: Origin when origin is a function or array
// Verify this in integration tests: assert 'Origin' in Vary header
}), authenticate, async (req, res) => {
const report = await Report.findOne({
_id: req.params.id,
orgId: req.user.orgId,
});
if (!report) return res.status(404).json({ error: 'Not found' });
const format = req.query.format || 'csv';
const data = await ExportService.generate(report, format);
// Cache-Control: private prevents CDN from caching credentialed responses
// no-store prevents any caching tier (CDN, browser) from storing the export
res.setHeader('Cache-Control', 'private, no-store');
// Vary: Origin ensures CDN caches separate responses per requesting origin
// cors() sets this automatically, but set explicitly for defense-in-depth
res.setHeader('Vary', 'Origin');
res.setHeader('Content-Type', format === 'pdf' ? 'application/pdf' : 'text/csv');
res.setHeader('Content-Disposition', `attachment; filename="report-${report._id}.${format}"`);
res.send(data);
});
CORS24-003 impact: An attacker can read the full CSV or PDF export of any report whose CDN-cached ACAO: * entry has been poisoned. The attack does not require any user interaction beyond the victim visiting a URL — the CDN poisoning step can be pre-executed by the attacker. The exported data includes every finding, severity score, affected file path, and code snippet from the audit. SkillAudit detects this by identifying route handlers that set Access-Control-Allow-Origin: * without a corresponding Vary: Origin header, and cross-references with CDN configuration files (CloudFront distribution config, Fastly VCL) to determine whether the response is cached.
CORS24-004 — MEDIUM — Tenant CORS config IDOR: CORS policy derived from requester's org rather than report owner's org
The multi-tenant reporting API dynamically derives its CORS policy by loading the requesting organization's corsAllowedOrigins array from the database and passing it to the cors() middleware. The intent is to allow each org to configure the frontend origins that may access their reports. The flaw is that the middleware uses the requester's org identity to look up the CORS config, rather than the report owner's org identity. If a report at /api/reports/VICTIM_REPORT_ID is owned by org A, but org B makes a cross-origin request to that endpoint, the CORS policy applied is org B's config, not org A's.
An attacker with a valid free-tier account (org B) sends PATCH /api/orgs/ATTACKER_ORG_ID/settings with {"corsAllowedOrigins": ["https://attacker.com"]} using their own org's API key. The PATCH succeeds because the attacker is an admin of their own org. Now the attacker's page at https://attacker.com sends a cross-origin fetch to /api/reports/VICTIM_REPORT_ID (a report owned by org A). The middleware looks up the requester's org (org B) CORS config, finds https://attacker.com in the allowlist, and returns ACAO: https://attacker.com. The attacker's page reads the response — which is org A's private report — without any interaction from org A.
The fix requires deriving the CORS policy from the report owner's org, not the requester's org. Additionally, the PATCH /api/orgs/:id/settings endpoint must require admin role and must validate each domain in corsAllowedOrigins against a list of verified domains that the org has proven ownership of (via DNS TXT record or HTTP challenge), to prevent an attacker from registering arbitrary domains in the allowlist.
// VULNERABLE — CORS24-004
// middleware/tenant-cors.js
async function tenantCorsMiddleware(req, res, next) {
// BUG: looks up CORS config using the requester's identity (from API key)
// The requester may not own the resource being accessed
const requestingOrg = await Org.findById(req.apiKey.orgId);
if (!requestingOrg) return next(new Error('Org not found'));
// Attacker PATCH /api/orgs/ATTACKER_ORG/settings with:
// { "corsAllowedOrigins": ["https://attacker.com"] }
// Now all requests authenticated with attacker's API key get ACAO: https://attacker.com
// — even requests to reports owned by OTHER orgs
const allowedOrigins = requestingOrg.corsAllowedOrigins || [];
cors({ origin: allowedOrigins, credentials: true })(req, res, next);
}
app.get('/api/reports/:id', authenticateApiKey, tenantCorsMiddleware, async (req, res) => {
// Authorization check: report must belong to the requesting org
const report = await Report.findOne({
_id: req.params.id,
orgId: req.apiKey.orgId,
});
if (!report) return res.status(404).json({ error: 'Not found' });
res.json(report);
});
// BUG: PATCH allows any org admin to set arbitrary corsAllowedOrigins
// No domain verification, no origin format validation
app.patch('/api/orgs/:id/settings', authenticateApiKey, async (req, res) => {
const org = await Org.findOneAndUpdate(
{ _id: req.params.id, ownerId: req.apiKey.userId },
{ $set: req.body }, // BUG: merges entire request body into org document
{ new: true }
);
res.json(org);
});
// FIXED — CORS24-004
// middleware/tenant-cors.js
// Valid origin pattern: https://[subdomain.]example.com (no wildcards, no IP)
const ORIGIN_RE = /^https:\/\/([a-z0-9-]+\.)*[a-z0-9-]+\.[a-z]{2,}$/i;
async function tenantCorsMiddleware(req, res, next) {
// Determine the resource owner — look up the report's org, not the requester's org
let ownerOrgId;
try {
const report = await Report.findOne(
{ _id: req.params.id },
{ orgId: 1 } // projection: only need the orgId for CORS derivation
);
if (!report) {
// Resource not found — apply default restrictive CORS policy (no ACAO header)
// The 404 from the main handler below will terminate the request
return next();
}
ownerOrgId = report.orgId;
} catch (err) {
return next(err);
}
// Derive CORS policy from the report OWNER's org, not the requester's org
const ownerOrg = await Org.findById(ownerOrgId);
if (!ownerOrg) return next();
const allowedOrigins = (ownerOrg.corsAllowedOrigins || []).filter(o => ORIGIN_RE.test(o));
cors({ origin: allowedOrigins, credentials: true })(req, res, next);
}
app.get('/api/reports/:id', authenticateApiKey, tenantCorsMiddleware, async (req, res) => {
const report = await Report.findOne({
_id: req.params.id,
orgId: req.apiKey.orgId, // requester must own the report
});
if (!report) return res.status(404).json({ error: 'Not found' });
res.json(report);
});
// FIXED: PATCH requires admin role, validates each origin, requires domain verification
app.patch('/api/orgs/:id/settings', authenticateApiKey, requireRole('admin'), async (req, res) => {
// Only allow updating specific fields — never merge req.body wholesale
const { corsAllowedOrigins } = req.body;
if (corsAllowedOrigins !== undefined) {
if (!Array.isArray(corsAllowedOrigins)) {
return res.status(400).json({ error: 'corsAllowedOrigins must be an array' });
}
for (const origin of corsAllowedOrigins) {
if (!ORIGIN_RE.test(origin)) {
return res.status(400).json({ error: `Invalid origin format: ${origin}` });
}
// Require domain ownership verification before adding to allowlist
const verified = await DomainVerification.isVerified(req.apiKey.orgId, origin);
if (!verified) {
return res.status(400).json({
error: `Domain not verified for this org: ${origin}. Complete DNS verification first.`,
});
}
}
}
const org = await Org.findOneAndUpdate(
{ _id: req.params.id, ownerId: req.apiKey.userId },
{ $set: { corsAllowedOrigins } }, // only update the specific field
{ new: true, runValidators: true }
);
res.json({ id: org._id, corsAllowedOrigins: org.corsAllowedOrigins });
});
CORS24-004 impact: An attacker with any valid free-tier API key can read reports belonging to any organization by updating their own org's CORS config and making a cross-origin request with an API key that has access to the target report. This is a CORS-layer IDOR: the CORS policy is derived from the wrong identity principal. The exploit requires a single PATCH request to self and one cross-origin fetch — no brute force, no race condition. SkillAudit detects this by modeling the data flow from CORS policy derivation back to the resource ownership check; if the org used for CORS lookup differs from the org used for authorization, it flags the discrepancy as CORS24-004.
Detection with SkillAudit
SkillAudit's static analysis module scans CORS configuration code for all four SA-SKL-CORS24 patterns using AST-based data flow analysis. For CORS24-001, it detects any cors() call with both origin: true (or any equivalent function that always returns true) and credentials: true. For CORS24-002, it identifies routes that set Access-Control-Allow-Origin: * and also apply authentication middleware. For CORS24-003, it detects ACAO: * responses that lack a corresponding Vary: Origin header, then cross-references CDN configuration to confirm the route is cached. For CORS24-004, it models the organization identity used for CORS derivation versus the organization identity used for resource ownership enforcement, and flags mismatches.
| Finding | Severity | Root cause | Fix |
|---|---|---|---|
| CORS24-001 | CRITICAL | origin:true reflects any Origin; combined with credentials:true enables full credentialed cross-origin read | Explicit allowlist array in cors() options; never combine origin:true with credentials:true |
| CORS24-002 | HIGH | Wildcard ACAO on private analytics endpoint leaks org metrics and internal metric names | Credentials+allowlist CORS on private endpoints; Cache-Control: private, no-store |
| CORS24-003 | HIGH | Wildcard ACAO without Vary:Origin; CDN caches header and serves it on credentialed response | Allowlist CORS + Vary:Origin + Cache-Control:private,no-store on all export endpoints |
| CORS24-004 | MEDIUM | CORS policy derived from requester's org rather than report owner's org; free-tier API key reads any report | Derive CORS from resource owner's org; validate domain ownership before adding to allowlist |
Related findings: SA-SKL-CORS23 (webhook/event stream CORS), SA-SKL-AUTH16 (report access control), SA-SKL-SSRF25 (SSRF via documentation URL fetch).
SkillAudit scans your MCP skill registry for all SA-SKL-CORS24 patterns — credentialed origin reflection, wildcard on private endpoints, CDN Vary:Origin gaps, and multi-tenant CORS logic errors — and delivers a prioritized fix report in minutes.
Join the waitlist →