Claude MCP skill CORS misconfiguration — file download and static asset serving — SA-SKL-CORS23
File download and static asset endpoints are often treated as low-risk because they appear to deliver public content. In a multi-tenant skill registry, however, they gate access to private skill packages, presigned cloud storage URLs, and per-user artifacts. SA-SKL-CORS23 covers four CORS misconfigurations that expose these endpoints to attacker-controlled origins: origin reflection on the download endpoint, a missing Cross-Origin-Resource-Policy header on the CDN, wildcard CORS on the presigned URL generator, and an over-long preflight cache that survives allowlist revocation.
GET /api/skills/:id/download echoes the request Origin header as Access-Control-Allow-Origin without validating it against an allowlist and sets Access-Control-Allow-Credentials: true; any attacker-controlled page can initiate a credentialed fetch, receive the full skill ZIP binary in the response, and exfiltrate itAccess-Control-Allow-Origin: * but no Cross-Origin-Resource-Policy: same-origin (or cross-origin) header; in browsers with cross-origin isolation enabled, the absence of CORP allows Spectre-style side-channel reads of asset bytes from a cross-origin page sharing the same renderer processPOST /api/skills/:id/presigned-download sets Access-Control-Allow-Origin: *; any attacker origin can call the endpoint with a victim's session cookie (credentialed fetch not needed — the ACAO:* discloses the response body), read the presigned URL from the JSON response, and fetch the private skill package directly from S3 for one hourAccess-Control-Max-Age: 86400 (24 hours) on mutable API endpoints; when an origin is removed from the allowlist (e.g., after a partner integration is terminated), browsers that cached the previous preflight approval continue sending credentialed cross-origin requests for up to 24 hours without re-checkingBackground: CORS on asset delivery endpoints
CORS misconfigurations on API endpoints that return JSON are well understood. What is less commonly audited is the CORS posture of asset delivery endpoints: file download routes, presigned URL generators, and CDN-backed static stores. In a skill registry, these endpoints guard the actual intellectual property — the skill source files, compiled packages, and private audit reports that paying customers submit. A CORS vulnerability on the download API is functionally equivalent to an unauthenticated file download endpoint, because any page the victim visits in their browser can silently fetch the content on their behalf using their session cookie.
The findings in SA-SKL-CORS23 build on the CORS origin reflection pattern documented in SA-SKL-CORS22, which showed how the same pattern on administrative endpoints allows cross-origin state mutation. Here the impact is data exfiltration. CORS23-003 is especially subtle: the presigned URL endpoint does not need to serve the binary itself — it only needs to leak the URL, which then grants time-limited direct S3 access with no further authentication.
CORS23-001 — CRITICAL — File download endpoint reflects Origin as ACAO with credentials
The GET /api/skills/:id/download route is intended to serve skill ZIP packages to authenticated users. To support cross-origin access from the registry's own dashboard (hosted at a different subdomain), the route was modified to allow cross-origin requests. The developer reached for the simplest pattern: read the incoming Origin header and echo it back as Access-Control-Allow-Origin. Combined with Access-Control-Allow-Credentials: true (required so the browser sends the session cookie), this opens every origin as a valid cross-origin reader. The browser's same-origin policy is the only protection between the victim's skill package and an attacker-controlled page — and origin reflection defeats it entirely.
The correct fix is an explicit allowlist: a Set of permitted origins checked before the response is written. For download endpoints, the allowlist should be conservative — typically only https://skillaudit.dev and https://app.skillaudit.dev. If the endpoint must serve truly public content (no authentication), use ACAO: * and remove credentials support entirely; the two cannot be combined per the CORS specification.
// VULNERABLE — CORS23-001
// routes/downloads.js
router.get('/api/skills/:id/download', requireAuth, async (req, res) => {
const origin = req.headers['origin'];
// BUG: echoes any Origin back — Origin reflection with credentials
if (origin) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
}
const skill = await db.query(
'SELECT package_path, owner_org_id FROM skills WHERE id = $1',
[req.params.id]
);
if (!skill.rows.length) return res.status(404).end();
// Authorization: check org membership
if (skill.rows[0].owner_org_id !== req.user.orgId) {
return res.status(403).json({ error: 'Forbidden' });
}
res.setHeader('Content-Type', 'application/zip');
res.setHeader('Content-Disposition', `attachment; filename="skill-${req.params.id}.zip"`);
fs.createReadStream(skill.rows[0].package_path).pipe(res);
});
// FIXED — CORS23-001
// routes/downloads.js
const CORS_DOWNLOAD_ALLOWLIST = new Set([
'https://skillaudit.dev',
'https://app.skillaudit.dev',
]);
function applyCorsForDownload(req, res) {
const origin = req.headers['origin'];
if (origin && CORS_DOWNLOAD_ALLOWLIST.has(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
res.setHeader('Vary', 'Origin');
}
// If origin not in allowlist: no CORS headers — browser blocks the response
}
router.options('/api/skills/:id/download', (req, res) => {
applyCorsForDownload(req, res);
res.setHeader('Access-Control-Allow-Methods', 'GET');
res.setHeader('Access-Control-Max-Age', '300'); // short cache for mutable allowlist
res.status(204).end();
});
router.get('/api/skills/:id/download', requireAuth, async (req, res) => {
applyCorsForDownload(req, res);
const skill = await db.query(
'SELECT package_path, owner_org_id FROM skills WHERE id = $1',
[req.params.id]
);
if (!skill.rows.length) return res.status(404).end();
if (skill.rows[0].owner_org_id !== req.user.orgId) {
return res.status(403).json({ error: 'Forbidden' });
}
res.setHeader('Content-Type', 'application/zip');
res.setHeader('Content-Disposition', `attachment; filename="skill-${req.params.id}.zip"`);
fs.createReadStream(skill.rows[0].package_path).pipe(res);
});
CORS23-001 impact: Any page the victim visits can silently download their private skill packages in full. The attacker page initiates fetch('/api/skills/target-id/download', { credentials: 'include' }) from the attacker origin. Because the server reflects the attacker origin, the browser delivers the response body. The skill ZIP is transmitted to the attacker's server in a single XMLHttpRequest without any user interaction. SkillAudit detects this by issuing a preflight from a synthetic test origin and verifying the preflight response does not echo an arbitrary origin.
CORS23-002 — HIGH — CDN CORP header missing enables Spectre-based cross-origin reads
The static asset CDN is configured with Access-Control-Allow-Origin: * to allow images and scripts to load from any page. This is intentional for public resources. However, the CDN does not set a Cross-Origin-Resource-Policy (CORP) header. CORP is a Fetch metadata response header (Cross-Origin-Resource-Policy: same-origin or cross-origin) that instructs the browser whether a resource may be included in a cross-origin context. Without CORP, browsers that have enabled cross-origin isolation (e.g., via Cross-Origin-Opener-Policy: same-origin + Cross-Origin-Embedder-Policy: require-corp) will refuse to load the CDN assets, breaking the page. More importantly, in browsers running cross-origin isolated contexts, the absence of CORP on a resource that is embedded (e.g., via <img>) means the resource bytes are loaded into the renderer process and become accessible via Spectre-style timing attacks.
The fix depends on what the CDN serves. For skill package assets that are private (even if served from a CDN), use Cross-Origin-Resource-Policy: same-origin to prevent cross-origin embedding entirely. For truly public assets (logos, fonts, public demo files), use Cross-Origin-Resource-Policy: cross-origin to explicitly permit cross-origin embedding while enabling cross-origin isolation on pages that need it.
# VULNERABLE — CORS23-002
# Caddy CDN config — static assets served without CORP header
handle /assets/* {
root * /srv/skillaudit/assets
file_server
header Access-Control-Allow-Origin *
# BUG: no Cross-Origin-Resource-Policy header
# Cross-origin isolation is blocked on pages that embed these assets
# Spectre-based side-channel possible in cross-origin isolated contexts
}
# FIXED — CORS23-002
# Caddy CDN config — CORP header applied per asset sensitivity
# Private skill assets: same-origin only
handle /skill-assets/* {
root * /srv/skillaudit/skill-assets
file_server
header Cross-Origin-Resource-Policy same-origin
# No ACAO header — not intended for cross-origin embedding
}
# Truly public assets: cross-origin explicitly allowed
handle /public/* {
root * /srv/skillaudit/public
file_server
header Access-Control-Allow-Origin *
header Cross-Origin-Resource-Policy cross-origin
# Explicit CORP: cross-origin unblocks cross-origin isolation on pages embedding these
}
CORS23-002 impact: The direct Spectre exploitation requires a cross-origin isolated browser context and hardware-level timing precision; it is a theoretical risk today that becomes more practical as browser isolation weakens. The more immediate impact is that pages requiring cross-origin isolation (e.g., SharedArrayBuffer-dependent features) cannot load CDN assets from this registry, breaking legitimate use cases. Setting CORP costs nothing and resolves both issues. SkillAudit flags the absence of CORP on any CDN-served resource as a medium finding.
CORS23-003 — CRITICAL — Presigned URL endpoint exposes private package URLs via wildcard CORS
The POST /api/skills/:id/presigned-download endpoint generates a time-limited presigned S3 URL that allows the holder to download a private skill package directly from object storage without further authentication. This endpoint is intended to be called only by the authenticated registry frontend. However, it sets Access-Control-Allow-Origin: * in its response headers, intending to allow broad access. The critical mistake is that wildcard CORS on a JSON API endpoint means any page can read the response body — not just authenticated pages with session cookies (since ACAO:* and Allow-Credentials are mutually exclusive in modern browsers, credentialed fetches are not needed here). An attacker page running in the victim's browser can call fetch('https://skillaudit.dev/api/skills/target-id/presigned-download', { credentials: 'include' }), and because the ACAO:* header allows the cross-origin read, the browser delivers the JSON response containing the presigned S3 URL. The attacker then fetches the skill package directly from S3.
The fix is to restrict this endpoint to the same origin allowlist used for all authenticated API routes. The presigned URL endpoint returns sensitive data (a time-limited credential); it must never use wildcard CORS. Apply the same origin-allowlist middleware used on other private API routes, and remove any special-case ACAO: * override added for convenience.
// VULNERABLE — CORS23-003
// routes/presigned.js
router.post('/api/skills/:id/presigned-download', requireAuth, async (req, res) => {
// BUG: wildcard CORS — any origin can read the presigned URL from the response body
res.setHeader('Access-Control-Allow-Origin', '*');
const skill = await db.query(
'SELECT s3_key, owner_org_id FROM skills WHERE id = $1',
[req.params.id]
);
if (!skill.rows.length) return res.status(404).end();
if (skill.rows[0].owner_org_id !== req.user.orgId) {
return res.status(403).json({ error: 'Forbidden' });
}
const url = await s3.getSignedUrlPromise('getObject', {
Bucket: process.env.S3_BUCKET,
Key: skill.rows[0].s3_key,
Expires: 3600,
});
res.json({ url }); // attacker reads this via ACAO:* cross-origin fetch
});
// FIXED — CORS23-003
// routes/presigned.js
// Apply the same origin-allowlist cors middleware used on all private API routes
const { corsMiddleware } = require('../middleware/cors'); // allowlist-based, see CORS23-001 fix
router.post(
'/api/skills/:id/presigned-download',
corsMiddleware, // origin must be in CORS_API_ALLOWLIST — no wildcard
requireAuth,
async (req, res) => {
const skill = await db.query(
'SELECT s3_key, owner_org_id FROM skills WHERE id = $1',
[req.params.id]
);
if (!skill.rows.length) return res.status(404).end();
if (skill.rows[0].owner_org_id !== req.user.orgId) {
return res.status(403).json({ error: 'Forbidden' });
}
const url = await s3.getSignedUrlPromise('getObject', {
Bucket: process.env.S3_BUCKET,
Key: skill.rows[0].s3_key,
Expires: 3600,
});
res.json({ url });
}
);
CORS23-003 impact: An attacker page can harvest valid presigned S3 URLs for private skill packages belonging to any authenticated victim who visits a page the attacker controls. Each presigned URL grants one hour of direct S3 download access. The attack chain: victim visits attacker page → page fetches presigned URL endpoint with victim cookies via ACAO:* → reads URL from response → exfiltrates to attacker server → attacker downloads skill package from S3. SkillAudit detects this by issuing a no-credentials fetch from a synthetic cross-origin and verifying the response body is not readable.
CORS23-004 — MEDIUM — Long preflight cache Max-Age persists after allowlist revocation
CORS preflight responses for the skill registry API are cached with Access-Control-Max-Age: 86400 (24 hours). The intent is performance: browsers will not re-issue OPTIONS requests for 24 hours, reducing round trips. The problem arises when an origin is removed from the CORS allowlist — for example, when a partner integration is terminated or a misconfigured developer origin must be revoked. Browsers that have already cached the preflight approval will continue sending credentialed cross-origin requests to that endpoint for up to 24 hours without re-checking. The server-side allowlist is updated instantly, but the browser's cache keeps the old decision. During that window, the revoked origin retains all the CORS access it previously had.
The fix is to reduce Access-Control-Max-Age on mutable API endpoints to a value that balances performance against revocation latency. A value of 300 seconds (5 minutes) is a reasonable default for most API routes: it eliminates most repeat preflight overhead while bounding the revocation window to under 5 minutes. For highly sensitive endpoints (admin, billing, download), use a lower value or zero. Truly immutable resources (public scripts with no auth) may use longer caches.
// VULNERABLE — CORS23-004
// middleware/cors.js
function corsMiddleware(req, res, next) {
const origin = req.headers['origin'];
if (origin && CORS_ALLOWLIST.has(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
res.setHeader('Vary', 'Origin');
}
if (req.method === 'OPTIONS') {
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization');
// BUG: 24-hour cache — revocation takes up to 24 hours to take effect per client
res.setHeader('Access-Control-Max-Age', '86400');
return res.status(204).end();
}
next();
}
// FIXED — CORS23-004
// middleware/cors.js — per-endpoint Max-Age based on sensitivity
function corsMiddleware(options = {}) {
const maxAge = options.maxAge ?? 300; // default: 5 minutes
return (req, res, next) => {
const origin = req.headers['origin'];
if (origin && CORS_ALLOWLIST.has(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
res.setHeader('Vary', 'Origin');
}
if (req.method === 'OPTIONS') {
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization');
res.setHeader('Access-Control-Max-Age', String(maxAge));
return res.status(204).end();
}
next();
};
}
// Apply with endpoint-appropriate cache durations:
// Standard API routes — 5 minutes
app.use('/api/', corsMiddleware({ maxAge: 300 }));
// Sensitive endpoints (admin, billing, download) — 60 seconds
app.use('/api/admin/', corsMiddleware({ maxAge: 60 }));
app.use('/api/skills/:id/download', corsMiddleware({ maxAge: 60 }));
// Public static assets with no auth — longer cache acceptable
app.use('/public/', corsMiddleware({ maxAge: 86400 }));
CORS23-004 remediation: For immediate revocation of a compromised partner origin, the fastest path is to both update the server-side allowlist AND issue a short-TTL CORS-revocation response: return an empty Access-Control-Allow-Origin (no header) with Access-Control-Max-Age: 0 for a brief period. Modern browsers will treat the absence of ACAO as a denial and invalidate the cached approval. The 5-minute default Max-Age prevents most stale-cache revocation windows without meaningful performance impact on modern connections.
Detection with SkillAudit
SkillAudit's CORS audit module tests all four SA-SKL-CORS23 patterns automatically. For CORS23-001 and CORS23-003, the scanner issues synthetic preflight and actual requests from an attacker-controlled test origin and checks whether the response ACAO header reflects the test origin or is *. For CORS23-002, the scanner inspects CDN response headers for the presence of a Cross-Origin-Resource-Policy header on all asset-serving routes. For CORS23-004, the scanner inspects preflight responses for Access-Control-Max-Age values exceeding 3600 on routes that accept write methods (POST, PUT, PATCH, DELETE) with authentication.
| Finding | Severity | Detection signal | Fix |
|---|---|---|---|
| CORS23-001 | CRITICAL | Download endpoint echoes test origin as ACAO with Allow-Credentials:true | Explicit origin allowlist; remove reflection |
| CORS23-002 | HIGH | CDN assets lack Cross-Origin-Resource-Policy header | CORP: same-origin for private; cross-origin for public |
| CORS23-003 | CRITICAL | Presigned URL endpoint returns ACAO:* on JSON response with presigned URL in body | Allowlist-only CORS on all sensitive JSON endpoints |
| CORS23-004 | MEDIUM | Max-Age > 3600 on authenticated mutable endpoints | Max-Age ≤ 300 on API routes; 60 on sensitive endpoints |
Related findings: SA-SKL-CORS22 (admin API CORS), SA-SKL-CORS21 (webhook delivery CORS), SA-SKL-SSRF25 (SSRF via documentation URL fetch).