Claude MCP skill CORS misconfiguration — audit submission and result delivery endpoints — SA-SKL-CORS26
Audit submission and result delivery endpoints sit at the core of the SkillAudit billing and reporting model: they consume quota, store findings, and feed downstream CI/CD systems. SA-SKL-CORS26 covers four CORS misconfiguration patterns in these endpoints — a wildcard ACAO on the audit submit endpoint that lets any attacker origin burn a victim's free quota using their session cookie, a wildcard on the result status polling endpoint that leaks repository URL and partial findings, an absent CORS policy on the result callback endpoint that allows grade fabrication, and a premature Origin reflection on the batch endpoint that creates a timing oracle for quota exhaustion state.
POST /api/audits has Access-Control-Allow-Origin: * — any origin submits unlimited free audits using the victim's session cookie, burning free quota; the endpoint returns the audit job ID which lets the attacker track the submission and later retrieve resultsGET /api/audits/:id/status has ACAO: * and reflects all job metadata — any origin polls for the victim's in-progress audit status leaking repoUrl, partial findings, and internal task identifiersPOST /api/audits/:id/callback has no CORS middleware — attacker forges delivery completion cross-origin, marking the audit as complete with a fabricated grade (e.g., grade:A) and overwriting real in-progress analysisPOST /api/audits/batch reflects Origin as ACAO before the rate limit check runs — timing oracle reveals whether the org is rate-limited before the CORS block fires, leaking quota exhaustion stateBackground: audit submission as a CORS attack surface
CORS attacks against audit submission endpoints are more damaging than typical read-based CORS exploits because they consume real resources on behalf of the victim. CORS26-001 turns the wildcard ACAO on POST /api/audits into a quota-burning weapon: an attacker page visited by an authenticated victim submits an arbitrary number of audit jobs using the victim's session cookie. Each submission counts against the victim's free tier limit, potentially locking them out of the service. The returned job IDs also enable the attacker to retrieve full audit results once analysis completes — combining quota exhaustion with result exfiltration in a single request.
CORS26-002 and CORS26-003 attack the result delivery pipeline. The status polling endpoint leaks the full job context — repository URL, partial findings as they are written, and internal task queue identifiers — to any origin that obtains a job ID. CORS26-003 is particularly severe: by forging a callback delivery to the internal endpoint that marks audit jobs complete, an attacker can overwrite a legitimate in-progress analysis with fabricated results. If a CI/CD gate reads the SkillAudit grade before merging a pull request, the attacker causes the gate to pass a grade:A result for a repository that never completed real analysis.
CORS26-004 illustrates how middleware ordering errors create information leakage even when the final response is correctly blocked. The timing delta between a cross-origin request that hits the Origin-reflect CORS middleware versus one that is rate-limited before CORS fires exposes the org's quota exhaustion state without returning any data payload.
Related patterns: SA-SKL-CORS25 (webhook endpoint CORS), SA-SKL-CORS24 (reporting endpoint CORS), SA-SKL-INJECTION15 (CI/CD pipeline injection).
CORS26-001 — CRITICAL — Wildcard ACAO on audit submit endpoint burns victim's free quota
The audit submission endpoint POST /api/audits returns Access-Control-Allow-Origin: *. The endpoint accepts Content-Type: application/json, so the browser sends a preflight OPTIONS request. The server's OPTIONS handler responds with ACAO: * and Access-Control-Allow-Methods: POST, which instructs the browser to proceed with the cross-origin POST. The browser attaches the victim's session cookie to the POST request because the endpoint is on the same origin as the authenticated session — the wildcard merely allows the cross-origin page to read the response, not to inject cookies, but the cookies are sent regardless of CORS policy on credentialed same-origin-cookie requests.
An attacker page sends fetch('https://api.skillaudit.dev/api/audits', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ repoUrl: 'https://github.com/victim/repo' }) }). The browser fires the preflight, receives ACAO: *, then sends the POST with the victim's session cookie. The server processes the request as the victim, creates an audit job, and decrements the victim's free quota. The response body — including the new jobId — is returned to the attacker page because ACAO: * permits cross-origin response reads.
The attacker now has the jobId. They can poll GET /api/audits/:id/status (see CORS26-002) to track progress and retrieve full results. With automation, the attacker can submit hundreds of audit jobs in a loop, exhausting the victim's quota within seconds. The fix requires replacing the wildcard with an explicit origin allowlist and adding credentials: true to the CORS configuration — which also forces the browser to send the session cookie only from allowed origins.
// VULNERABLE — CORS26-001
// routes/audits.js
const express = require('express');
const router = express.Router();
// BUG: wildcard ACAO on a state-mutating, quota-consuming endpoint
// Any origin can submit audits using victim's session cookie:
// fetch('/api/audits', { method:'POST', credentials:'include',
// headers:{'Content-Type':'application/json'},
// body: JSON.stringify({ repoUrl: 'https://github.com/victim/repo' })
// })
// Server responds with ACAO:* — attacker reads jobId, victim's quota decremented
router.options('/', (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*'); // BUG: wildcard
res.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.sendStatus(204);
});
router.post('/', authenticate, async (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*'); // BUG: wildcard on response too
const { repoUrl, branch, config } = req.body;
// Check and decrement free quota
const user = await User.findById(req.user.id);
if (user.freeAuditsRemaining <= 0) {
return res.status(402).json({ error: 'Free quota exhausted' });
}
await User.updateOne({ _id: req.user.id }, { $inc: { freeAuditsRemaining: -1 } });
const job = await AuditJob.create({
userId: req.user.id,
repoUrl,
branch: branch || 'main',
config: config || {},
status: 'queued',
});
await queue.add('audit', { jobId: job.id });
// BUG: returns jobId to any origin — attacker tracks and retrieves results
res.status(201).json({ jobId: job.id, status: 'queued' });
});
app.use('/api/audits', router);
// FIXED — CORS26-001
// routes/audits.js
const cors = require('cors');
const ALLOWED_ORIGINS = [
'https://app.skillaudit.dev',
'https://skillaudit.dev',
];
// Allowlist CORS — no wildcard; credentials:true restricts cookie attachment
// to allowed origins only
const auditCors = cors({
origin: (origin, cb) => {
// No origin = same-origin or server-to-server — allow
if (!origin) return cb(null, true);
if (ALLOWED_ORIGINS.includes(origin)) return cb(null, true);
logger.warn('CORS26-001: rejected origin on audit submit', { origin });
return cb(new Error('CORS: origin not allowed'));
},
credentials: true,
methods: ['POST', 'GET', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
});
router.options('/', auditCors); // explicit preflight handler
router.post('/', auditCors, authenticate, async (req, res) => {
const { repoUrl, branch, config } = req.body;
// Validate repoUrl is an allowed VCS host (SSRF guard)
if (!isAllowedRepoHost(repoUrl)) {
return res.status(400).json({ error: 'Repository host not allowed' });
}
// Check and decrement free quota atomically
const user = await User.findOneAndUpdate(
{ _id: req.user.id, freeAuditsRemaining: { $gt: 0 } },
{ $inc: { freeAuditsRemaining: -1 } },
{ new: true }
);
if (!user) return res.status(402).json({ error: 'Free quota exhausted' });
const job = await AuditJob.create({
userId: req.user.id,
repoUrl,
branch: branch || 'main',
config: config || {},
status: 'queued',
});
await queue.add('audit', { jobId: job.id });
// jobId returned only to allowed origins; cross-origin reads now blocked
res.status(201).json({ jobId: job.id, status: 'queued' });
});
app.use('/api/audits', router);
CORS26-001 impact: Any page the victim visits can submit an unlimited number of audit jobs using the victim's session cookie, exhausting their free tier quota in seconds. The returned jobId is readable by the attacker page (wildcard ACAO permits cross-origin response reads), enabling result exfiltration once analysis completes. The combined impact — quota exhaustion plus result theft — requires a single cross-origin POST. SkillAudit detects this by identifying audit submission routes and flagging any that emit ACAO: * on the OPTIONS preflight or POST response, particularly those that also modify billing-related fields such as free quota counters.
CORS26-002 — HIGH — Wildcard ACAO on result status polling leaks repoUrl and partial findings
The audit result status endpoint GET /api/audits/:id/status returns the full job metadata for the given audit job ID, including the repository URL, current status, partial findings as they are written by the analysis engine, and internal task queue identifiers. The endpoint sets Access-Control-Allow-Origin: *. Because it is a GET request, no preflight is required — the browser sends the request directly and allows the cross-origin page to read the response body.
An attacker who obtains a valid jobId — either via CORS26-001 (by submitting a job themselves), by enumerating sequential integer IDs, or by observing a Referer header or URL bar sharing — can call fetch('https://api.skillaudit.dev/api/audits/JOB_ID/status') from any page and read the full response. The response includes repoUrl (which may reveal internal or private repository names), findings (partial results as the analysis engine writes them, including vulnerability identifiers, file paths, and severity scores), and workerTaskId (an internal queue identifier that can be used to infer the analysis engine's internal state or correlate with other jobs).
The fix requires either applying an allowlist CORS policy (so only the legitimate frontend can read status responses) or implementing per-job access tokens such that only the user who submitted the job can retrieve its status. The two approaches are complementary: CORS restricts which pages can read responses, while per-job authorization restricts which users can access which jobs. Both are needed; CORS alone does not prevent server-to-server polling or curl requests.
// VULNERABLE — CORS26-002
// routes/audits.js
// BUG: wildcard ACAO on a GET endpoint that returns full job metadata
// Any origin can poll for any job's status and read repoUrl + partial findings:
// fetch('https://api.skillaudit.dev/api/audits/JOB_ID/status')
// .then(r => r.json())
// .then(data => exfiltrate(data.repoUrl, data.findings, data.workerTaskId))
router.get('/:id/status', authenticate, async (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*'); // BUG: wildcard
const job = await AuditJob.findOne({ _id: req.params.id, userId: req.user.id });
if (!job) return res.status(404).json({ error: 'Job not found' });
// BUG: returns internal task identifiers and partial findings — readable by any origin
res.json({
jobId: job.id,
status: job.status,
repoUrl: job.repoUrl, // leaks private repo URL
findings: job.partialFindings, // leaks partial analysis results
workerTaskId: job.workerTaskId, // leaks internal queue identifier
createdAt: job.createdAt,
updatedAt: job.updatedAt,
});
});
// FIXED — CORS26-002
// routes/audits.js
const ALLOWED_ORIGINS = [
'https://app.skillaudit.dev',
'https://skillaudit.dev',
];
const auditCors = cors({
origin: (origin, cb) => {
if (!origin || ALLOWED_ORIGINS.includes(origin)) return cb(null, true);
logger.warn('CORS26-002: rejected origin on status poll', { origin });
return cb(new Error('CORS: origin not allowed'));
},
credentials: true,
methods: ['GET', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
});
router.get('/:id/status', auditCors, authenticate, async (req, res) => {
const job = await AuditJob.findOne({ _id: req.params.id, userId: req.user.id });
if (!job) return res.status(404).json({ error: 'Job not found' });
// Return only fields needed by the frontend — omit internal identifiers
res.json({
jobId: job.id,
status: job.status,
repoUrl: job.repoUrl,
// Return findings only when job is complete, not during partial writes
findings: job.status === 'completed' ? job.findings : null,
grade: job.status === 'completed' ? job.grade : null,
createdAt: job.createdAt,
completedAt: job.completedAt || null,
// workerTaskId intentionally omitted — internal detail not needed by frontend
});
});
CORS26-002 impact: An attacker with any valid job ID can read the victim's repository URL, partial analysis findings as they are written by the analysis engine, and internal task identifiers. If the endpoint lacks authentication on the job ownership check, the exposure extends to any job in the system. The partial findings disclosure is particularly damaging because it reveals vulnerability identifiers before the owner has seen the full report, enabling targeted exploitation of the disclosed issues. SkillAudit detects this by identifying status and progress polling routes and flagging those emitting ACAO: * alongside response fields containing file paths, vulnerability identifiers, or internal identifiers.
CORS26-003 — HIGH — No CORS on result callback endpoint allows grade fabrication
The result delivery callback endpoint POST /api/audits/:id/callback is an internal endpoint called by the analysis worker to mark an audit job as complete and store the final grade and findings. The endpoint has no CORS middleware configured. As with CORS25-001 (webhook registration), absent CORS middleware does not protect an endpoint against cross-origin simple requests. An attacker can send fetch('/api/audits/JOB_ID/callback', { method: 'POST', credentials: 'include', body: new URLSearchParams({ grade: 'A', status: 'completed' }), headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) without a preflight.
The concrete impact is that the attacker can overwrite the real in-progress analysis result with fabricated data. If the callback endpoint validates only that the authenticated user owns the job (not that the caller is the internal worker), any authenticated user — including the victim visiting the attacker's page — can close out their own job with a fabricated grade. If a CI/CD pipeline gate reads the SkillAudit grade before merging a pull request, the attacker causes a repository with real vulnerabilities to pass the gate with a fabricated grade:A.
The fix has two components. First, the callback endpoint must require a shared secret (HMAC signature or a per-job callback token) that only the analysis worker possesses — this prevents any user, authenticated or not, from forging a callback. Second, an explicit CORS policy must be applied that blocks all browser-origin requests, since the callback is a machine-to-machine endpoint that should never be called from a browser context.
// VULNERABLE — CORS26-003
// routes/audits.js
// BUG: no CORS middleware AND no worker authentication
// Attacker sends simple-request POST (application/x-www-form-urlencoded):
// fetch('/api/audits/JOB_ID/callback', {
// method: 'POST', credentials: 'include',
// body: new URLSearchParams({ grade: 'A', status: 'completed',
// findings: '[]' }),
// headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
// })
// Browser attaches victim's session cookie — job marked A, real analysis overwritten
router.post('/:id/callback', authenticate, async (req, res) => {
// BUG: authenticates as the job owner (victim) not as the internal worker
// No shared secret / HMAC check — any authenticated user can call this
const job = await AuditJob.findOne({ _id: req.params.id, userId: req.user.id });
if (!job) return res.status(404).json({ error: 'Job not found' });
const { grade, status, findings } = req.body;
// BUG: blindly stores attacker-supplied grade and findings
await AuditJob.updateOne({ _id: job.id }, {
$set: { grade, status, findings: JSON.parse(findings || '[]'), completedAt: new Date() }
});
res.json({ ok: true });
});
// FIXED — CORS26-003
// routes/audits.js
const crypto = require('crypto');
// Callback is machine-to-machine only — block all browser-origin requests
const callbackCors = cors({
origin: (origin, cb) => {
// Any browser-issued request will have an Origin header — reject all
if (origin) {
logger.warn('CORS26-003: browser-origin request rejected on callback', { origin });
return cb(new Error('CORS: callback endpoint not accessible from browser origins'));
}
// No Origin header = server-to-server call — allow
return cb(null, true);
},
credentials: false,
methods: ['POST'],
});
// authenticateWorker validates the X-Worker-Signature HMAC header
// signed with WORKER_CALLBACK_SECRET shared with the analysis fleet
function authenticateWorker(req, res, next) {
const sig = req.headers['x-worker-signature'];
if (!sig) return res.status(401).json({ error: 'Missing worker signature' });
const payload = `${req.params.id}:${req.headers['x-worker-timestamp']}`;
const expected = crypto
.createHmac('sha256', process.env.WORKER_CALLBACK_SECRET)
.update(payload)
.digest('hex');
if (!crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected))) {
logger.warn('CORS26-003: invalid worker signature on callback', { jobId: req.params.id });
return res.status(403).json({ error: 'Invalid worker signature' });
}
// Reject replayed callbacks (timestamp older than 5 minutes)
const ts = parseInt(req.headers['x-worker-timestamp'], 10);
if (Date.now() - ts > 5 * 60 * 1000) {
return res.status(403).json({ error: 'Callback timestamp expired' });
}
next();
}
router.post('/:id/callback', callbackCors, authenticateWorker, async (req, res) => {
const job = await AuditJob.findById(req.params.id);
if (!job) return res.status(404).json({ error: 'Job not found' });
if (job.status === 'completed') {
// Idempotent: already complete — return success without overwriting
return res.json({ ok: true, idempotent: true });
}
const { grade, findings } = req.body;
// Validate grade is from the allowed set
if (!['A', 'B', 'C', 'D', 'F'].includes(grade)) {
return res.status(400).json({ error: 'Invalid grade value' });
}
await AuditJob.updateOne({ _id: job.id }, {
$set: {
grade,
findings: Array.isArray(findings) ? findings : [],
status: 'completed',
completedAt: new Date(),
}
});
res.json({ ok: true });
});
CORS26-003 impact: An attacker can overwrite a victim's in-progress audit result with a fabricated grade (e.g., grade: A) before real analysis completes. If the victim's CI/CD pipeline gates merges on the SkillAudit grade, the attacker causes a vulnerable pull request to pass the gate. The exploit requires only that the victim visit the attacker's page while authenticated and have a job in progress — the attacker learns the jobId via CORS26-001 or CORS26-002. SkillAudit detects this by identifying callback and completion endpoints (paths matching /callback, /complete, /finish) and flagging those that lack both CORS middleware and machine-to-machine authentication (HMAC signature or dedicated service token).
CORS26-004 — MEDIUM — Premature Origin reflection on batch endpoint creates quota exhaustion timing oracle
The batch audit submission endpoint POST /api/audits/batch uses a custom CORS middleware that reflects the incoming Origin header as Access-Control-Allow-Origin before the rate limit check middleware runs. The rate limit check is the first real guard on this endpoint — it short-circuits the request with a 429 if the organization has exceeded its quota. Because CORS reflection runs first, the server emits ACAO: <reflected-origin> regardless of whether the request will be rate-limited.
An attacker page sends a cross-origin preflight (OPTIONS) or simple POST to /api/audits/batch from their origin. The server reflects the origin back in the ACAO header. If the organization is rate-limited, the response is 429 Too Many Requests with the ACAO header already set — the browser allows the attacker page to read the 429 body, confirming that the organization has exhausted its batch quota. If the organization is not rate-limited, the response proceeds through authentication and returns a 401 or 201 depending on the session state. The timing delta between these paths (rate limit check is a fast Redis lookup; authentication is a database query) is measurable and further distinguishes the cases.
While the direct information leakage is limited (quota exhaustion state), this oracle is valuable in combination with CORS26-001: an attacker who exhausts the victim's quota via CORS26-001 can confirm the exhaustion via CORS26-004 without requiring authentication. The fix is to replace the reflect-all CORS middleware with an allowlist — unknown origins are blocked before the CORS header is emitted, eliminating the oracle entirely.
// VULNERABLE — CORS26-004
// routes/audits.js
// BUG: reflect-any-origin CORS applied BEFORE rate limit check
// Any origin receives its own value as ACAO, allowing it to read the 429 body
// Timing oracle: rate-limit check (Redis, ~1ms) vs auth check (DB, ~5ms) is measurable
app.post('/api/audits/batch',
(req, res, next) => {
// Reflects any Origin — runs before rate limit and auth checks
if (req.headers.origin) {
res.setHeader('Access-Control-Allow-Origin', req.headers.origin); // BUG
res.setHeader('Access-Control-Allow-Credentials', 'true');
res.setHeader('Vary', 'Origin');
}
next();
},
rateLimitByOrg, // runs AFTER cors — 429 body readable by attacker origin
authenticate, // runs AFTER rate limit
async (req, res) => {
const { repos } = req.body;
// ... create batch job ...
res.status(201).json({ batchId: batch.id, jobCount: repos.length });
}
);
// FIXED — CORS26-004
// routes/audits.js
const cors = require('cors');
const ALLOWED_ORIGINS = [
'https://app.skillaudit.dev',
'https://skillaudit.dev',
];
// Allowlist CORS — unknown origins never receive ACAO, cannot read any response
const strictCors = cors({
origin: (origin, cb) => {
if (!origin || ALLOWED_ORIGINS.includes(origin)) return cb(null, true);
logger.warn('CORS26-004: rejected origin on batch audit submit', { origin });
return cb(new Error('CORS: origin not allowed'));
},
credentials: true,
methods: ['POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
});
// Explicit OPTIONS handler for the preflight
app.options('/api/audits/batch', strictCors);
// CORS applied first with ALLOWLIST — unknown origins blocked before they can
// observe rate limit or auth timing differences
app.post('/api/audits/batch',
strictCors,
authenticate, // authenticate before rate limit: auth failure returns 401
rateLimitByOrg, // rate limit after auth: 429 only reached by authenticated orgs
async (req, res) => {
const { repos } = req.body;
if (!Array.isArray(repos) || repos.length === 0) {
return res.status(400).json({ error: 'repos must be a non-empty array' });
}
if (repos.length > 50) {
return res.status(400).json({ error: 'Batch size exceeds maximum of 50' });
}
// Validate each repo URL and check aggregate quota
const user = await User.findOneAndUpdate(
{ _id: req.user.id, freeAuditsRemaining: { $gte: repos.length } },
{ $inc: { freeAuditsRemaining: -repos.length } },
{ new: true }
);
if (!user) return res.status(402).json({ error: 'Insufficient quota for batch size' });
const batch = await AuditBatch.create({
userId: req.user.id,
repos,
status: 'queued',
});
await queue.addBulk(repos.map(repoUrl => ({ name: 'audit', data: { batchId: batch.id, repoUrl } })));
res.status(201).json({ batchId: batch.id, jobCount: repos.length });
}
);
CORS26-004 impact: Timing oracle reveals whether the target organization has exhausted its batch audit quota, without requiring authentication. The direct information value is limited — quota exhaustion state — but it confirms that a prior CORS26-001 quota-burning attack was successful. The underlying reflect-all CORS + premature emission pattern is a consistent indicator of broader CORS mishandling in the audits module; SkillAudit flags it as medium severity but escalates to high when coexisting with CORS26-001 or CORS26-003 in the same router file. SkillAudit detects this via middleware ordering analysis: any route where a reflect-all CORS middleware is registered ahead of a rate limit or authentication middleware in the same chain is flagged.
Detection with SkillAudit
SkillAudit's static analysis scans audit submission and result delivery modules for all four SA-SKL-CORS26 patterns. For CORS26-001 it identifies quota-consuming POST routes and flags those emitting ACAO: * on either the OPTIONS preflight or the POST response. For CORS26-002 it identifies status and progress polling routes and flags those emitting ACAO: * alongside response fields containing sensitive metadata (repository URLs, finding objects, internal identifiers). For CORS26-003 it identifies callback and completion endpoints and flags those lacking both CORS middleware and machine-to-machine authentication (HMAC signature or service token). For CORS26-004 it performs middleware ordering analysis — detecting reflect-all CORS middleware registered before rate limiting or authentication middleware on the same route.
| Finding | Severity | Root cause | Fix |
|---|---|---|---|
| CORS26-001 | CRITICAL | Wildcard ACAO on audit submit POST; any origin burns victim's free quota and reads returned jobId | Allowlist CORS + credentials:true; validate repoUrl against allowed hosts; atomic quota decrement |
| CORS26-002 | HIGH | Wildcard ACAO on status polling GET; any origin reads repoUrl, partial findings, internal task IDs | Allowlist CORS; omit internal fields from response; return findings only on completed jobs |
| CORS26-003 | HIGH | No CORS on callback endpoint; simple-request POST forges grade with victim session cookie | Block browser-origin requests entirely; require HMAC worker signature; validate grade enum |
| CORS26-004 | MEDIUM | Reflect-all CORS before rate limit; any origin reads 429 body confirming quota exhaustion | Allowlist CORS (not reflect-all); reorder middleware: auth before rate limit |
Related findings: SA-SKL-CORS25 (webhook endpoint CORS), SA-SKL-CORS24 (reporting endpoint CORS), SA-SKL-INJECTION15 (CI/CD pipeline injection).
SkillAudit scans your MCP skill registry for all SA-SKL-CORS26 patterns — wildcard on submit endpoints, status polling leaks, forged callback grade injection, and quota exhaustion oracles — and delivers a prioritized fix report in minutes.
Join the waitlist →