Claude MCP skill privilege escalation — skill organization admin and billing control endpoints — SA-SKL-PRIVESC40
SA-SKL-PRIVESC40 documents four privilege escalation vulnerabilities in MCP skill registry skill organization admin and billing control endpoints. Organization admin and billing controls are the highest-impact targets in a multi-tenant skill registry: super_admin level grants billing control across all organizations, the ability to add and remove members from any organization, and cross-organization read access to private skill data. This advisory covers JWT claim forgery that elevates any user to super_admin, a level boundary bypass that allows any org admin to self-escalate without an approving authority, a missing ownership check on billing configuration that lets any user modify payment methods for any organization, and a cache key design flaw that bleeds super_admin level across tenant boundaries during organization ID reuse.
orgAdminLevel claim; craft JWT with orgAdminLevel:'super_admin' grants billing control, member management, and cross-org skill access for all organizations; fix: DB-backed 60s Map cache keyed on userId+orgId; JWT carries only sub; invalidate on level change eventPOST /api/orgs/:id/admins missing level boundary check; any org admin assigns super_admin level to themselves or others exceeding their own admin level; fix: requireSession; validate assigned level does not exceed assigning user's own level; Zod OrgAdminLevelSchema; audit logPATCH /api/orgs/:id/billing/config missing ownership check; any authenticated user modifies any organization's billing configuration including payment methods, subscription tiers, and usage limits; fix: require org.ownerId === req.session.userId OR super_admin level; requireSession; audit logorgId without tenantId; cache entries bleed across org deletion and recreation in multi-tenant deployments; previously assigned super_admin level served to new org with same sequential integer ID; fix: cache key = tenantId:orgId; invalidate on org deletion; strict 60s TTLPRIVESC40-001 — JWT orgAdminLevel claim forgery elevates any user to super_admin
Severity: CRITICAL
The organization admin middleware reads the user's admin level from the orgAdminLevel claim in the JWT access token. Any user who can obtain or forge a JWT with orgAdminLevel: 'super_admin' — through a signing key leak, an algorithm confusion attack on the JWT library, or a misconfigured token issuance endpoint — gains super_admin privileges for all organizations. Super_admin level grants billing control across all organizations in the registry (read and modify payment methods, subscription tiers, and usage limits), the ability to add and remove members from any organization regardless of ownership, and read access to all private skill data across organizational boundaries. The fix moves admin level to a server-side cache backed by the database, with the JWT carrying only the sub claim. The cache is invalidated on every admin level change event to prevent stale elevation.
Algorithm confusion on RS256/HS256 is a common JWT forgery vector. If the JWT library accepts both asymmetric and symmetric algorithms, an attacker can re-sign a modified token using the public key as an HMAC secret — a known attack against libraries that do not enforce a fixed algorithm. Storing admin level in the JWT makes this attack immediately impactful: a successfully forged token grants registry-wide super_admin access.
// org admin middleware — reads orgAdminLevel from JWT claim
function requireOrgAdmin(minLevel = 'admin') {
return (req, res, next) => {
const token = req.headers.authorization?.split(' ')[1];
const decoded = jwt.verify(token, process.env.JWT_SECRET);
// attacker forges JWT with orgAdminLevel:'super_admin'
if (!hasRequiredLevel(decoded.orgAdminLevel, minLevel)) {
return res.status(403).end();
}
req.orgAdminLevel = decoded.orgAdminLevel;
next();
};
}
// org admin middleware — DB-backed cache, JWT carries only sub
const orgAdminLevelCache = new Map(); // key: userId:orgId → { level, expiresAt }
async function getOrgAdminLevel(userId, orgId) {
const cacheKey = `${userId}:${orgId}`;
const cached = orgAdminLevelCache.get(cacheKey);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const admin = await OrgAdmin.findOne({ userId, orgId }).select('level');
const level = admin?.level ?? 'none';
orgAdminLevelCache.set(cacheKey, { level, expiresAt: Date.now() + 60_000 });
return level;
}
// called on admin level change events to prevent stale elevation
export function invalidateOrgAdminCache(userId, orgId) {
orgAdminLevelCache.delete(`${userId}:${orgId}`);
}
function requireOrgAdmin(minLevel = 'admin') {
return async (req, res, next) => {
if (!req.session?.userId) return res.status(401).end();
// JWT carries only sub — level always read from DB cache
const level = await getOrgAdminLevel(req.session.userId, req.params.id);
if (!hasRequiredLevel(level, minLevel)) return res.status(403).end();
req.orgAdminLevel = level;
next();
};
}
PRIVESC40-002 — Org admin level boundary check missing enables self-escalation to super_admin
Severity: HIGH
The POST /api/orgs/:id/admins endpoint creates or updates admin records for an organization. The endpoint validates that the caller is an org admin — a correct check — but does not validate that the level being assigned does not exceed the assigning user's own level. Any user with the admin level can submit a request assigning the super_admin level to their own account. Alternatively, they can assign super_admin to a second account they control as a stable backdoor, then reduce their own level to avoid detection. The fix enforces a level boundary: the assigned level must not exceed the assigning user's current level. Only an existing super_admin can promote another user to super_admin, and no user can assign a level higher than their own.
// POST /api/orgs/:id/admins — missing level boundary check
router.post('/:id/admins', requireSession, async (req, res) => {
const isAdmin = await OrgAdmin.exists({ orgId: req.params.id, userId: req.session.userId });
if (!isAdmin) return res.status(403).end();
const { targetUserId, level } = req.body;
// no check that level <= assigning user's own level
// any admin can assign 'super_admin' to themselves or others
await OrgAdmin.upsert({ orgId: req.params.id, userId: targetUserId, level });
return res.status(200).end();
});
// POST /api/orgs/:id/admins — level boundary check + Zod + audit log
const OrgAdminLevelSchema = z.object({
targetUserId: z.string().uuid(),
level: z.enum(['viewer', 'admin', 'super_admin']),
});
const LEVEL_ORDER = { none: 0, viewer: 1, admin: 2, super_admin: 3 };
router.post('/:id/admins', requireSession, async (req, res) => {
const callerLevel = await getOrgAdminLevel(req.session.userId, req.params.id);
if (LEVEL_ORDER[callerLevel] < LEVEL_ORDER['admin']) return res.status(403).end();
const parsed = OrgAdminLevelSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid input' });
// assigned level must not exceed the assigning user's own level
if (LEVEL_ORDER[parsed.data.level] > LEVEL_ORDER[callerLevel]) {
return res.status(403).json({ error: 'Cannot assign level higher than your own' });
}
await OrgAdmin.upsert({ orgId: req.params.id, userId: parsed.data.targetUserId, level: parsed.data.level });
invalidateOrgAdminCache(parsed.data.targetUserId, req.params.id);
await AuditLog.create({
action: 'org.admin.assigned',
actorId: req.session.userId,
orgId: req.params.id,
targetUserId: parsed.data.targetUserId,
level: parsed.data.level,
at: new Date(),
});
return res.status(200).end();
});
PRIVESC40-003 — Billing config missing ownership check allows cross-org payment method modification
Severity: HIGH
The PATCH /api/orgs/:id/billing/config endpoint updates an organization's billing configuration — including the default payment method, subscription tier, usage limits, and invoice contact email. The endpoint requires an authenticated session but does not verify that the caller owns or administers the target organization. Any authenticated user can send a PATCH request with any organization's ID in the path parameter and modify that organization's billing configuration. The most disruptive modification is replacing the payment method with a declined card, downgrading the subscription tier to the free tier (revoking private skill access, CI webhook integrations, and SSO), and setting usage limits to zero to trigger immediate rate-limiting. All of these changes appear in billing logs as legitimate configuration updates.
// PATCH /api/orgs/:id/billing/config — missing ownership check
router.patch('/:id/billing/config', requireSession, async (req, res) => {
// no check that req.session.userId is the org owner or super_admin
const { paymentMethodId, tier, usageLimits, invoiceEmail } = req.body;
await Org.updateOne({ _id: req.params.id }, {
$set: { paymentMethodId, tier, usageLimits, invoiceEmail },
});
return res.status(200).end();
});
// PATCH /api/orgs/:id/billing/config — ownership check + super_admin override + audit
const BillingConfigSchema = z.object({
paymentMethodId: z.string().optional(),
tier: z.enum(['free', 'pro', 'team']).optional(),
usageLimits: z.object({
auditsPerMonth: z.number().int().min(0).max(100_000),
seats: z.number().int().min(1).max(1000),
}).optional(),
invoiceEmail: z.string().email().optional(),
});
router.patch('/:id/billing/config', requireSession, async (req, res) => {
const org = await Org.findById(req.params.id);
if (!org) return res.status(404).end();
const callerLevel = await getOrgAdminLevel(req.session.userId, req.params.id);
const isOwner = String(org.ownerId) === req.session.userId;
const isSuperAdmin = callerLevel === 'super_admin';
if (!isOwner && !isSuperAdmin) return res.status(403).end();
const parsed = BillingConfigSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid billing config' });
await Org.updateOne({ _id: req.params.id }, { $set: parsed.data });
await AuditLog.create({
action: 'org.billing.updated',
actorId: req.session.userId,
orgId: req.params.id,
changes: Object.keys(parsed.data),
at: new Date(),
});
return res.status(200).end();
});
PRIVESC40-004 — Org admin cache key missing tenantId bleeds super_admin level across tenant boundaries
Severity: HIGH
The org admin level cache keys entries as userId:orgId where orgId is a sequential integer. In a multi-tenant deployment where multiple tenants share an application instance and sequential database IDs, the following sequence produces a cross-tenant privilege escalation: an admin at tenantA is assigned super_admin level for org ID 1234 in tenant A's namespace and their level is cached as userId:1234 → super_admin. TenantA later deletes org 1234. TenantB creates a new organization which receives the recycled sequential integer ID 1234. The cache still contains the entry userId:1234 → super_admin from the previous tenantA org. When the same user authenticates to tenantB and the cache is consulted for org 1234, the stale entry serves super_admin level for a completely different organization the user has no legitimate relationship with. The fix includes the tenantId in the cache key and invalidates cache entries on org deletion.
Sequential integer IDs make cache bleed exploitable by design. Database sequences that reset on deletion or recycle IDs across tenants create predictable collision conditions. This finding is amplified in multi-tenant SaaS deployments that use PostgreSQL sequences without per-tenant ID namespacing. Consider UUIDs for org IDs, and always scope cache keys to the full composite identity (tenantId + orgId).
// org admin level cache — key uses orgId without tenantId
const orgAdminLevelCache = new Map();
async function getOrgAdminLevel(userId, orgId) {
// key: userId:orgId — bleeds across tenant boundaries when orgId is reused
const cacheKey = `${userId}:${orgId}`;
const cached = orgAdminLevelCache.get(cacheKey);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const admin = await OrgAdmin.findOne({ userId, orgId }).select('level');
const level = admin?.level ?? 'none';
orgAdminLevelCache.set(cacheKey, { level, expiresAt: Date.now() + 60_000 });
return level;
}
// org deletion does NOT invalidate cache — stale level persists for up to 60s
router.delete('/:id', requireSession, requireOrgAdmin('super_admin'), async (req, res) => {
await Org.deleteOne({ _id: req.params.id });
return res.status(204).end();
});
// org admin level cache — key includes tenantId + org deletion invalidation
async function getOrgAdminLevel(userId, tenantId, orgId) {
// key: userId:tenantId:orgId — no cross-tenant bleed even with sequential integer orgId
const cacheKey = `${userId}:${tenantId}:${orgId}`;
const cached = orgAdminLevelCache.get(cacheKey);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const admin = await OrgAdmin.findOne({ userId, tenantId, orgId }).select('level');
const level = admin?.level ?? 'none';
orgAdminLevelCache.set(cacheKey, { level, expiresAt: Date.now() + 60_000 });
return level;
}
function invalidateOrgAdminCacheForOrg(tenantId, orgId) {
for (const key of orgAdminLevelCache.keys()) {
if (key.endsWith(`:${tenantId}:${orgId}`)) orgAdminLevelCache.delete(key);
}
}
// org deletion invalidates all cache entries for this org across all users
router.delete('/:id', requireSession, requireOrgAdmin('super_admin'), async (req, res) => {
const org = await Org.findById(req.params.id);
if (!org) return res.status(404).end();
await Org.deleteOne({ _id: req.params.id });
await OrgAdmin.deleteMany({ orgId: req.params.id });
// invalidate cache for all users who had admin level for this org
invalidateOrgAdminCacheForOrg(org.tenantId, req.params.id);
return res.status(204).end();
});