Claude MCP skill privilege escalation — skill audit history and report access control endpoints — SA-SKL-PRIVESC27
SA-SKL-PRIVESC27 documents four privilege escalation vulnerabilities in MCP skill registry audit history and report access control endpoints. Audit history endpoints are particularly sensitive access control targets because they store the security investigation record of an organization — the evidence trail that shows which skills were audited, what vulnerabilities were found, and what remediation steps were taken. Cross-organizational access to audit history constitutes a competitive intelligence breach and a compliance violation for organizations under SOC 2 or ISO 27001. PRIVESC27-001 reads audit access level from a JWT claim, enabling system-wide access via crafted tokens. PRIVESC27-002 is missing org-scoping on the audit list endpoint, enabling cross-org enumeration. PRIVESC27-003 is missing an ownership check on audit report visibility changes. PRIVESC27-004 is a share token cache bleed across report ID reuse after deletion.
auditAccessLevel claim — craft JWT with auditAccessLevel:'unrestricted' grants access to all org audit histories system-wide; fix: DB-backed 60s Map cache keyed on userId+orgId; JWT carries only sub; invalidate on role changeGET /api/audits missing org scoping — any authenticated user retrieves any org's audit report list by enumerating auditId; fix: requireSession; enforce WHERE orgId = req.session.orgId; validate auditId ownership before returning; Zod AuditIdSchemaPATCH /api/audits/:id/visibility missing ownership check — any org member changes any audit report's visibility from private to public across all orgs; fix: require audit belongs to req.session.orgId; requireRole('admin'); audit logreportId without orgId — share token cache entries bleed across report ID reuse after deletion; fix: cache key = orgId:reportId; invalidate on deletion; strict 30s TTL; use UUID for report IDsPRIVESC27-001 — JWT auditAccessLevel claim grants system-wide audit history access
The audit history access control system reads the auditAccessLevel field directly from the decoded JWT payload to determine what scope of audit history a user can access. Because JWT payloads are user-controlled (they can be crafted by anyone with a valid signing key — including the user themselves if JWTs are symmetric-key signed — or forged entirely if the key is weak or leaked), an attacker can craft a JWT with auditAccessLevel: 'unrestricted'. The server decodes this JWT, reads the unrestricted value, and grants the attacker access to audit histories from all organizations in the system — including the security investigation records, vulnerability findings, and remediation status for every private skill in the registry.
The JWT claim attack vector is a well-known anti-pattern, but it recurs specifically in audit history systems because those systems are frequently built after the core RBAC layer, by developers who extend the JWT with new custom claims rather than adding new DB-backed authorization checks. The JWT becomes a de-facto capability token rather than an identity token, and any claim that can be added by an authorized user (during account setup, during privilege grant flows, or via a JWT mutation vulnerability elsewhere in the system) becomes an escalation path.
PRIVESC27-001 fix: Remove the auditAccessLevel claim from the JWT entirely. Replace it with a DB-backed lookup: on each audit history request, query the roles table for the requesting user's current audit access level, using an in-process Map cache with a 60-second TTL keyed on userId+orgId. Invalidate the cache entry whenever a role change event is processed. The JWT should carry only the subject (sub) claim — all authorization decisions must come from the database, not from claims the user controls.
// Audit access level from JWT — attacker crafts auditAccessLevel:'unrestricted'
router.get('/audits',
requireSession,
async (req, res) => {
const { auditAccessLevel } = req.user; // read from JWT payload
if (auditAccessLevel === 'unrestricted') {
return res.json(await db.getAllAudits()); // ALL org audit histories
}
res.json(await db.getOrgAudits(req.session.orgId));
}
);
const auditAccessCache = new Map(); // userId+orgId → { level, expiresAt }
async function getAuditAccessLevel(userId, orgId) {
const key = `${userId}:${orgId}`;
const cached = auditAccessCache.get(key);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const level = await db.getUserAuditAccessLevel(userId, orgId); // DB lookup, not JWT
auditAccessCache.set(key, { level, expiresAt: Date.now() + 60_000 });
return level;
}
router.get('/audits',
requireSession,
async (req, res) => {
// JWT carries only sub — no auditAccessLevel claim to forge
const level = await getAuditAccessLevel(req.session.userId, req.session.orgId);
// level is 'standard' for all non-admin users; 'admin' for org admins only
// 'unrestricted' is never assigned; system-wide access requires super_admin role
const audits = await db.getOrgAudits(req.session.orgId, level);
res.json(audits);
}
);
PRIVESC27-002 — Missing org scoping on audit list allows cross-org enumeration
The GET /api/audits endpoint returns audit reports by auditId without enforcing that the requested audit belongs to the requesting user's organization. Any authenticated user — including users on a Free plan who have only run a single public audit — can enumerate audit reports from other organizations by iterating through sequential or guessable audit IDs. Each audit report contains the full findings for the scanned skill, including vulnerability details, severity grades, and remediation recommendations that the target organization has not yet addressed. For enterprise organizations under non-disclosure or competitive sensitivity requirements, their unpublished audit findings are exposed to any authenticated user.
PRIVESC27-002 fix: Add WHERE orgId = req.session.orgId to all audit queries. For individual report fetches by ID, validate ownership before returning the report. Use UUIDs for audit IDs to prevent sequential enumeration. Validate the auditId parameter with Zod AuditIdSchema before processing.
// WRONG — no org scoping; any authenticated user reads any org's audits
router.get('/audits/:auditId',
requireSession,
async (req, res) => {
const audit = await db.query('SELECT * FROM audits WHERE id = ?', [req.params.auditId]);
res.json(audit); // returns any org's private audit report
}
);
// RIGHT — ownership check before return; Zod ID validation
router.get('/audits/:auditId',
requireSession,
async (req, res) => {
const id = AuditIdSchema.parse(req.params.auditId); // validates UUID format
const audit = await db.query(
'SELECT * FROM audits WHERE id = ? AND org_id = ?',
[id, req.session.orgId] // org scoping enforced at query level
);
if (!audit) return res.status(404).json({ error: 'not found' });
res.json(audit);
}
);
PRIVESC27-003 — Missing ownership check on audit visibility change
The audit report visibility endpoint PATCH /api/audits/:id/visibility allows changing an audit report from private to public (making it visible in the public audit gallery) or back to private. The endpoint is missing an ownership check: any authenticated org member can change the visibility of any audit report in the system, regardless of which organization owns it. An attacker can use this to force-publish private audit reports from other organizations — exposing their unpublished vulnerability findings — or to force-privatize public audit reports from organizations that have published them as social proof, removing their public trust signal.
PRIVESC27-003 fix: Before applying the visibility change, verify that the audit report's orgId matches req.session.orgId. Require requireRole('admin') since visibility changes have significant consequences. Emit an audit log entry for every visibility change — forced publication of private security findings is a serious compliance event and needs to be traceable.
// WRONG — no ownership check; any member changes any audit's visibility
router.patch('/audits/:id/visibility',
requireSession,
async (req, res) => {
await db.query('UPDATE audits SET visibility = ? WHERE id = ?',
[req.body.visibility, req.params.id]);
res.json({ ok: true });
}
);
// RIGHT — ownership check + admin role + audit log
router.patch('/audits/:id/visibility',
requireSession,
requireRole('admin'),
async (req, res) => {
const audit = await db.getAudit(req.params.id);
if (!audit || audit.orgId !== req.session.orgId) {
return res.status(403).json({ error: 'forbidden' });
}
const previous = audit.visibility;
await db.query('UPDATE audits SET visibility = ? WHERE id = ? AND org_id = ?',
[req.body.visibility, req.params.id, req.session.orgId]); // org-scoped UPDATE
await audit.log('audit_visibility_changed', {
auditId: req.params.id,
orgId: req.session.orgId,
from: previous,
to: req.body.visibility,
changedBy: req.session.userId
});
res.json({ ok: true });
}
);
PRIVESC27-004 — Share token cache bleed across report ID reuse after deletion
The audit report share token cache uses reportId alone as the cache key — without including orgId. When an audit report is deleted and a new report is created that reuses the same sequential integer ID (a common behavior in registries that use auto-increment primary keys), the cache still contains the previous report's share tokens under that ID. If the new report is owned by a different organization (or by a different user within the same organization), the cached share tokens from the deleted report are served as valid tokens for the new report. An attacker who obtained a share token for their own report (which was then deleted) can use that token to access the new report that reuses the same ID.
PRIVESC27-004 fix: Include orgId in the share token cache key: orgId:reportId. Invalidate all cache entries for a report when it is deleted. Apply a strict 30-second TTL rather than relying on explicit invalidation alone. Switch to UUIDs or ULIDs for report IDs to make ID reuse practically impossible — a UUID colliding with a previous UUID is negligible probability, eliminating the cache bleed attack surface entirely.
// WRONG — cache key uses reportId only; deleted report's tokens bleed to new report with same ID
const shareToken = shareTokenCache.get(reportId); // bleeds across org boundary if ID reused
// RIGHT — cache key includes orgId; invalidate on deletion; UUID report IDs; 30s TTL
const SHARE_TOKEN_TTL = 30_000;
const shareTokenCache = new Map(); // key: orgId:reportId → { tokens, expiresAt }
function getShareTokenCacheKey(orgId, reportId) {
return `${orgId}:${reportId}`;
}
async function getShareTokens(orgId, reportId) {
const key = getShareTokenCacheKey(orgId, reportId);
const cached = shareTokenCache.get(key);
if (cached && cached.expiresAt > Date.now()) return cached.tokens;
const tokens = await db.getShareTokens(reportId, orgId); // org-scoped DB query
shareTokenCache.set(key, { tokens, expiresAt: Date.now() + SHARE_TOKEN_TTL });
return tokens;
}
async function invalidateShareTokenCache(orgId, reportId) {
shareTokenCache.delete(getShareTokenCacheKey(orgId, reportId));
}
// Called when a report is deleted:
await db.deleteReport(reportId); // uses UUID, not sequential int
await invalidateShareTokenCache(orgId, reportId); // explicit cache invalidation on delete
SkillAudit scans for JWT claim-based authorization in audit history endpoints, missing org-scoped WHERE clauses on audit queries, unguarded visibility mutation handlers, and cache key patterns that omit orgId — across all audit history and report access control code paths in your MCP skill registry.
Scan your registry| Finding | Severity | Root cause | Impact |
|---|---|---|---|
| PRIVESC27-001 | CRITICAL | Audit access level read from JWT auditAccessLevel claim | Crafted JWT with unrestricted value grants access to all org audit histories system-wide |
| PRIVESC27-002 | CRITICAL | Missing WHERE orgId = req.session.orgId on audit list query | Any authenticated user reads any org's private audit reports by enumerating audit IDs |
| PRIVESC27-003 | CRITICAL | Missing ownership check on audit visibility PATCH | Any org member force-publishes private audit findings or removes public trust signals from other orgs |
| PRIVESC27-004 | HIGH | Share token cache key uses reportId without orgId | Deleted report's share tokens served to new report with same sequential ID; cross-org share token bleed |
See also: SA-SKL-PRIVESC26 (API key and service account privilege escalation patterns) for JWT claim-based escalation in API key scope management and the same cache key cross-contamination pattern in service account permissions.