Claude MCP skill privilege escalation — skill billing and subscription management endpoints (SA-SKL-PRIVESC65)
SA-SKL-PRIVESC65 identifies four privilege escalation vulnerabilities in MCP skill registry skill billing and subscription management endpoints. Trusting the billingPlan claim from a user-controlled JWT without a database-side verification step allows any user to self-issue an enterprise JWT and immediately access unlimited audit quotas, the private skill catalog, SSO bypass, and enterprise SLA support; a missing plan boundary check on the upgrade endpoint allows free tier users to jump directly to enterprise without payment or vetting; an absent ownership check on the global billing configuration endpoint allows any authenticated user to overwrite the platform-wide free tier quota and enterprise feature gate values, affecting every account simultaneously; and a billing plan cache key that excludes the policy version identifier allows revoked enterprise plan entries to persist in cache until TTL expiry, maintaining enterprise access for accounts whose plans were administratively revoked.
billingPlan claim — craft JWT with billingPlan:'enterprise' grants unlimited audit quotas, private catalog access, SSO bypass, and enterprise support SLA without database-side checkPOST /api/registry/billing/upgrade missing plan boundary check — any free tier user upgrades to enterprise plan themselves bypassing payment and vetting processPATCH /api/registry/billing/config missing ownership check — any authenticated user modifies global billing thresholds including free tier audit quotas and enterprise feature gates affecting all accountsuserId without billingPolicyVersionId — cache entries bleed across billing policy upgrades; revoked enterprise plans retained until TTL expiryPRIVESC65-001 — JWT billingPlan claim trusted without database verification grants enterprise access
The billing authorization middleware reads the user's billing plan from the JWT's billingPlan claim and applies feature gates based on this client-controlled value without performing a database lookup to verify it matches the user's actual stored plan. Because JWTs are signed with the server's secret but carry user-supplied claim values set at login time, an attacker who crafts a JWT with billingPlan: 'enterprise' — by logging in normally and then modifying their stored JWT or by exploiting a JWT claim injection path — bypasses every billing gate including unlimited audit submission quotas, access to the private skill catalog, SSO integration bypass that skips email domain verification, and the enterprise SLA support queue that grants direct engineering escalation.
// PRIVESC65-001 — VULNERABLE: billing plan read from JWT claim — no DB check
function requireBillingPlan(minPlan) {
const PLAN_ORDER = ['free', 'pro', 'enterprise'];
return (req, res, next) => {
// attacker crafts JWT with billingPlan:'enterprise' — trusted without verification
const userPlan = req.jwt.billingPlan;
if (PLAN_ORDER.indexOf(userPlan) < PLAN_ORDER.indexOf(minPlan)) {
return res.status(403).json({ error: 'upgrade required', requiredPlan: minPlan });
}
next();
};
}
router.get('/catalog/private', requireSession, requireBillingPlan('enterprise'), async (req, res) => {
res.json(await catalog.getPrivateSkills());
});
// PRIVESC65-001 — FIXED: DB-backed billing plan lookup by userId; JWT carries only sub
const billingPlanCache = new Map();
async function getUserBillingPlan(userId) {
const cacheKey = `plan:${await getBillingPolicyVersion()}:${userId}`;
if (billingPlanCache.has(cacheKey)) return billingPlanCache.get(cacheKey);
const record = await db.users.findOne({ id: userId }, { projection: { billingPlan: 1 } });
if (!record) throw new Error('User not found');
billingPlanCache.set(cacheKey, record.billingPlan);
return record.billingPlan;
}
function requireBillingPlan(minPlan) {
const PLAN_ORDER = ['free', 'pro', 'enterprise'];
return async (req, res, next) => {
try {
// JWT carries only sub — billing plan always from DB
const userPlan = await getUserBillingPlan(req.jwt.sub);
if (PLAN_ORDER.indexOf(userPlan) < PLAN_ORDER.indexOf(minPlan)) {
return res.status(403).json({ error: 'upgrade required', requiredPlan: minPlan });
}
req.billingPlan = userPlan;
next();
} catch (err) {
next(err);
}
};
}
router.get('/catalog/private', requireSession, requireBillingPlan('enterprise'), async (req, res) => {
res.json(await catalog.getPrivateSkills());
});
JWTs are integrity-protected but not access-controlled — their claims are set by whoever minted them. Any claim stored in a JWT can be forged if the attacker controls the token creation path or finds a secondary JWT injection vulnerability. Authorization-critical values like billing plan, role, and quota limits must always be read from the database using the JWT's sub as the lookup key. The JWT proves identity; the database provides authorization.
PRIVESC65-002 — Missing plan boundary check allows free tier to self-upgrade to enterprise
The POST /api/registry/billing/upgrade endpoint accepts a targetPlan field and upgrades the requesting user's billing plan to the specified value without validating that the upgrade follows the permitted plan progression sequence or that enterprise upgrades require an administrative approval workflow. Any free tier user can call this endpoint with targetPlan: 'enterprise' and immediately receive enterprise-tier capabilities including unlimited audit quotas, private catalog access, and SSO integration, without submitting payment information, completing the enterprise vetting process, or obtaining any administrative approval — a complete billing bypass that also invalidates the vetting controls designed to prevent abuse of the enterprise support queue.
// PRIVESC65-002 — VULNERABLE: no plan boundary check — free tier jumps directly to enterprise
router.post('/billing/upgrade', requireSession, async (req, res) => {
const { targetPlan } = req.body;
// No check: is this upgrade permitted? Is payment attached? Is enterprise approved?
await db.users.updateOne(
{ id: req.session.userId },
{ $set: { billingPlan: targetPlan } }
);
res.json({ plan: targetPlan, message: 'upgrade successful' });
});
// PRIVESC65-002 — FIXED: BILLING_PLAN_ORDER ordinal check prevents jump > 1 level; enterprise requires admin approval queue
const BILLING_PLAN_ORDER = ['free', 'pro', 'enterprise'];
router.post('/billing/upgrade', requireSession, csrfProtection, async (req, res) => {
const { targetPlan } = req.body;
const currentRecord = await db.users.findOne(
{ id: req.session.userId },
{ projection: { billingPlan: 1 } }
);
const currentIdx = BILLING_PLAN_ORDER.indexOf(currentRecord.billingPlan);
const targetIdx = BILLING_PLAN_ORDER.indexOf(targetPlan);
if (targetIdx === -1) return res.status(400).json({ error: 'invalid plan' });
if (targetIdx <= currentIdx) return res.status(400).json({ error: 'already on this plan or higher' });
// Prevent skipping plan levels (free → enterprise)
if (targetIdx - currentIdx > 1) {
return res.status(400).json({ error: 'cannot skip plan levels', nextPlan: BILLING_PLAN_ORDER[currentIdx + 1] });
}
// Enterprise upgrades always require admin approval — never self-serve
if (targetPlan === 'enterprise') {
await adminApprovalQueue.enqueue({ userId: req.session.userId, requestedPlan: 'enterprise', at: new Date() });
return res.json({ status: 'pending_approval', message: 'Enterprise upgrade requires admin review' });
}
// Pro upgrade requires payment confirmation
await billingService.requirePaymentMethod(req.session.userId);
await db.users.updateOne({ id: req.session.userId }, { $set: { billingPlan: targetPlan } });
await auditLog.write({ action: 'billing.upgrade', userId: req.session.userId, plan: targetPlan, at: new Date() });
res.json({ plan: targetPlan, message: 'upgrade successful' });
});
Plan boundary validation must enforce both the step size and the approval path, not just the target value. Validating that targetPlan is a known plan name is necessary but not sufficient. The upgrade must check the current plan, enforce one-level-at-a-time progression, and route enterprise requests through an async admin approval queue that is distinct from the self-service payment flow.
PRIVESC65-003 — Missing ownership check allows any user to modify global billing configuration
The PATCH /api/registry/billing/config endpoint updates the platform-wide billing configuration that governs the free tier audit quota, the enterprise feature gate thresholds, and the monthly audit submission limits applied to every account. The endpoint authenticates the request but does not verify that the requesting user holds the billing_admin role before applying changes. Any authenticated free tier user can submit a PATCH request increasing the free tier audit quota to an arbitrarily large value, granting unlimited audits to every free tier user platform-wide. Conversely, a malicious user can reduce the enterprise feature quotas to zero, breaking audit functionality for every paying enterprise customer simultaneously.
// PRIVESC65-003 — VULNERABLE: any authenticated user can modify global billing config
router.patch('/billing/config', requireSession, async (req, res) => {
// No role check — any authenticated user reaches this code
const { freeTierAuditQuota, enterpriseAuditQuota, enterpriseFeatureGates } = req.body;
await db.billingConfig.updateOne(
{ key: 'global' },
{ $set: { freeTierAuditQuota, enterpriseAuditQuota, enterpriseFeatureGates } }
);
res.json({ updated: true });
});
// PRIVESC65-003 — FIXED: billing_admin role; Zod BillingConfigUpdateSchema with min/max; reAuthRequired; audit log with before/after diff
const { z } = require('zod');
const BillingConfigUpdateSchema = z.object({
freeTierAuditQuota: z.number().int().min(1).max(100),
enterpriseAuditQuota: z.number().int().min(1).max(100000),
enterpriseFeatureGates: z.record(z.boolean()).optional()
});
router.patch('/billing/config',
requireSession,
requireRole('billing_admin'),
reAuthRequired,
csrfProtection,
async (req, res) => {
const update = BillingConfigUpdateSchema.parse(req.body);
const before = await db.billingConfig.findOne({ key: 'global' });
await db.billingConfig.updateOne(
{ key: 'global' },
{ $set: { ...update, billingConfigVersion: (before.billingConfigVersion || 0) + 1 } }
);
// Audit log with before/after diff for compliance
await auditLog.write({
action: 'billing.config.update',
actorId: req.session.userId,
before: { freeTierAuditQuota: before.freeTierAuditQuota, enterpriseAuditQuota: before.enterpriseAuditQuota },
after: update,
at: new Date()
});
res.json({ updated: true });
}
);
Global configuration endpoints are platform-wide blast radius operations. A single misconfigured PATCH to the global billing config simultaneously affects every account on the platform. Treat these endpoints with the same controls as account deletion: require the billing_admin role, enforce re-authentication, capture a complete before/after diff in the audit log, and version-stamp the config record so that any downstream cache invalidation can be driven by the version change.
PRIVESC65-004 — Billing plan cache key bleeds across policy versions retaining revoked enterprise access
The billing plan cache uses a key of the form plan:{userId} without incorporating the current billing policy version identifier. When an enterprise plan is administratively revoked — for example, following a failed payment, a chargeback, or a terms-of-service violation — the user's database record is updated to billingPlan: 'free', but the existing cache entry keyed only by userId continues to return 'enterprise' until the cache TTL expires. Depending on the TTL setting, the revoked user retains full enterprise access for minutes to hours after revocation, during which they can download private catalog entries, submit unlimited audits, and use enterprise SSO — rendering the administrative revocation action ineffective within its intended timeframe.
// PRIVESC65-004 — VULNERABLE: cache key uses only userId — revoked plans persist until TTL
const PLAN_CACHE_TTL = 3600; // 1 hour
async function getUserBillingPlan(userId) {
const cacheKey = `plan:${userId}`;
const cached = await redis.get(cacheKey);
if (cached) return cached; // returns 'enterprise' even after revocation
const record = await db.users.findOne({ id: userId }, { projection: { billingPlan: 1 } });
await redis.setex(cacheKey, PLAN_CACHE_TTL, record.billingPlan);
return record.billingPlan;
}
// Revoke does NOT invalidate the cache entry
async function revokeBillingPlan(userId) {
await db.users.updateOne({ id: userId }, { $set: { billingPlan: 'free' } });
// Cache entry for plan:${userId} still returns 'enterprise' for up to 1 hour
}
// PRIVESC65-004 — FIXED: cache key = billingPolicyVersionId:userId; revokeBillingPlan() increments policyVersion
const PLAN_CACHE_TTL = 300; // 5 minutes — shorter TTL reduces worst-case bleed window
async function getBillingPolicyVersion() {
const cfg = await db.billingConfig.findOne({ key: 'global' }, { projection: { billingConfigVersion: 1 } });
return cfg.billingConfigVersion;
}
async function getUserBillingPlan(userId) {
const policyVersion = await getBillingPolicyVersion();
// Cache key incorporates policy version — revocation increments version, busting all entries
const cacheKey = `plan:v${policyVersion}:${userId}`;
const cached = await redis.get(cacheKey);
if (cached) return cached;
const record = await db.users.findOne({ id: userId }, { projection: { billingPlan: 1 } });
await redis.setex(cacheKey, PLAN_CACHE_TTL, record.billingPlan);
return record.billingPlan;
}
async function revokeBillingPlan(userId) {
await db.users.updateOne({ id: userId }, { $set: { billingPlan: 'free' } });
// Increment billingConfigVersion — invalidates ALL plan cache entries for every user
await db.billingConfig.updateOne(
{ key: 'global' },
{ $inc: { billingConfigVersion: 1 } }
);
await auditLog.write({ action: 'billing.plan.revoke', userId, at: new Date() });
}
Cache invalidation on revocation requires that the cache key incorporate the data version. A per-user delete of the cache entry is fragile under race conditions and misses in distributed cache deployments where entries may be replicated. Incrementing a global billingConfigVersion counter and embedding it in every cache key provides an atomic, race-free mechanism that invalidates all plan cache entries simultaneously at the moment of revocation — with no per-entry delete required.
SkillAudit checks for all SA-SKL-PRIVESC vulnerability patterns including JWT claim trust without DB verification, missing plan boundary enforcement, global configuration endpoint authorization gaps, and versioned cache invalidation failures. Get a graded report with line-level code fixes in 60 seconds.
Get a free audit