Claude MCP skill privilege escalation — team audit policy and compliance gate enforcement
SA-SKL-PRIVESC16 documents four privilege escalation vulnerabilities in MCP skill registry team audit policy and compliance gate enforcement. JWT-encoded minimum grade allows CI gate bypass, an orgId-free cache key causes policy data to bleed across organisation renames, a missing ownership check on the policy override endpoint lets any team member disable compliance enforcement, and an uncapped bulk export endpoint allows any team member to dump the entire registry's policy configuration.
teams[].minGrade; attacker crafts JWT with minGrade:F bypassing CI compliance gate enforcement entirely
orgId; policy cache bleeds across orgs after org rename, serving stale policy from a prior org to the renamed org
PRIVESC16-001 (Critical): JWT-encoded minimum audit grade bypasses CI compliance gate
MCP skill registry compliance gate features enforce a minimum acceptable audit grade for skills used in CI/CD pipelines — a team may require that any skill passes with a grade of B or higher before the pipeline can proceed. This enforcement is only meaningful if the grade threshold is stored and enforced server-side. When the team's minimum grade requirement is embedded in the JWT access token (as a minGrade field within a teams[] array claim), any authenticated user can craft a replacement token with an arbitrarily permissive minimum grade, defeating the compliance gate without any server-side change.
The practical impact is that every CI pipeline integration relying on the SkillAudit compliance gate becomes ineffective — a developer can ship a skill with a failing audit grade (F, D, or C) into production by simply modifying their JWT before the CI step runs the grade check. For organisations that use SkillAudit compliance gates as a mandatory security control in their deployment pipeline, this bypass represents a complete failure of the security control. Because the JWT is signed with the user's session credentials and the grade check never queries the team policy database, the bypass leaves no trace in the policy audit log.
// VULNERABLE — compliance gate reads minimum grade from JWT teams[] claim
// File: middleware/complianceGate.js
const jwt = require('jsonwebtoken');
async function complianceGateMiddleware(req, res, next) {
const token = req.headers.authorization?.split(' ')[1];
const decoded = jwt.verify(token, process.env.JWT_SECRET);
const teamId = req.params.teamId || req.body.teamId;
// VULNERABILITY: minGrade read from JWT teams[] claim — attacker-controlled
// Attacker crafts JWT: { teams: [{ id: "team-123", minGrade: "F" }] }
// This bypasses the compliance gate for all grade values including F
const teamClaim = decoded.teams?.find(t => t.id === teamId);
const minGrade = teamClaim?.minGrade ?? 'A'; // default A, but overridable via JWT
const auditGrade = req.body.auditGrade; // grade from the completed audit
if (!gradePassesThreshold(auditGrade, minGrade)) {
return res.status(422).json({ error: `Audit grade ${auditGrade} below minimum ${minGrade}` });
}
next();
}
Fix: Fetch the team's minimum audit grade exclusively from the team policy record in the database — never from JWT claims. The JWT should carry only the user's identity (sub) and optionally their team membership IDs for authorization checks. The authoritative policy values must come from the policy database, where they are write-protected by admin-only endpoints and covered by an audit log. Any JWT claim that embeds enforcement thresholds enables client-side policy override and must be removed from the token schema entirely.
// FIXED — minimum grade fetched from team policy DB record; JWT carries identity only
// File: middleware/complianceGate.js
const jwt = require('jsonwebtoken');
const { getTeamPolicy } = require('../services/teamPolicyService');
async function complianceGateMiddleware(req, res, next) {
const token = req.headers.authorization?.split(' ')[1];
const decoded = jwt.verify(token, process.env.JWT_SECRET);
// JWT carries sub and team membership IDs only — no enforcement thresholds
const teamId = req.params.teamId || req.body.teamId;
const userId = decoded.sub;
// Authoritative policy from database: minimum grade is a server-side fact
const policy = await getTeamPolicy(teamId, userId); // also validates team membership
if (!policy) return res.status(403).json({ error: 'Not a member of this team' });
const minGrade = policy.minAuditGrade; // e.g., 'B' — from DB, not JWT
const auditGrade = req.body.auditGrade;
if (!gradePassesThreshold(auditGrade, minGrade)) {
return res.status(422).json({
error: `Audit grade ${auditGrade} below team minimum ${minGrade}`,
teamId,
});
}
next();
}
PRIVESC16-002 (High): Policy cache key without orgId causes cross-organisation policy bleed on rename
Compliance gate enforcement commonly caches team policy objects in Redis to avoid a database round-trip on every CI gate check. When the cache key is constructed from only the team name (or slug) without including the organisation ID, a cache entry written for a team under one organisation remains retrievable under the same key when a different organisation renames one of its teams to an identical name. The scenario occurs specifically when: (1) Organisation A has a team named "platform" with policy minGrade=F, (2) a cache entry is written for key policy:platform, (3) Organisation B renames one of its teams to "platform" (or is newly provisioned with a team of that name), and (4) Organisation B's compliance gate check hits the cache for key policy:platform and receives Organisation A's permissive F-grade policy.
The result is that Organisation B's compliance gate silently applies a foreign team's policy — either more permissive (allowing skills that should be blocked) or more restrictive (blocking skills that should pass). In a multi-tenant MCP registry with many organisations, team name collisions after renames are not uncommon, and the cache TTL (often 10–60 minutes) means the cross-contamination persists long after the rename. Because the gate check appears to succeed normally (returning a policy object, just the wrong one), this vulnerability is difficult to detect without detailed policy audit logging.
// VULNERABLE — policy cache key uses team name only; no orgId; cross-org bleed on rename
// File: services/teamPolicyService.js
async function getTeamPolicy(teamName) {
// VULNERABILITY: cache key = team name only; org A's "platform" team and org B's
// "platform" team share the same key after org B renames or creates a matching team
const cacheKey = `policy:${teamName}`;
const cached = await redis.get(cacheKey);
if (cached) return JSON.parse(cached);
const { rows } = await db.query(
'SELECT * FROM team_policies WHERE team_name = $1',
[teamName] // also missing orgId filter — could return multiple rows
);
if (!rows.length) return null;
await redis.setex(cacheKey, 600, JSON.stringify(rows[0]));
return rows[0];
}
Fix: Always include the orgId in the cache key: policy:${orgId}:${teamId}. Use the immutable team ID (UUID) rather than the mutable team name or slug as the identifier component — names can change, IDs cannot. Invalidate the cache on every policy change and on every org or team rename operation. Query the database with both team_id and org_id as predicates to prevent the SQL query from returning a row from a different organisation even if the cache is cold.
// FIXED — cache key includes orgId and immutable teamId; invalidated on rename/change
// File: services/teamPolicyService.js
async function getTeamPolicy(teamId, userId) {
// First verify team membership and retrieve the orgId for the requesting user
const { rows: memberRows } = await db.query(
'SELECT tm.org_id FROM team_members tm WHERE tm.team_id = $1 AND tm.user_id = $2',
[teamId, userId]
);
if (!memberRows.length) return null; // not a member of this team
const orgId = memberRows[0].org_id;
// Cache key includes both orgId and immutable teamId — rename-safe
const cacheKey = `policy:${orgId}:${teamId}`;
const cached = await redis.get(cacheKey);
if (cached) return JSON.parse(cached);
// Both predicates required: team_id AND org_id prevent cross-org data return
const { rows } = await db.query(
'SELECT * FROM team_policies WHERE team_id = $1 AND org_id = $2',
[teamId, orgId]
);
if (!rows.length) return null;
await redis.setex(cacheKey, 600, JSON.stringify(rows[0]));
return rows[0];
}
// Called on team rename or org transfer — invalidates the old cache entry
async function invalidatePolicyCache(teamId, orgId) {
await redis.del(`policy:${orgId}:${teamId}`);
}
PRIVESC16-003 (High): Missing admin role check on policy override endpoint allows any team member to disable compliance
The policy override endpoint PATCH /api/teams/:id/policy allows the minimum audit grade requirement to be modified for a team. This endpoint controls a security enforcement boundary — lowering the minimum grade or disabling the compliance gate allows lower-quality skills into production. When this endpoint validates only that the requesting user is a member of the team, any team member (including developer-tier members who should not have administrative privileges) can modify the team's compliance policy. In organisations where development teams have many members across different permission tiers, this means that any developer account can silently disable the security gate that their organisation's security team configured.
Beyond the direct policy bypass, the missing admin check removes the audit trail that security teams depend on to understand when and why compliance policies were changed. Policy changes on a security-critical endpoint should require admin role verification, be recorded in an append-only audit log with the requesting user's identity and timestamp, and optionally trigger a notification to the team's security contact. Without these controls, a developer can disable compliance enforcement, ship a vulnerable skill, re-enable enforcement, and leave no detectable trace of the policy change in the normal audit flow.
// VULNERABLE — policy override endpoint checks team membership but not admin role
// File: routes/teamPolicy.js
router.patch('/teams/:id/policy', authenticate, async (req, res) => {
const { id: teamId } = req.params;
const userId = req.user.sub;
const { minAuditGrade, enabled } = req.body;
// VULNERABILITY: only checks team membership — does not verify admin role
// Any team member (including developer tier) can disable the compliance gate
const { rows } = await db.query(
'SELECT 1 FROM team_members WHERE team_id = $1 AND user_id = $2',
[teamId, userId]
);
if (!rows.length) return res.status(403).json({ error: 'Not a team member' });
// No role check: developer, contributor, maintainer, admin all reach this point
await db.query(
'UPDATE team_policies SET min_audit_grade = $1, enabled = $2 WHERE team_id = $3',
[minAuditGrade, enabled, teamId]
);
res.json({ updated: true });
// No audit log entry written
});
Fix: Require admin role for all policy modification endpoints. After the team membership check, add a role check that verifies the user holds an admin or owner role within the team. Write an audit log entry for every policy change, including the previous value, the new value, the requesting user's ID, and a timestamp. Consider sending a notification to the team's registered security contact on any compliance gate change. Apply the same admin-only constraint to any endpoint that affects security enforcement boundaries — these endpoints must be treated as privileged operations, not routine member-accessible actions.
// FIXED — admin role required; audit log written; notification sent
// File: routes/teamPolicy.js
router.patch('/teams/:id/policy', authenticate, async (req, res) => {
const { id: teamId } = req.params;
const userId = req.user.sub;
const { minAuditGrade, enabled } = req.body;
// Check team membership AND admin/owner role in one query
const { rows } = await db.query(
`SELECT role FROM team_members
WHERE team_id = $1 AND user_id = $2 AND role IN ('admin', 'owner')`,
[teamId, userId]
);
if (!rows.length) {
return res.status(403).json({ error: 'Admin or owner role required to modify team policy' });
}
// Read current policy before update for audit log
const { rows: current } = await db.query(
'SELECT min_audit_grade, enabled FROM team_policies WHERE team_id = $1',
[teamId]
);
await db.query(
'UPDATE team_policies SET min_audit_grade = $1, enabled = $2 WHERE team_id = $3',
[minAuditGrade, enabled, teamId]
);
// Append-only audit log: who changed what, when, and what it was before
await db.query(
`INSERT INTO policy_audit_log (team_id, changed_by, prev_grade, new_grade, prev_enabled, new_enabled, changed_at)
VALUES ($1, $2, $3, $4, $5, $6, NOW())`,
[teamId, userId, current[0]?.min_audit_grade, minAuditGrade, current[0]?.enabled, enabled]
);
res.json({ updated: true });
// Optionally: await notifySecurityContact(teamId, userId, { minAuditGrade, enabled });
});
PRIVESC16-004 (Medium): Uncapped bulk policy export dumps full registry compliance configuration
The bulk policy export endpoint GET /api/teams/policy-export is designed to allow team administrators to download their own team's compliance configuration for backup or audit purposes. When this endpoint is missing pagination and rate limiting, any authenticated team member can issue a single request that returns the complete policy configuration for all teams in the registry — potentially tens of thousands of entries covering every organisation's compliance grade requirements, exception lists, CI gate configurations, and policy history.
The data exposed includes: each team's minimum acceptable audit grade, whether compliance enforcement is currently enabled or disabled, any whitelisted skill IDs that bypass the compliance gate, the policy owner's user ID and contact email, and policy timestamps. This configuration data is sensitive for two reasons: it reveals which organisations have weaker compliance postures (providing targeting intelligence for attackers who want to find organisations running low-grade skills in production), and it constitutes a bulk data export of internal configuration that individual organisations reasonably expect to remain private. The missing rate limit additionally creates a denial-of-service surface — a single request materialising 10,000+ policy rows from Postgres can saturate the API server.
// VULNERABLE — policy export endpoint: no pagination, no rate limit, no scope filter
// File: routes/teamPolicy.js
router.get('/teams/policy-export', authenticate, async (req, res) => {
// VULNERABILITY: no scope filter, no pagination, no rate limit
// Any team member can dump the entire registry's policy configuration
const { rows } = await db.query(
'SELECT * FROM team_policies ORDER BY created_at DESC'
// No LIMIT, no WHERE — returns all 10000+ team policies in one query
);
res.json({ policies: rows });
});
Fix: Scope the export query to the requesting user's own organisations — a user should only be able to export policy data for teams they belong to. Add mandatory cursor-based or offset-based pagination with a maximum page size of 100 rows. Apply a per-user rate limit of 10 export requests per hour to prevent bulk enumeration. Require admin or owner role for the export endpoint — developer-tier team members should not have access to bulk configuration exports. Log each export request with the requesting user's ID and the number of rows returned.
// FIXED — policy export scoped to user's orgs; paginated; rate-limited; admin-only
// File: routes/teamPolicy.js
const rateLimit = require('express-rate-limit');
const exportRateLimit = rateLimit({
windowMs: 60 * 60 * 1000, // 1 hour
max: 10, // 10 export requests per user per hour
keyGenerator: (req) => req.user.sub,
message: { error: 'Policy export rate limit exceeded' },
});
router.get('/teams/policy-export', authenticate, exportRateLimit, async (req, res) => {
const userId = req.user.sub;
// Require admin/owner role in at least one of the user's teams
const { rows: adminTeams } = await db.query(
`SELECT DISTINCT tm.team_id, tm.org_id
FROM team_members tm
WHERE tm.user_id = $1 AND tm.role IN ('admin', 'owner')`,
[userId]
);
if (!adminTeams.length) {
return res.status(403).json({ error: 'Admin role required for policy export' });
}
// Pagination
const limit = Math.min(parseInt(req.query.limit ?? 100, 10), 100);
const offset = Math.max(parseInt(req.query.offset ?? 0, 10), 0);
// Scope: only teams where user is admin/owner — not all teams in registry
const orgIds = [...new Set(adminTeams.map(t => t.org_id))];
const teamIds = adminTeams.map(t => t.team_id);
const { rows } = await db.query(
`SELECT team_id, org_id, min_audit_grade, enabled, created_at, updated_at
FROM team_policies
WHERE org_id = ANY($1) AND team_id = ANY($2)
ORDER BY created_at DESC
LIMIT $3 OFFSET $4`,
[orgIds, teamIds, limit, offset]
);
// Audit log the export
await db.query(
'INSERT INTO export_audit_log (user_id, exported_rows, exported_at) VALUES ($1,$2,NOW())',
[userId, rows.length]
);
res.json({ policies: rows, limit, offset, count: rows.length });
});
Compound attack chain: compliance gate neutralisation via JWT + cache bleed
These four PRIVESC16 vulnerabilities compose an attack chain that fully neutralises the compliance gate enforcement system for a targeted team, with the attack remaining undetected in standard audit logs.
Phase 1 — Policy discovery (PRIVESC16-004). The attacker, a developer-tier team member, issues a request to the uncapped policy export endpoint. The response includes the compliance policies for all teams in the registry, revealing which teams have strict enforcement (minGrade=A) and which have been configured with weaker thresholds. The attacker identifies their own team's policy ID and the policies of competitor organisations' teams.
Phase 2 — Cache poisoning (PRIVESC16-002). The attacker examines the registry's team naming patterns from the policy export and identifies an opportunity to trigger a cache bleed. By renaming their own test team to match the name of a target team (exploiting the orgId-free cache key), they cause the target team's compliance gate to serve the attacker's test team's permissive policy (minGrade=F) until the cache expires. During this window, the target team's CI pipeline accepts any skill regardless of audit grade.
Phase 3 — Persistent bypass (PRIVESC16-001 + PRIVESC16-003). For their own team, the attacker uses PRIVESC16-001 to craft a JWT with minGrade:F in the teams claim, bypassing the gate on every CI run without touching the database. If they can access PRIVESC16-003 (the unprotected policy override endpoint), they permanently set their team's policy to minGrade=F in the database, leaving no trace because the audit log is never written.
Chain severity: The combined chain allows a developer-tier team member to discover all registry compliance policies, trigger cross-organisation cache poisoning, and permanently disable their own team's compliance gate — with no entries in the policy audit log and no detectable anomaly in normal monitoring. Each individual fix is straightforward; together they close the full attack surface of the compliance gate system. Deploy PRIVESC16-001 (DB-sourced minGrade) first as it has the highest direct impact on enforcement integrity.
Detection with tree-sitter queries
Query 1 — JWT claim read used as enforcement threshold (grade or policy). Extends the PRIVESC15-001 pattern to match grade and policy claim reads from decoded JWT objects, covering the PRIVESC16-001 variant.
; tree-sitter query: JWT claim read used as compliance enforcement value (PRIVESC16-001)
; Matches: decoded.teams?.find(t => t.id === teamId)?.minGrade and similar patterns
(variable_declarator
name: (identifier) @grade-var
(#match? @grade-var "(grade|policy|threshold|minimum|min)")
value: [
(optional_chain
object: (call_expression
function: (member_expression
object: (member_expression
object: (identifier) @jwt-obj
(#match? @jwt-obj "(decoded|payload|claims|token)")
property: (property_identifier) @jwt-teams
(#match? @jwt-teams "(teams|roles|perms|permissions)")
)
)
)
)
(member_expression
object: (identifier) @team-claim (#match? @team-claim "(teamClaim|roleClaim)")
property: (property_identifier) @grade-prop (#match? @grade-prop "(grade|minGrade|threshold)")
)
]
) @finding
; Fix: replace JWT claim read with DB policy lookup (getTeamPolicy(teamId, userId)).
Query 2 — Route handler with no role check on policy mutation. Matches PATCH/PUT/DELETE route handlers for paths containing "policy" that have a team-membership check (team_members query) but no role check (no role condition in the query or no second db.query call for role verification).
; tree-sitter query: policy mutation route with membership check but no role check
; Flags: router.patch('/teams/:id/policy') handlers that query team_members without 'role'
(call_expression
function: (member_expression
object: (identifier) @router (#match? @router "router")
property: (property_identifier) @method (#match? @method "(patch|put|delete)")
)
arguments: (arguments
(string) @path (#match? @path "policy")
(_)*
(arrow_function
body: (statement_block) @handler-body
(#match? @handler-body "team_members")
(#not-match? @handler-body "role")
)
)
) @missing-role-check
; Each @missing-role-check: policy mutation handler queries team_members but
; does not filter on role column. Add: AND role IN ('admin', 'owner')
Summary
| ID | Severity | Surface | Root cause | Fix |
|---|---|---|---|---|
| PRIVESC16-001 | Critical | CI compliance gate / JWT enforcement | Minimum audit grade read from attacker-controlled teams[].minGrade JWT claim |
Fetch policy from team policy DB record; JWT carries sub and team IDs only |
| PRIVESC16-002 | High | Policy cache layer / Redis key construction | Cache key uses team name without orgId; policy bleeds across orgs on team rename | Cache key: policy:${orgId}:${teamId}; invalidate on rename; query with both predicates |
| PRIVESC16-003 | High | PATCH /api/teams/:id/policy — policy override | Checks team membership but not admin role; any member can disable compliance enforcement | Require role IN ('admin','owner'); write audit log entry for every policy change |
| PRIVESC16-004 | Medium | GET /api/teams/policy-export — bulk export | No scope filter, no pagination, no rate limit; any member dumps all 10,000+ policies | Scope to user's admin-role teams; LIMIT 100; rate limit 10/hr; require admin role; audit log |
Checklist for MCP skill registry operators: (1) Audit all JWT middleware for claims used as enforcement thresholds — minGrade, policyEnabled, threshold; replace with DB policy lookups. (2) Audit all Redis cache key constructions — confirm every multi-tenant key includes an immutable tenant/org identifier, not just a name or slug. (3) Grep policy mutation endpoints for team_members queries lacking a role condition — add admin/owner role requirement. (4) Review all bulk list/export endpoints for missing pagination and rate limits — apply server-side caps and per-user rate limiting. (5) Confirm that all policy-modifying endpoints write to an append-only audit log. Use the tree-sitter queries above in CI to prevent regressions across the full SA-SKL-PRIVESC series.