Claude MCP skill privilege escalation — skill audit report and compliance export endpoints — SA-SKL-PRIVESC38
SA-SKL-PRIVESC38 documents four privilege escalation vulnerabilities in MCP skill registry skill audit report and compliance export endpoints. Audit reports represent the most sensitive data a security-focused registry produces: they contain full vulnerability findings, remediation timelines, unpatched security debt, and compliance gap analysis for every organization using the registry. Access to another organization's compliance audit report is not just a data breach — it is a roadmap for targeting that organization's unpatched infrastructure. PRIVESC38-001 exploits a JWT claim that carries the user's audit report access level, allowing any user to forge a compliance_admin level and read all organizations' full audit reports. PRIVESC38-002 exploits a missing boundary check on report export that allows any user to export at any access level. PRIVESC38-003 exploits a missing ownership check on report visibility that exposes remediation timelines publicly. PRIVESC38-004 exploits a cache key collision that serves previously issued share tokens to new reports with the same sequential integer ID.
auditReportLevel claim; craft JWT with auditReportLevel:'compliance_admin' grants access to all organizations' full compliance audit reports including remediation timelines and security debt details; fix: DB-backed 60s Map cache keyed on userId+reportId; JWT carries only sub; invalidate on level change eventPOST /api/audit/reports missing access level boundary check; any user exports audit reports at compliance_admin level gaining access to remediation details and risk scores not authorized for their subscription tier; fix: requireSession; validate requested report level does not exceed account's authorized level; Zod AuditReportLevelSchema; audit logPATCH /api/audit/reports/:id/visibility missing ownership check; any authenticated user changes any organization's audit report visibility from private to public, exposing remediation timelines, unpatched vulnerabilities, and security debt scores to external parties; fix: require report.orgId matches req.session.orgId OR compliance_admin role; requireSession; audit logreportId without orgId; share token cache entries bleed across report deletion and recreation; previously issued share tokens for deleted reports access new reports with same sequential integer ID during 60s recreation window; fix: cache key = orgId:reportId; invalidate on report deletion; strict 60s TTLPRIVESC38-001 — JWT auditReportLevel claim forging grants compliance_admin access
Severity: CRITICAL
The audit report access control system reads the user's access level from a custom claim in the JWT access token: auditReportLevel. This claim is set at login time and embedded in the signed JWT. However, the JWT signing secret is shared across authentication environments and has leaked via a previous misconfiguration (or the attacker uses one of the other PRIVESC38 vectors to gain a low-privilege account and observes their own token structure). An attacker crafts a new JWT with auditReportLevel: 'compliance_admin' and signs it with the leaked or brute-forced secret. The forged token passes JWT signature verification. The audit report endpoint reads the access level from the token claim and grants full compliance_admin access — including read access to every organization's audit reports, remediation timelines, unpatched vulnerability lists, and security debt scores. The fix removes all authorization data from the JWT and replaces it with a DB-backed access level cache keyed on userId+reportId, ensuring the access level is always authoritative from the database regardless of token contents.
// Audit report endpoint — reads access level from JWT claim
router.get('/api/audit/reports/:id', requireSession, async (req, res) => {
const { auditReportLevel } = req.user; // from JWT payload — attacker-controlled
if (auditReportLevel !== 'compliance_admin') {
return res.status(403).json({ error: 'Insufficient access level' });
}
const report = await AuditReport.findById(req.params.id).populate('findings');
return res.json(report);
});
// Audit report endpoint — DB-backed access level cache; JWT carries only sub
const accessLevelCache = new Map(); // userId+reportId -> { level, expiresAt }
const CACHE_TTL_MS = 60_000;
async function getAccessLevel(userId, reportId) {
const key = `${userId}:${reportId}`;
const cached = accessLevelCache.get(key);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const grant = await AccessGrant.findOne({ userId, reportId });
const level = grant?.level ?? 'none';
accessLevelCache.set(key, { level, expiresAt: Date.now() + CACHE_TTL_MS });
return level;
}
router.get('/api/audit/reports/:id', requireSession, async (req, res) => {
const level = await getAccessLevel(req.session.userId, req.params.id);
if (level !== 'compliance_admin' && level !== 'report_reader') {
return res.status(403).json({ error: 'Insufficient access level' });
}
const report = await AuditReport.findById(req.params.id)
.select(level === 'compliance_admin' ? '' : '-findings.remediationTimeline -securityDebt');
return res.json(report);
});
PRIVESC38-002 — Missing access level boundary check on report export endpoint
Severity: HIGH
The POST /api/audit/reports endpoint accepts a reportLevel parameter from the request body that specifies which access tier's data to include in the export. The endpoint does not validate that the requested report level falls within the range authorized for the calling account's subscription tier. A user subscribed to the basic tier (which provides access only to aggregate scores, not individual findings) submits a request with reportLevel: 'compliance_admin'. The endpoint creates and returns an audit report at the compliance_admin level — including full finding details, remediation timelines, risk scores, and compliance gap analysis — without verifying that the caller's subscription authorizes this level. The exported report contains the same content as a full compliance audit sold at a significant premium, freely obtained via a parameter override. The fix validates that req.body.reportLevel does not exceed the account's maxAuthorizedReportLevel from the database.
Never trust client-supplied tier or access level parameters. Any request body field that maps to a permission tier — reportLevel, planTier, accessLevel, subscriptionTier — must be validated against the caller's authoritative tier from the database. Client-side tier claims are always attacker-controlled.
// Audit report export — missing boundary check on requested report level
router.post('/api/audit/reports', requireSession, async (req, res) => {
const { skillId, reportLevel } = req.body; // reportLevel from client — attacker sets 'compliance_admin'
const report = await generateAuditReport(skillId, reportLevel); // generates at any level
return res.status(201).json(report);
});
// Audit report export — boundary check: requested level must not exceed authorized level
const AuditReportLevelSchema = z.object({
skillId: z.string().uuid(),
reportLevel: z.enum(['basic', 'standard', 'full', 'compliance_admin']),
});
const LEVEL_ORDER = ['basic', 'standard', 'full', 'compliance_admin'];
router.post('/api/audit/reports', requireSession, async (req, res) => {
const parsed = AuditReportLevelSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid request' });
const account = await Account.findOne({ userId: req.session.userId });
const authorizedIdx = LEVEL_ORDER.indexOf(account.maxAuthorizedReportLevel);
const requestedIdx = LEVEL_ORDER.indexOf(parsed.data.reportLevel);
if (requestedIdx > authorizedIdx) {
return res.status(403).json({ error: 'Requested report level exceeds account authorization' });
}
const report = await generateAuditReport(parsed.data.skillId, parsed.data.reportLevel);
await AuditLog.create({ action: 'report.exported', userId: req.session.userId, reportId: report.id, level: parsed.data.reportLevel });
return res.status(201).json(report);
});
PRIVESC38-003 — Missing ownership check on report visibility exposes remediation timelines
Severity: HIGH
The PATCH /api/audit/reports/:id/visibility endpoint does not verify that the caller belongs to the organization that owns the target audit report. Any authenticated user can send a request changing any organization's audit report visibility from private to public. Once a report's visibility is set to public, it becomes accessible via the registry's public audit report index — any visitor can read the report's full content including remediation timelines, unpatched vulnerability details, and security debt scores. This is equivalent to publishing another organization's confidential security assessment without their consent. The attack requires only a valid authentication token — no elevated permissions — and the target report's integer ID, which is sequential and trivially enumerable. The fix requires that the caller's session organization ID matches the report's organization ID, with an exception for compliance_admin role.
// Report visibility — missing ownership check
router.patch('/api/audit/reports/:id/visibility', requireSession, async (req, res) => {
const { visibility } = req.body;
// No check that req.session.orgId matches report.orgId
await AuditReport.updateOne({ _id: req.params.id }, { visibility });
return res.json({ updated: true });
});
// Report visibility — ownership check + audit log
const VisibilitySchema = z.object({ visibility: z.enum(['private', 'org', 'public']) });
router.patch('/api/audit/reports/:id/visibility', requireSession, async (req, res) => {
const parsed = VisibilitySchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid visibility value' });
const report = await AuditReport.findById(req.params.id);
if (!report) return res.status(404).json({ error: 'Not found' });
const isAdmin = req.session.role === 'compliance_admin';
const isOwner = report.orgId.toString() === req.session.orgId;
if (!isOwner && !isAdmin) return res.status(403).json({ error: 'Forbidden' });
await report.updateOne({ visibility: parsed.data.visibility });
await AuditLog.create({
action: 'report.visibility.changed',
reportId: report.id,
orgId: report.orgId,
changedBy: req.session.userId,
from: report.visibility,
to: parsed.data.visibility,
});
return res.json({ updated: true });
});
PRIVESC38-004 — Share token cache key collision enables cross-report token reuse
Severity: HIGH
The audit report share token cache uses reportId alone as the cache key. When an organization deletes an audit report (ID 1042) and a different organization creates a new report that receives the same sequential integer ID (1042), the cache still holds the previously issued share tokens for the deleted report under the key 1042. For up to 60 seconds — the cache TTL — anyone who holds the previously issued share token for the deleted report can present that token to the share token validation endpoint and gain read access to the new organization's report. The 60-second window is sufficient to exploit in automated attacks: a script that monitors report creation events and immediately presents share tokens for previously observed IDs can reliably access new reports in the collision window. The fix includes orgId in the cache key (orgId:reportId) and explicitly invalidates the cache entry when a report is deleted, eliminating the collision window entirely.
// Share token validation — cache key uses only reportId const shareTokenCache = new Map(); // reportId -> Setasync function validateShareToken(reportId, token) { const cached = shareTokenCache.get(reportId); // key = reportId alone if (cached?.has(token)) return true; // bleeds across org boundaries after ID reuse const record = await ShareToken.findOne({ reportId, token }); if (record) shareTokenCache.set(reportId, (cached ?? new Set()).add(token)); return !!record; }
// Share token validation — cache key includes orgId; invalidate on report deletion const shareTokenCache = new Map(); // orgId:reportId -> Setasync function validateShareToken(orgId, reportId, token) { const key = `${orgId}:${reportId}`; // org-scoped key prevents cross-org bleed const cached = shareTokenCache.get(key); if (cached?.has(token)) return true; const record = await ShareToken.findOne({ orgId, reportId, token }); // orgId in query if (record) { const existing = shareTokenCache.get(key) ?? new Set(); existing.add(token); shareTokenCache.set(key, existing); setTimeout(() => shareTokenCache.delete(key), 60_000); // strict 60s TTL } return !!record; } // Invalidate cache on report deletion async function deleteReport(orgId, reportId) { await AuditReport.deleteOne({ _id: reportId, orgId }); shareTokenCache.delete(`${orgId}:${reportId}`); // explicit invalidation await ShareToken.deleteMany({ reportId, orgId }); }
Remediation summary
| Finding | Severity | Primary remediation | Secondary hardening |
|---|---|---|---|
| PRIVESC38-001 | Critical | Remove authorization data from JWT; DB-backed access level cache keyed on userId+reportId; invalidate on level change; JWT carries only sub | Rotate JWT signing secret; audit all JWT claim reads for authorization data; enforce sub-only token policy |
| PRIVESC38-002 | High | Validate requested reportLevel against account's maxAuthorizedReportLevel from DB; Zod AuditReportLevelSchema; audit log all exports | Alert on export requests that hit the boundary check; review subscription tier enforcement across all export endpoints |
| PRIVESC38-003 | High | Require report.orgId matches req.session.orgId OR compliance_admin role; requireSession; audit log all visibility changes with from/to values | Alert on visibility changes to 'public' for reports with high security debt scores; review all PATCH routes for missing ownership checks |
| PRIVESC38-004 | High | Cache key = orgId:reportId; invalidate on report deletion; strict 60s TTL with explicit setTimeout deletion | Use UUIDs for report IDs to eliminate sequential enumeration; audit share token issuance and validation logs for anomalous cross-org patterns |
Scan your MCP skill registry audit report and compliance export endpoints for PRIVESC38 patterns. SkillAudit checks JWT claim usage for authorization data, access level boundary enforcement, ownership checks on visibility mutation endpoints, and cache key scoping for share token validation. See also SA-SKL-PRIVESC37 and SA-SKL-PRIVESC36. Connect at skillaudit.dev.