Claude MCP skill privilege escalation — skill billing and subscription management endpoints — SA-SKL-PRIVESC47
SA-SKL-PRIVESC47 documents four privilege escalation vulnerabilities in MCP skill registry billing and subscription management endpoints. PRIVESC47-001: billing access level read from JWT billingAccessLevel claim — craft JWT with billingAccessLevel:'billing_admin' grants access to all organizations' payment methods, invoice history, and subscription cancellation capabilities; PRIVESC47-002: POST /api/billing/access missing level boundary check — any billing user assigns billing_admin level to themselves or others exceeding their own access level; PRIVESC47-003: PATCH /api/registry/billing/config missing ownership check — any authenticated user modifies global billing configuration including discount rates, trial periods, and free tier limits; PRIVESC47-004: billing access level cache key uses userId without billingPolicyVersionId — cache entries bleed across billing policy version upgrades; previously assigned billing_admin level served when billing policy updates restrict admin capabilities.
billingAccessLevel claim — craft JWT with billingAccessLevel:'billing_admin' grants access to all organizations' payment methods, invoice history, and subscription cancellation capabilities; secondary risk: downgraded billing users reuse existing JWT to continue operating at previous level until JWT expiry; fix: DB-backed 60s Map cache keyed on userId; JWT carries only sub; invalidate on level change eventPRIVESC47-001 — JWT billing access level claim enables billing_admin escalation across all organizations
Severity: CRITICAL
The billing access control system reads the user's billing level directly from the billingAccessLevel claim in the JWT payload without verifying the claim against the database. JWT payloads are signed but not encrypted — an attacker who obtains any valid JWT (through XSS, session fixation, or social engineering) can decode the payload, modify the billingAccessLevel value to 'billing_admin', and re-sign the token with a known or guessable secret. If the secret is weak or has been rotated without invalidating existing tokens, the attacker gains billing_admin access to every organization's payment methods, invoice history, and subscription management capabilities.
There is a secondary risk beyond active escalation: when a billing user is downgraded from billing_admin to a lower level in the database, their existing JWT still carries the old claim value. The user continues to operate at the billing_admin level for the remaining lifetime of the JWT — typically 24 hours to 7 days depending on registry configuration. During this window, the user can access all billing data they should no longer be authorized to view. This is a standard risk of storing authorization claims in JWTs, but it is particularly severe for billing data where downgrade decisions are often made in response to discovered access control violations.
// Billing access level from JWT claim — attacker crafts JWT with billingAccessLevel:'billing_admin'
function getBillingLevel(req) {
return req.jwtPayload.billingAccessLevel; // from JWT claim, no DB check
}
router.get('/admin/payments', requireSession, async (req, res) => {
if (getBillingLevel(req) !== 'billing_admin') return res.status(403).json({ error: 'Forbidden' });
const payments = await Payment.find({}); // all organizations' payment data
return res.json(payments);
});
// DB-backed cache keyed on userId — JWT carries only sub
const billingLevelCache = new Map(); // userId → { level, expiresAt }
async function getBillingLevel(userId) {
const cached = billingLevelCache.get(userId);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const user = await User.findById(userId).select('+billingAccessLevel');
const entry = { level: user.billingAccessLevel, expiresAt: Date.now() + 60_000 };
billingLevelCache.set(userId, entry);
return entry.level;
}
router.get('/admin/payments', requireSession, async (req, res) => {
const level = await getBillingLevel(req.session.userId);
if (level !== 'billing_admin') return res.status(403).json({ error: 'Forbidden' });
const payments = await Payment.find({});
return res.json(payments);
});
The fix removes the JWT claim entirely from billing access decisions. The JWT carries only the sub (user ID) claim; the billing access level is always read from the database via a short-lived in-process cache with a 60-second TTL. When a user's billing level is changed in the database, the cache entry expires within 60 seconds and the next request fetches the updated level. The cache must be invalidated immediately on level change events (not just on TTL expiry) to close the downgrade window for security-critical demotion operations — a cache delete on the billingAccessLevel.changed event achieves this.
PRIVESC47-002 — Missing level boundary check enables billing_admin self-assignment
Severity: HIGH
The billing access assignment endpoint allows any user with a valid session to assign any billing access level to any user ID, including themselves. There is no validation that the assigning user's own billing level is at least as high as the level they are assigning. A user with billing_viewer level can submit a request assigning billing_admin level to their own user ID, immediately gaining full billing administration capabilities. The endpoint also lacks a Zod schema, so arbitrary string values can be submitted as newLevel and stored in the database — if the application performs string comparisons against billing level values elsewhere, unexpected stored values may cause authorization check failures that default to permissive behavior.
The boundary check vulnerability is a standard broken access control pattern where operations that modify authorization state are not themselves protected by the authorization boundary they modify. Users who can invoke the assignment endpoint at all should only be able to grant levels up to and including their own current level — granting a higher level than you currently hold is a privilege escalation by definition. The fix requires fetching the caller's current billing level and comparing it ordinally against the requested assignment level before proceeding.
router.post('/api/billing/access', requireSession, async (req, res) => {
const { targetUserId, newLevel } = req.body;
// No boundary check — any billing user can assign billing_admin to themselves
await User.findByIdAndUpdate(targetUserId, { billingAccessLevel: newLevel });
return res.json({ updated: true });
});
const BILLING_LEVEL_ORDER = { billing_viewer: 0, billing_user: 1, billing_manager: 2, billing_admin: 3 };
const BillingAccessLevelSchema = z.enum(['billing_viewer', 'billing_user', 'billing_manager', 'billing_admin']);
router.post('/api/billing/access', requireSession, async (req, res) => {
const parsed = BillingAccessLevelSchema.safeParse(req.body.newLevel);
if (!parsed.success) return res.status(400).json({ error: 'Invalid billing level' });
const callerLevel = await getBillingLevel(req.session.userId);
if (BILLING_LEVEL_ORDER[parsed.data] > BILLING_LEVEL_ORDER[callerLevel])
return res.status(403).json({ error: 'Cannot assign level exceeding your own' });
await User.findByIdAndUpdate(req.body.targetUserId, { billingAccessLevel: parsed.data });
billingLevelCache.delete(req.body.targetUserId);
await AuditLog.create({ action: 'billing.access.changed', actorId: req.session.userId,
targetId: req.body.targetUserId, newLevel: parsed.data, at: new Date() });
return res.json({ updated: true });
});
The fix uses Zod to constrain newLevel to the known enum of billing access level strings, preventing arbitrary values from being stored. The BILLING_LEVEL_ORDER map converts level names to ordinal integers, enabling a simple numeric comparison to enforce the boundary invariant. The cache is invalidated immediately after the database update so that the target user's next request reflects the new level within milliseconds rather than waiting for TTL expiry. The audit log records both the assigning user and the target user, enabling detection of coordinated escalation attempts across multiple accounts.
PRIVESC47-003 — Missing ownership check on billing config enables global discount and trial manipulation
Severity: HIGH
The global billing configuration endpoint performs no access level check before accepting and applying configuration changes. Any authenticated user — including users with no billing access level at all — can submit a PATCH request that modifies the global billing configuration. The configuration includes the registry-wide discount rate applied to all subscription payments, the trial period length offered to new subscribers, and the free tier resource limits. An attacker can set the discount rate to 100% (making all subscriptions free), zero out the trial period (denying new users their trial entitlement), or set free tier limits to zero (breaking free tier functionality for all users).
Global billing configuration changes have immediate effect on all users and all billing transactions. Setting the discount rate to 100% causes the payment processor to charge zero for all subscription renewals until the configuration is corrected — this creates both financial loss for the registry operator and potentially fraudulent zero-charge transaction records. The absence of a Zod schema means that configuration values outside the expected range (negative discount rates, fractional trial day counts, zero free tier limits) can be stored and cause downstream billing calculation errors that may be difficult to detect and reverse.
router.patch('/api/registry/billing/config', requireSession, async (req, res) => {
// No ownership check — any authenticated user modifies global billing config
const { discountRate, trialDays, freeTierLimit } = req.body;
await BillingConfig.findOneAndUpdate({}, { discountRate, trialDays, freeTierLimit });
return res.json({ updated: true });
});
const BillingConfigSchema = z.object({
discountRate: z.number().min(0).max(50), // cap at 50%; no 100% discount
trialDays: z.number().int().min(1).max(90),
freeTierLimit: z.number().int().min(1).max(100),
});
router.patch('/api/registry/billing/config', requireSession, async (req, res) => {
const level = await getBillingLevel(req.session.userId);
if (level !== 'billing_admin') return res.status(403).json({ error: 'billing_admin required' });
const parsed = BillingConfigSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid config', issues: parsed.error.issues });
const prev = await BillingConfig.findOne({});
await BillingConfig.findOneAndUpdate({}, parsed.data);
await AuditLog.create({ action: 'billing.config.updated', actorId: req.session.userId,
prev: prev.toObject(), next: parsed.data, at: new Date() });
return res.json({ updated: true });
});
The fix requires the caller to hold billing_admin level (fetched from the DB-backed cache, not from the JWT). The Zod BillingConfigSchema enforces value ranges that prevent operationally destructive configurations: discount rates are capped at 50%, trial periods require at least 1 day and at most 90, and free tier limits must be positive integers within a reasonable range. The before/after diff audit log enables rapid identification of what was changed, by whom, and when — supporting both incident response and compliance requirements for billing configuration change tracking.
PRIVESC47-004 — Billing policy version cache bleed preserves elevated access across policy upgrades
Severity: HIGH
The billing access level cache uses a key of userId alone, without incorporating the current billing policy version identifier. When the registry operator upgrades the billing policy — for example, restricting the capabilities of billing_admin level to exclude access to competitor-organization payment data, or changing which payment operations require two-person authorization — the existing cache entries continue to serve the pre-upgrade access decisions for up to the cache TTL duration. Users who held billing_admin under the old policy continue to have their old level served from cache, which now grants capabilities the new policy intended to restrict.
Billing policy version upgrades are often made in response to access control incidents or compliance audit findings — they are highest priority changes that should take effect immediately for all users. A cache that does not incorporate the policy version means that the most critical access control changes have the worst implementation lag. If the cache TTL is long (e.g., 10 minutes to reduce database load), users continue operating at the old policy's access level for the full TTL duration after the policy upgrade is deployed. For billing policy changes made in response to a detected breach, this window represents continued unauthorized access during active incident response.
// Cache key = userId only — bleeds across billing policy version upgrades
const levelCache = new Map(); // userId → level
async function getCachedBillingLevel(userId) {
if (levelCache.has(userId)) return levelCache.get(userId); // stale level after policy upgrade
const user = await User.findById(userId).select('+billingAccessLevel');
levelCache.set(userId, user.billingAccessLevel);
return user.billingAccessLevel;
}
// Cache key = billingPolicyVersionId:userId — invalidates on policy upgrade
const levelCache = new Map();
let currentPolicyVersionId = await BillingPolicy.getVersionId();
async function getCachedBillingLevel(userId) {
const key = `${currentPolicyVersionId}:${userId}`;
const cached = levelCache.get(key);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const user = await User.findById(userId).select('+billingAccessLevel');
levelCache.set(key, { level: user.billingAccessLevel, expiresAt: Date.now() + 60_000 });
return user.billingAccessLevel;
}
BillingPolicy.on('versionUpgrade', async (newVersionId) => {
currentPolicyVersionId = newVersionId;
levelCache.clear(); // invalidate all cached levels on policy upgrade
});
The fix incorporates currentPolicyVersionId into the cache key so that all existing cache entries become cache misses immediately when the policy version changes. The BillingPolicy.on('versionUpgrade') event listener updates the in-process version ID and clears the entire cache on policy upgrade, ensuring that the first request after a policy upgrade always reads from the database. The 60-second TTL remains for performance, but it now only applies within a single policy version — cross-version cache bleed is structurally impossible because the old version ID no longer matches the current key prefix. In a multi-instance deployment, the policy version change event must be distributed via a pub/sub mechanism (Redis Pub/Sub, event bus) to all running instances so that all caches are cleared simultaneously.
Run SkillAudit to detect JWT claim-based authorization checks, missing level boundary enforcement on access assignment endpoints, absent ownership checks on global configuration endpoints, and policy-version-unaware cache key patterns in your MCP skill registry billing source code. Join the waitlist for access.