CORS Misconfigurations in MCP Skill Registry Skill Search and Autocomplete Suggestion Endpoints
Search and autocomplete endpoints sit at an uncomfortable intersection in the MCP skill registry attack surface: they handle real-time, session-personalized queries against an index that includes private, internal, and draft skills that organizations have deliberately kept off public listings. When these endpoints are misconfigured with permissive CORS, any attacker page the victim visits can silently read not just what an organization publishes — but every private skill they have queried, every autocomplete suggestion drawn from their session context, and every saved search that reflects their internal discovery process. The SA-SKL-CORS37 vulnerability class captures four patterns that together give an external observer a complete map of an organization’s internal tooling strategy.
In this post
- Why skill search and autocomplete endpoints are a high-value CORS target
- CORS37-001 — Credential-bearing CORS on personalized search leaks private skill names
- CORS37-002 — Wildcard ACAO on autocomplete exposes search history via token-in-query-param
- CORS37-003 — Origin reflection before ownership check creates saved-search timing oracle
- CORS37-004 — Credential-bearing CORS on search history leaks full query log including private skills
- Compound attack chain: result leak → autocomplete exposure → ID enumeration → full history dump
- Detection with tree-sitter AST queries
- Operator checklist: 10 controls for CORS-safe search and autocomplete endpoints
GET /api/skills/search uses cors({origin:true,credentials:true}); any origin reads personalized search results including private skill names from the victim org’s internal registry using the victim’s session cookieGET /api/skills/autocomplete has ACAO: *; session token passed as query parameter makes wildcard ACAO exploitable without withCredentials:true — any page reads autocomplete suggestions drawn from victim’s search history and recently accessed private skillsPOST /api/skills/search/save reflects Origin before ownership check; 3× response latency difference between existing and non-existing saved-search IDs creates cross-user timing oracle enabling full ID enumerationGET /api/skills/search/history uses cors({origin:true,credentials:true}); any origin reads the full search history including every private skill name the victim has ever queried, surfacing internal tooling strategy cross-originWhy skill search and autocomplete endpoints are a high-value CORS target
Public search endpoints — the kind that return only published, vetted skills — are rarely worth attacking via CORS. The data they return is by definition public. The danger in MCP skill registries arises from the fact that search is never purely public for authenticated users: results are ranked, filtered, and scoped by session context. A logged-in user searching for “auth” receives results that include the organization’s private internal auth-wrapper skill sitting in draft review, skills shared only within the org’s private workspace, and skills from partner organizations accessible only via a bilateral sharing agreement. None of these are visible in the public search index, but all of them appear in the credentialed search response.
Autocomplete is even more sensitive than search results. Where results reflect what is available, autocomplete reflects what has been queried. The suggestions presented when a user types into the search box are generated from the user’s own search history, recently accessed skills, and org-wide popular searches across all members — a compressed summary of the entire organization’s internal tooling discovery process. If an attacker can read autocomplete responses via CORS, they can reconstruct which skills the team is evaluating without ever viewing the results themselves.
The CORS vulnerability pattern on search endpoints is the same root cause as CORS36 and CORS35: an engineering team chose cors({origin:true}) rather than maintaining an explicit allowlist when embedding the search bar in a third-party integration portal. The business pressure to ship the integration fast meant the security debt was never repaid. CORS37 is distinguished from prior CORS vulnerability classes in this series by the specific attack primitive it enables: competitive intelligence. An attacker who can read a competitor organization’s search history and autocomplete responses knows which internal skills they are building, what security tools they are evaluating, and — via the saved-search enumeration in CORS37-003 — which of those evaluations were considered important enough to save for later review by other team members.
CORS37-001 — Credential-bearing CORS on personalized search leaks private skill names
The skill search endpoint GET /api/skills/search returns a ranked list of matching skills for a given query string, scoped by session context. For authenticated users, the scope includes all skills visible to their organization: public skills from the global index, private skills shared within the org’s workspace, draft skills currently under internal review, and skills from partner organizations accessible via sharing agreements. The endpoint was originally implemented with explicit CORS for the main application domain. When a partner organization requested a white-label search bar embedded in their own developer portal, the developer replaced the explicit allowlist with cors({origin:true,credentials:true}) to cover the new origin without updating the allowlist.
With origin:true, Express’s cors middleware reflects the incoming Origin header back as Access-Control-Allow-Origin and also sets Access-Control-Allow-Credentials: true. Any cross-origin page that the victim visits while logged in can execute a credentialed fetch to the search endpoint, read the full response including private and draft skill names, and exfiltrate them to an attacker-controlled server. The search endpoint does not require any special permission beyond session presence, so the technique works as long as the victim has an active session — which covers every user who has not explicitly logged out.
// CORS37-001 — VULNERABLE
// cors({origin:true,credentials:true}) reflects any Origin with credentials.
// Any attacker page reads private skill names from the authenticated search response.
// skills/search.router.js
const cors = require('cors');
const router = require('express').Router();
router.get(
'/',
cors({ origin: true, credentials: true }), // VULNERABLE: reflects any Origin
requireSession,
async (req, res) => {
const { q, page = 1, limit = 20 } = req.query;
const results = await skillSearch.query({
q,
orgId: req.session.orgId, // scoped to org — includes private + draft skills
includePrivate: true, // ← includes skills org has not published
includeDraft: true, // ← includes skills currently under review
includeShared: true, // ← includes skills from partner sharing agreements
page,
limit,
});
// Response includes private skill names, draft descriptions, internal tags
res.json(results);
}
);
// Attacker page (any origin, victim session present):
// fetch('https://registry.example.com/api/skills/search?q=auth', {
// credentials: 'include'
// })
// .then(r => r.json())
// .then(results => {
// // results.items contains private skill names and draft descriptions
// exfil(results); // send to attacker-controlled server
// });
Why session-scoped search results require the same CORS controls as admin endpoints: Teams often apply strict CORS to admin routes while treating search as low-sensitivity because it “only returns discovery data.” But for a competitor or insider threat actor, the list of private skills an organization is developing is as sensitive as the billing records. Any endpoint that returns org-scoped data different from the public response requires allowlist-based CORS — not origin:true and not wildcards. The fix must be applied at the router level, not per-endpoint, to prevent bypass via any other endpoint in the same router that shares the permissive CORS middleware.
// CORS37-001 — FIXED
// 1. Replace origin:true with explicit Set-based allowlist at router level.
// 2. requireSession already present — keep.
// 3. For non-org callers (unauthenticated or external), return only public skills.
// config/cors.js
const ALLOWED_ORIGINS = new Set([
'https://app.skillaudit.dev',
'https://skillaudit.dev',
'https://partner-portal.example.com', // explicitly registered partner
]);
const searchCorsOptions = {
origin: (origin, callback) => {
if (!origin || ALLOWED_ORIGINS.has(origin)) return callback(null, true);
callback(Object.assign(new Error('CORS: origin not in allowlist'), { status: 403 }));
},
credentials: true,
methods: ['GET', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
};
module.exports = { searchCorsOptions };
// skills/search.router.js
const { searchCorsOptions } = require('../config/cors');
router.use(cors(searchCorsOptions)); // applied once at router level
router.get('/', requireSession, async (req, res) => {
const { q, page = 1, limit = 20 } = req.query;
const isOrgCaller = req.session?.orgId != null;
const results = await skillSearch.query({
q,
orgId: isOrgCaller ? req.session.orgId : null,
includePrivate: isOrgCaller, // only return private skills for org-authenticated callers
includeDraft: false, // never return drafts via search — only via specific draft API
includeShared: isOrgCaller,
page,
limit,
});
res.json(results);
});
CVSS 3.1 approximate score for CORS37-001: 8.1 (HIGH) — AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N. Confidentiality is High because the attacker gains the full set of private skill names, draft descriptions, and partner skill names that the organization has not published, constituting direct competitive intelligence. The UI:R reflects that the victim must visit the attacker’s page while logged in.
CORS37-002 — Wildcard ACAO on autocomplete exposes search history via token-in-query-param
The autocomplete endpoint GET /api/skills/autocomplete serves real-time search suggestions as the user types. For authenticated users, suggestions are drawn from a personalization index built from the user’s own search history, their recently accessed and installed skills, and org-wide trending searches. The endpoint was designed to be called from JavaScript-driven search widgets in multiple third-party integration contexts and was given a wildcard Access-Control-Allow-Origin: * header to avoid CORS preflight latency on every keystroke.
The wildcard appears safe at first glance because ACAO: * cannot be combined with Access-Control-Allow-Credentials: true — the browser will refuse to expose the response if both headers are present. The vulnerability arises because the autocomplete endpoint accepts the session token as a query parameter (?token=<session_token>) in addition to the cookie-based session. The token-in-query-param pattern was added to support embedded widgets in iframes where cookie access is blocked by third-party cookie restrictions. With token-in-query-param, the browser does not need to send credentials in the Cookie header — the token is part of the URL. Because the request does not use withCredentials:true, the browser permits the response to be read under ACAO: *. An attacker who can read the victim’s session token from any other source (a previous CORS37-001 or CORS37-004 leak, a session fixation, or a readable localStorage key) can then read the full personalized autocomplete response from any page.
// CORS37-002 — VULNERABLE
// ACAO:* appears safe because credentials:true is absent.
// But the endpoint accepts session token as query param — any page can read
// personalized autocomplete once it obtains the session token from any other source.
// skills/autocomplete.router.js
router.get('/autocomplete', async (req, res) => {
res.set('Access-Control-Allow-Origin', '*'); // VULNERABLE: wildcard — readable by any page
// Session resolved from query param if cookie missing (supports iframe widgets)
const session = req.session || await sessionStore.get(req.query.token);
if (!session) {
return res.json({ suggestions: await publicAutocomplete(req.query.q) });
}
// Personalized autocomplete for authenticated users
const suggestions = await autocompleteEngine.suggest({
q: req.query.q,
userId: session.userId,
orgId: session.orgId, // ← includes private skill names from org search history
limit: 10,
});
res.json({ suggestions }); // includes private skill names in suggestion strings
});
// Attacker who has victim's token (from any source):
// fetch(`https://registry.example.com/api/skills/autocomplete?q=auth&token=${victimToken}`)
// .then(r => r.json())
// .then(d => exfil(d.suggestions)); // response readable under ACAO:* — no credentials needed
The token-in-query-param trap: Endpoints that accept credentials via query parameter rather than Cookie or Authorization header break a core assumption of the CORS wildcard rule. The rule assumes that wildcard ACAO endpoints return the same response to all callers because there is no session context. As soon as the endpoint uses a query param for authentication, the wildcard becomes a hole: any page can craft a credentialed request that bypasses the Cookie-based restriction browsers impose on ACAO: * + credentials:true. The fix is never to accept authentication credentials via URL query parameters, particularly on endpoints that return session-personalized data.
// CORS37-002 — FIXED
// 1. Remove query-param token support — cookies and Authorization header only.
// 2. Remove wildcard ACAO — apply allowlist-based CORS from the router.
// 3. For unauthenticated callers, return only public autocomplete results.
// skills/autocomplete.router.js — CORS applied at router level (see CORS37-001 fix)
router.get('/autocomplete', requireSession, async (req, res) => {
// No token-in-query-param: requireSession reads only req.cookies and Authorization header.
const suggestions = await autocompleteEngine.suggest({
q: req.query.q,
userId: req.session.userId,
orgId: req.session.orgId,
limit: 10,
// Return only public skill names in suggestions — never private skill names
// even when personalization ranking promotes them to top results.
filterToPublic: true,
});
res.json({ suggestions });
});
// Public autocomplete (no session) served by a separate, explicitly uncredentialed route:
router.get('/autocomplete/public', (req, res) => {
res.set('Access-Control-Allow-Origin', '*'); // safe: no session scope, no credentials
res.set('Access-Control-Allow-Credentials', 'false');
return publicAutocomplete(req.query.q).then(suggestions => res.json({ suggestions }));
});
CVSS 3.1 approximate score for CORS37-002: 7.4 (HIGH) — AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N. AC:H reflects that the attacker requires the victim’s session token from an independent source before this finding is exploitable. The finding is nonetheless HIGH because the token is obtainable via CORS37-001 or CORS37-004 in a chained attack, and because the autocomplete history contains private skill names that are not available via any public endpoint.
CORS37-003 — Origin reflection before ownership check creates saved-search timing oracle
The save-search endpoint POST /api/skills/search/save stores the current search query and filter state as a named saved search associated with the authenticated user’s account. A secondary read-path endpoint GET /api/skills/search/save/:id retrieves a saved search by ID for sharing or re-running. The vulnerability lies in the CORS handling of the read path: the endpoint calls cors() with origin:true at the top of the handler before it performs the ownership check. Because cors({origin:true}) does not add ACAO: * (it reflects the specific origin), the full CORS exchange including the preflight response happens before the authorization check evaluates whether the requesting user owns the saved search being looked up.
When a saved-search ID exists and belongs to a different user, the CORS headers are still emitted and the ownership failure returns HTTP 403 after a database query that includes a full ownership join. When the saved-search ID does not exist, the CORS headers are emitted but the response returns HTTP 404 after a faster not-found path. The timing difference — consistently 3-4× longer for exists-but-wrong-owner versus not-found — lets a cross-origin attacker probe saved-search IDs without being able to read their content. While the content is not leaked, the oracle reveals the existence of saved searches across all users, including the fact that specific users have saved searches (indicating an active session) and when those searches were created (via ID sequence analysis).
// CORS37-003 — VULNERABLE
// cors() called before ownership check — timing oracle on saved-search ID existence.
// 403 (exists, wrong owner) has different latency profile than 404 (does not exist).
// skills/saved-search.router.js
router.get(
'/save/:id',
cors({ origin: true, credentials: true }), // VULNERABLE: CORS emitted before auth
requireSession,
async (req, res) => {
const saved = await db.savedSearches.findById(req.params.id); // DB round-trip happens first
if (!saved) return res.status(404).json({ error: 'Not found' }); // fast path: ~8ms
if (saved.userId !== req.session.userId)
return res.status(403).json({ error: 'Forbidden' }); // slow path: ~32ms (ownership join)
res.json(saved);
}
);
// Timing oracle exploit:
// for id from 1 to N:
// t0 = performance.now()
// await fetch(`/api/skills/search/save/${id}`, { credentials: 'include', method: 'GET' })
// t1 = performance.now()
// if (t1 - t0 > 20) console.log(`ID ${id} exists (owned by another user)`)
Timing oracles and CORS preflights: Even when CORS fully prevents reading a response body, the timing of the preflight or the latency of the actual request can leak information about server-side state. For ownership-checked endpoints, the check must happen before any database query that has a different latency profile for “exists but forbidden” versus “does not exist.” The pattern is: authenticate → authorize → query. Never: query → authorize → respond.
// CORS37-003 — FIXED
// 1. Auth and ownership check in a single DB query before CORS emission.
// 2. Use WHERE id=$1 AND user_id=$2 — single query that returns nothing if
// the record does not exist OR belongs to a different user.
// Both cases return 404 with identical response time — no timing oracle.
// skills/saved-search.router.js — CORS at router level
router.get('/save/:id', requireSession, async (req, res) => {
// Single query: auth + ownership in one round-trip
const saved = await db.savedSearches.findOne({
where: { id: req.params.id, userId: req.session.userId }, // ownership enforced at query level
});
// Both "not found" and "wrong owner" return 404 — timing is identical
if (!saved) return res.status(404).json({ error: 'Not found' });
res.json(saved);
});
CVSS 3.1 approximate score for CORS37-003: 5.3 (MEDIUM) — AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N. Confidentiality impact is Low (ID existence only, not content) and AC:H reflects the precision required for reliable timing measurement. The finding is elevated from LOW to MEDIUM because the oracle can be used to identify active users and perform targeted follow-on attacks against their sessions.
CORS37-004 — Credential-bearing CORS on search history leaks full query log including private skills
The search history endpoint GET /api/skills/search/history returns a paginated log of all queries the authenticated user has executed, including the query string, the timestamp, the number of results returned, and — most critically — the names of the top results that were clicked through for each query. Because search results include private and draft skills (see CORS37-001), the click-through data in the search history response includes the names of private skills the user has examined, even if those skills were never publicly accessible.
The endpoint uses cors({origin:true,credentials:true}) applied at the router level, exposing the history to any origin the victim visits. Unlike CORS37-001 which requires a live query to discover what is currently available, CORS37-004 provides a retrospective view: an attacker reading the search history can determine which private skills the victim was considering months before the current session, reconstruct the sequence of their evaluation process, and identify which private skills were clicked into (indicating high interest) versus which were skipped. For a competitor who wants to understand an organization’s internal tooling strategy, this is a materially more valuable dataset than the current search results.
// CORS37-004 — VULNERABLE
// cors({origin:true,credentials:true}) on search history — any origin reads full query log
// including private skill names the victim clicked through in prior sessions.
// skills/search-history.router.js
router.get(
'/history',
cors({ origin: true, credentials: true }), // VULNERABLE: reflects any Origin with credentials
requireSession,
async (req, res) => {
const { page = 1, limit = 50 } = req.query;
const history = await db.searchHistory.findByUserId(req.session.userId, {
page,
limit,
includeClickthroughs: true, // ← includes names of private skills the user clicked into
});
res.json(history); // full query log including private skill names from click-throughs
}
);
// Attacker page (any origin, victim session present):
// fetch('https://registry.example.com/api/skills/search/history?limit=200', {
// credentials: 'include'
// })
// .then(r => r.json())
// .then(h => {
// // h.items[*].clickthroughs[*].skillName includes private skill names
// // h.items[*].query reveals evaluation process
// exfil(h);
// });
Click-through data as a secondary information store: Even organizations that correctly scope search results to public-only fail to recognize that click-through logging creates a persistent record of private skill access. If a user clicks into a private skill from search results, the click-through event is recorded with the private skill name at the time of the click. Even if the skill is later deleted or made private, the search history entry retains the name. Search history endpoints must therefore be treated as equivalent in sensitivity to any endpoint that directly returns private skill data — and must have the same CORS controls applied.
// CORS37-004 — FIXED
// 1. Remove per-endpoint cors() call — apply allowlist at router level.
// 2. Strip click-through skill names for skills that are no longer accessible
// to the requesting user's current org (privacy by default after access revocation).
// 3. Never return click-through names for skills the caller cannot currently access.
// skills/search-history.router.js — CORS at router level
router.get('/history', requireSession, async (req, res) => {
const { page = 1, limit = 50 } = req.query;
const history = await db.searchHistory.findByUserId(req.session.userId, {
page: Math.min(parseInt(page) || 1, 100),
limit: Math.min(parseInt(limit) || 50, 200),
});
// For each click-through, verify the skill is still accessible to the user's org
// before returning its name. Skills no longer accessible are redacted to "[redacted]".
const orgId = req.session.orgId;
const enriched = await Promise.all(history.items.map(async item => ({
...item,
clickthroughs: await Promise.all(item.clickthroughs.map(async ct => {
const accessible = await skillAccess.check(ct.skillId, orgId);
return accessible ? ct : { ...ct, skillName: '[redacted]', skillId: null };
})),
})));
res.json({ ...history, items: enriched });
});
CVSS 3.1 approximate score for CORS37-004: 8.1 (HIGH) — AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N. Confidentiality is High because the full retrospective history includes private skill names from multiple past sessions, providing an attacker with a comprehensive intelligence picture of the organization’s internal tooling evaluation process.
Compound attack chain: result leak → autocomplete exposure → ID enumeration → full history dump
The four findings in SA-SKL-CORS37 are individually significant but achieve maximum impact when chained. A single attacker page can execute the full chain in one visit from the victim:
/api/skills/search?q= (empty query returns all results) and receives the full set of skills visible to the victim’s org, including private and draft skills. This provides an immediate snapshot of the organization’s internal tooling inventory.
The end state of this chain: the attacker has a comprehensive, timestamped log of the organization’s internal tooling discovery process — both current and historical — achieved silently during a single page visit with no indicator visible to the victim or the registry operator.
Detection with tree-sitter AST queries
SkillAudit’s static scanner identifies the CORS37 family using three AST-level queries targeting cors({origin:true,credentials:true}) on search and history endpoints, wildcard ACAO on personalized endpoints, and CORS emission before ownership checks:
; Query 1 — cors({origin:true,credentials:true}) on search or history handler
(call_expression
function: (identifier) @fn (#eq? @fn "cors")
arguments: (arguments
(object
(pair key: (property_identifier) @ok (#eq? @ok "origin")
value: (true))
(pair key: (property_identifier) @ck (#eq? @ck "credentials")
value: (true)))))
(#match? @fn ".*") @cors_call
(call_expression
function: (member_expression
object: (identifier) @router
property: (property_identifier) @method (#match? @method "get|use"))
arguments: (arguments
(string) @path (#match? @path "search|history|autocomplete|suggest")
(call_expression function: (identifier) @cors_ref (#eq? @cors_ref "cors")) @cors_inline))
; Query 2 — ACAO:* set via res.set on endpoint serving personalized data
(call_expression
function: (member_expression
object: (identifier) @res (#eq? @res "res")
property: (property_identifier) @set_fn (#eq? @set_fn "set"))
arguments: (arguments
(string) @header (#match? @header "(?i)access-control-allow-origin")
(string) @value (#eq? @value "*")))
(identifier) @session_read (#match? @session_read "req\\.session|req\\.query\\.token")
; Query 3 — CORS emitted before ownership check (cors() call before findById + ownership if)
(call_expression
function: (identifier) @cors_fn (#eq? @cors_fn "cors")
arguments: (arguments (object) @opts)) @cors_early
(call_expression
function: (member_expression
property: (property_identifier) @db_fn (#match? @db_fn "findById|findOne|get"))
arguments: (arguments (member_expression
object: (member_expression
object: (identifier) @params
property: (property_identifier) @id_prop (#eq? @id_prop "params"))))) @db_query
(if_statement
condition: (binary_expression
left: (member_expression property: (property_identifier) @id_check)
operator: "!=="
right: (member_expression
object: (member_expression
object: (identifier) @session (#eq? @session "req")
property: (property_identifier) @sess_prop (#eq? @sess_prop "session"))
property: (property_identifier) @user_id (#match? @user_id "userId|user_id|uid")))) @ownership_check
Operator checklist: 10 controls for CORS-safe search and autocomplete endpoints
- All search and autocomplete endpoints use an explicit
Set-based CORS allowlist —origin:trueand wildcards are absent from every route in the search router. - CORS configuration is applied once at the router level, not per-endpoint, to prevent bypass via any endpoint that shares the router without its own CORS handler.
- No endpoint in the search surface accepts authentication credentials via URL query parameters;
?token=patterns are absent from all search, autocomplete, and history handlers. - Personalized and org-scoped search results are gated behind
requireSessionand return only public skills for unauthenticated or external callers. - Click-through data stored in search history is re-validated against current org access permissions before returning; skills no longer accessible to the caller’s org are redacted to
[redacted]. - Saved-search lookup uses a single
WHERE id=$1 AND user_id=$2query; “not found” and “wrong owner” return identical HTTP 404 responses with identical latency profiles, eliminating timing oracles. - Autocomplete suggestions served to authenticated users are filtered to public skill names only; private skill names are never included in suggestion strings even when personalization ranking would otherwise promote them.
- Public autocomplete (no session) is served from a separate route with explicit
ACAO: *andACAC: false; it shares no handler code with the personalized route. - CORS configuration is enforced by integration tests: each search, autocomplete, and history endpoint is called from an unlisted origin and asserted to return HTTP 403 or no CORS headers, not a reflected origin.
- Search history pagination is capped (
limit ≤ 200,page ≤ 100) and history older than 90 days is purged; limiting retained history bounds the value of a successful CORS37-004 exfiltration.
Related findings in this series
- SA-SKL-CORS36 — CORS misconfiguration in audit result caching and diff comparison endpoints
- SA-SKL-CORS35 — CORS misconfiguration in team invitation and member onboarding endpoints
- SA-SKL-DESER22 — Insecure deserialization in skill dependency graph and version resolution endpoints