← Security advisories

Claude MCP skill privilege escalation — skill audit history and report access control endpoints — SA-SKL-PRIVESC33

SA-SKL-PRIVESC33 documents four privilege escalation vulnerabilities in MCP skill registry audit history and report access control endpoints. These endpoints govern who can read audit history across organizational boundaries, what visibility state an audit report can have, and which share tokens grant time-limited access to private report contents. The vulnerabilities allow an attacker to escalate from a standard authenticated session to full admin-level audit report access across all organizations, enumerate other organizations' private security findings and remediation status, force-publish private audit reports exposing a competitor's security vulnerabilities to the public marketplace, and exploit report share token cache bleed to access new reports using expired tokens from deleted reports with the same sequential integer ID.

SA-SKL-PRIVESC33 findings at a glance
CRITICALPRIVESC33-001 — audit report access level read from JWT auditReportScope claim — craft JWT with auditReportScope:'admin' grants access to all organizations' full audit reports including private security findings; fix: DB-backed 60s Map cache keyed on userId+reportId; JWT carries only sub; invalidate on scope change event
CRITICALPRIVESC33-002 — GET /api/skills/:id/audit-history missing org scoping — any authenticated user reads full audit history for any skill across all organizations, enumerating private security findings and remediation status; fix: requireSession; validate skill.orgId === req.session.orgId; Zod AuditHistoryQuerySchema
CRITICALPRIVESC33-003 — PATCH /api/skills/:id/audit-reports/:reportId/visibility missing ownership check — any authenticated user force-publishes any organization's private audit report, exposing their security vulnerabilities to the public marketplace
HIGHPRIVESC33-004 — audit report share token cache key uses reportId without orgId — share tokens bleed across report deletion and recreation: deleted report's share tokens served to new report with same sequential integer ID, granting access to new report's contents to expired share token holders

PRIVESC33-001 — JWT auditReportScope claim escalation grants admin access to all organizations' audit reports

Severity: CRITICAL

The audit report access control layer reads the caller's audit report scope from a JWT claim named auditReportScope rather than from a server-side database lookup. The JWT is validated for signature authenticity but no server-side scope record is consulted: whatever scope string is present in the JWT payload is used directly to authorize access. An attacker who crafts a JWT with the same issuer and signing key (available via a key disclosure vulnerability or a misconfigured JWT library) and sets auditReportScope: 'admin' can read the full contents of every audit report across all organizations in the registry — including private security findings that organizations have not disclosed publicly, unresolved vulnerability details with active exploitation potential, and remediation status that reveals which organizations have not yet fixed known CVEs.

Vulnerable
// reports/access.js
function checkAuditReportAccess(req, reportId) {
  const { auditReportScope } = req.jwt.payload; // read directly from JWT — forgeable
  if (auditReportScope === 'admin') return true;
  if (auditReportScope === 'org') return req.jwt.payload.orgId === getReportOrgId(reportId);
  return false;
}
Fixed
// reports/access.js
// DB-backed scope cache: scope is always read from the database, never from JWT claims
const scopeCache = new Map(); // key: userId:reportId → { scope, expiresAt }

async function checkAuditReportAccess(req, reportId) {
  const cacheKey = `${req.session.userId}:${reportId}`;
  const cached = scopeCache.get(cacheKey);
  if (cached && cached.expiresAt > Date.now()) return evaluateScope(cached.scope, req, reportId);

  // Always fetch scope from DB — JWT carries only sub, never scope claims
  const scopeRecord = await AuditReportScope.findOne({
    userId: req.session.userId,
    reportId,
  });

  const scope = scopeRecord?.scope ?? 'none';
  scopeCache.set(cacheKey, { scope, expiresAt: Date.now() + 60_000 }); // 60s TTL
  return evaluateScope(scope, req, reportId);
}

// Invalidate cache entry on scope change events (called from admin scope management routes)
function invalidateScopeCache(userId, reportId) {
  scopeCache.delete(`${userId}:${reportId}`);
}

Authorization claims in JWTs are not safe for server-side access decisions. JWTs are designed to carry identity claims (sub, email, iat) that the token issuer attests to. Using them to carry authorization scope (admin, read:all) creates a brittle dependency on JWT secrecy: any key disclosure or algorithm confusion attack immediately becomes a full privilege escalation. Keep JWTs thin — carry only sub — and resolve all authorization from the database on each request, optionally caching with a short TTL.

PRIVESC33-002 — Missing org scoping on audit history exposes private security findings across all organizations

Severity: CRITICAL

The GET /api/skills/:id/audit-history endpoint authenticates the caller but does not enforce org-scoping on the audit history query: any authenticated user with a valid session can supply any skillId in the path and receive the complete audit history for that skill, regardless of which organization owns it. The audit history includes every audit run result, severity breakdowns, individual finding details with CVE references, and remediation timestamps — the full record of what security vulnerabilities a skill has had and which ones remain unresolved.

An attacker who is a registered user of the registry can enumerate audit history across all competitor organizations' skills, identifying which competitors have known unresolved critical vulnerabilities (useful for competitive positioning), which competitors have recently failed compliance audits (useful for sales conversations), and which specific CVEs affect competitor skills (useful for targeted exploitation).

Vulnerable
// reports/history.js
router.get('/:id/audit-history', requireSession, async (req, res) => {
  // No org scoping — returns audit history for any skillId
  const history = await AuditHistory.find({ skillId: req.params.id }).sort({ createdAt: -1 });
  return res.json(history);
});
Fixed
// reports/history.js
const { z } = require('zod');

const AuditHistoryQuerySchema = z.object({
  limit: z.coerce.number().int().min(1).max(100).default(20),
  offset: z.coerce.number().int().min(0).default(0),
});

router.get('/:id/audit-history', requireSession, async (req, res) => {
  // Verify the skill belongs to the requesting user's organization
  const skill = await Skill.findOne({
    _id: req.params.id,
    orgId: req.session.orgId,  // org scoping enforced in query
  });
  if (!skill) return res.status(404).json({ error: 'Not found' });

  const { limit, offset } = AuditHistoryQuerySchema.parse(req.query);

  const history = await AuditHistory.find({ skillId: skill._id })
    .sort({ createdAt: -1 })
    .skip(offset)
    .limit(limit);

  return res.json(history);
});

PRIVESC33-003 — Missing ownership check on report visibility allows force-publishing private audit reports

Severity: CRITICAL

The PATCH /api/skills/:id/audit-reports/:reportId/visibility endpoint accepts a visibility body field set to 'public' or 'private' and updates the report's visibility state. The endpoint validates that the caller is authenticated but does not check that the skill or report belongs to the caller's organization. Any authenticated user can set any organization's private audit report to 'public', immediately making the full report contents — including unredacted finding details, vulnerability proofs-of-concept, and remediation status — visible in the public marketplace. This is equivalent to forcing a competitor to publish their security audit results without consent.

Vulnerable
// reports/visibility.js
router.patch('/:id/audit-reports/:reportId/visibility', requireSession, async (req, res) => {
  // No ownership check — any authenticated user can change any report's visibility
  const report = await AuditReport.findById(req.params.reportId);
  if (!report) return res.status(404).json({ error: 'Not found' });
  report.visibility = req.body.visibility;
  await report.save();
  return res.json({ visibility: report.visibility });
});
Fixed
// reports/visibility.js
const { z } = require('zod');
const VisibilitySchema = z.object({ visibility: z.enum(['public', 'private']) });

router.patch('/:id/audit-reports/:reportId/visibility', requireSession, async (req, res) => {
  // Ownership check: skill must belong to the requesting user
  const skill = await Skill.findOne({
    _id: req.params.id,
    ownerId: req.session.userId,  // ownership enforced
  });
  if (!skill) return res.status(404).json({ error: 'Not found' });

  const report = await AuditReport.findOne({
    _id: req.params.reportId,
    skillId: skill._id,           // report must belong to this skill
  });
  if (!report) return res.status(404).json({ error: 'Not found' });

  const { visibility } = VisibilitySchema.parse(req.body);
  report.visibility = visibility;
  await report.save();

  await AuditLog.create({
    action: 'report.visibility.changed',
    reportId: report._id,
    skillId: skill._id,
    actorId: req.session.userId,
    newVisibility: visibility,
    timestamp: new Date(),
  });

  return res.json({ visibility: report.visibility });
});

PRIVESC33-004 — Report share token cache bleed across report deletion and recreation

Severity: HIGH

The audit report share token system caches share token lookups in a server-side Map with the cache key set to reportId alone — without the organization ID. Report IDs are sequential integers allocated by an auto-increment database column. When an audit report is deleted and a new report is created for a different organization's skill, the new report receives the next integer ID, which may be the same integer as the previously deleted report if the deletion and recreation occur within the 60-second cache TTL window.

An attacker who holds a share token for a deleted report (legitimately issued before deletion, or obtained through a companion vulnerability) can present that token within the 60-second window after a new report with the same integer ID is created. The cache lookup finds the old token entry keyed on reportId, validates it as matching, and serves the new report's contents to the token holder — granting unauthorized access to a different organization's audit report without any credential escalation.

Vulnerable
// reports/share-tokens.js
const tokenCache = new Map(); // key: reportId (integer) — vulnerable to bleed

async function validateShareToken(reportId, token) {
  const cacheKey = String(reportId);
  const cached = tokenCache.get(cacheKey);
  if (cached && cached.token === token && cached.expiresAt > Date.now()) {
    return true; // served from cache — may be for a different org's new report
  }
  const record = await ShareToken.findOne({ reportId, token, expiresAt: { $gt: new Date() } });
  if (record) {
    tokenCache.set(cacheKey, { token, expiresAt: record.expiresAt.getTime() });
    return true;
  }
  return false;
}
Fixed
// reports/share-tokens.js
const tokenCache = new Map(); // key: orgId:reportId — no cross-org bleed

async function validateShareToken(orgId, reportId, token) {
  const cacheKey = `${orgId}:${reportId}`; // orgId scopes the cache key
  const cached = tokenCache.get(cacheKey);
  if (cached && cached.token === token && cached.expiresAt > Date.now()) {
    // Always verify orgId matches before serving from cache
    if (cached.orgId !== orgId) {
      tokenCache.delete(cacheKey);
      return false;
    }
    return true;
  }

  // DB lookup: token must match both reportId AND orgId
  const record = await ShareToken.findOne({
    reportId,
    orgId,     // orgId enforced in DB query — prevents cross-org token reuse
    token,
    expiresAt: { $gt: new Date() },
  });

  if (record) {
    tokenCache.set(cacheKey, { token, orgId, expiresAt: record.expiresAt.getTime() });
    return true;
  }
  return false;
}

// Called when a report is deleted — invalidates all cached tokens for that report
function invalidateShareTokenCache(orgId, reportId) {
  tokenCache.delete(`${orgId}:${reportId}`);
}

Sequential integer IDs create cache bleed windows. Any cache keyed only on a sequential integer resource ID without a tenant or org dimension is vulnerable to bleed across deletion and recreation cycles. The 60-second TTL creates a deterministic exploitation window: an attacker who can predict or observe when a report with a target integer ID will be created can present a token from the deleted predecessor within that window. The fix is to always include a non-guessable tenant dimension (orgId, userId) in every cache key, and to explicitly invalidate all cache entries for a resource immediately on deletion.

Remediation summary

FindingSeverityPrimary remediationSecondary hardening
PRIVESC33-001CriticalDB-backed scope cache keyed on userId:reportId; JWT carries only subInvalidate cache on scope change events; strict 60s TTL
PRIVESC33-002CriticalrequireSession; orgId WHERE clause; Zod AuditHistoryQuerySchemaReturn only own-org audit history; pagination limits
PRIVESC33-003CriticalOwnership check: skill.ownerId === req.session.userId; audit log on every visibility changeRequire requireSession; scope report lookup to skill ownership
PRIVESC33-004HighCache key = orgId:reportId; invalidate on report deletion; verify orgId before serving cacheStrict 60s TTL; always DB-verify on orgId mismatch

SkillAudit scans for all four SA-SKL-PRIVESC33 patterns. The audit engine detects JWT claim-based authorization, missing org-scope WHERE clauses on multi-tenant queries, ownership-less PATCH handlers on visibility fields, and cache keys without tenant dimensions. See related advisories: SA-SKL-PRIVESC32 and SA-SKL-PRIVESC31. Connect your repository at skillaudit.dev.