← Security advisories

Claude MCP skill privilege escalation — skill billing and subscription management endpoints — SA-SKL-PRIVESC28

SA-SKL-PRIVESC28 documents four privilege escalation vulnerabilities in MCP skill registry billing and subscription management endpoints. Billing endpoints govern which features an organization has paid for, how many seats they are licensed to use, and how overage credits are tracked across plan transitions. Reading the subscription plan from an attacker-controllable JWT claim allows any user to forge an enterprise subscription and unlock all gated features without completing payment. A missing payment verification step on the upgrade endpoint allows any authenticated user to activate any plan tier for free. Missing org scoping on the seat management endpoint allows any authenticated user to increase seat counts for subscriptions belonging to other organizations. And a billing overage credit cache key that omits the orgId causes credit entries to bleed across plan transitions, granting credits earned under one organization's subscription to a different organization that later takes the same plan slot.

SA-SKL-PRIVESC28 findings at a glance
CRITICALPRIVESC28-001 — billing plan read from JWT subscriptionPlan claim; craft JWT with subscriptionPlan:'enterprise' unlocks all gated features without payment
CRITICALPRIVESC28-002 — POST /api/billing/upgrade missing payment verification; any authenticated user upgrades their org to any plan without completing payment
CRITICALPRIVESC28-003 — PATCH /api/billing/seats missing org scoping; any authenticated user increases seat count for any org's subscription
HIGHPRIVESC28-004 — billing overage credit cache key uses planId without orgId; credit entries bleed across plan transitions, serving downgraded org's credits to a different org on the same plan slot

PRIVESC28-001 — Billing plan read from JWT subscriptionPlan claim grants enterprise access without payment

The most direct billing privilege escalation available in a MCP skill registry occurs when the server trusts a subscription plan identifier embedded directly in the JWT access token. When the middleware that enforces feature gating reads req.user.subscriptionPlan from a decoded JWT payload rather than from an authoritative database record, any user who can generate or modify a valid JWT signature — or who is using a registry that accepts unsigned or weakly signed tokens — can set subscriptionPlan to 'enterprise' and immediately unlock every gated capability in the registry. Even in registries where the JWT signature itself cannot be forged, the claim becomes stale the moment the organization downgrades their plan: a user whose organization canceled their enterprise subscription retains full enterprise access for the entire lifetime of their unexpired token.

The attack sequence for PRIVESC28-001 is simple and requires no special tooling. An attacker registers a free-tier account, obtains a valid JWT for that account, and then either forges a new JWT with an elevated subscriptionPlan claim (if the signing key is weak or the algorithm is none) or simply uses a JWT from a previous session when their organization held a higher-tier subscription. Every gated feature check in the codebase — model execution concurrency limits, premium skill capabilities, advanced analytics, priority queue access, enterprise SSO enforcement — reads from the same JWT claim and therefore grants the forged tier unconditionally. The business impact is total revenue loss on every feature the registry charges for at premium tiers, compounded by the fact that the attack scales to any number of attacker accounts simultaneously without any additional effort per account.

The correct architecture keeps the JWT opaque on the authorization side: the token carries only sub (the user ID) and standard claims. A short-lived DB-backed cache keyed on userId:orgId with a 60-second TTL holds the authoritative plan tier, populated from the billing database on first access and invalidated immediately when a plan change event is received. This means that even if a JWT is somehow replayed from a higher-tier session, the cache lookup returns the current plan from the database, not the claim from the token. The 60-second TTL ensures that plan changes propagate within a single minute across all running instances without requiring a distributed cache invalidation broadcast for every request.

PRIVESC28-001 fix: Remove subscriptionPlan from the JWT payload entirely. JWT carries only sub. Implement a DB-backed 60s Map cache keyed on userId:orgId. Publish a plan change event from the billing service on every subscription update and invalidate the cache entry for the affected userId:orgId key immediately. All feature gate checks read from the cache, never from the JWT.

WRONG
// Middleware trusts subscriptionPlan from the JWT payload
function requirePlan(requiredPlan) {
  return (req, res, next) => {
    const { subscriptionPlan } = req.user; // read from decoded JWT claim
    if (!meetsOrExceedsPlan(subscriptionPlan, requiredPlan)) {
      return res.status(403).json({ error: 'upgrade required' });
    }
    next();
  };
}

router.get('/api/skills/:id/execute',
  requireSession,
  requirePlan('pro'), // attacker sets subscriptionPlan:'enterprise' in JWT — passes unconditionally
  async (req, res) => { /* ... */ }
);
RIGHT
// DB-backed plan cache — JWT carries only sub
const planCache = new Map(); // key: 'userId:orgId', value: { plan, expiresAt }

async function getSubscriptionPlan(userId, orgId) {
  const cacheKey = `${userId}:${orgId}`;
  const cached = planCache.get(cacheKey);
  if (cached && cached.expiresAt > Date.now()) return cached.plan;
  const { plan } = await db.query(
    'SELECT plan FROM subscriptions WHERE org_id = $1 AND status = $2',
    [orgId, 'active']
  );
  planCache.set(cacheKey, { plan: plan ?? 'free', expiresAt: Date.now() + 60_000 });
  return plan ?? 'free';
}

// Invalidate on plan change events from billing service
billingEvents.on('plan_changed', ({ userId, orgId }) => {
  planCache.delete(`${userId}:${orgId}`);
});

function requirePlan(requiredPlan) {
  return async (req, res, next) => {
    const plan = await getSubscriptionPlan(req.session.userId, req.session.orgId);
    if (!meetsOrExceedsPlan(plan, requiredPlan)) {
      return res.status(403).json({ error: 'upgrade required' });
    }
    next();
  };
}

router.get('/api/skills/:id/execute',
  requireSession,
  requirePlan('pro'), // reads from DB cache, never from JWT
  async (req, res) => { /* ... */ }
);

PRIVESC28-002 — POST /api/billing/upgrade missing payment verification allows free plan upgrades

The plan upgrade endpoint POST /api/billing/upgrade accepts a targetPlan parameter and activates the requested plan tier for the requesting user's organization. The critical missing step is payment verification: the endpoint does not check whether a Stripe payment_intent for the new plan has been successfully confirmed before writing the upgraded plan to the subscriptions table. Any authenticated user can call the endpoint directly with a JSON body of {"targetPlan":"enterprise"} and their organization will be immediately activated on the enterprise tier without any financial transaction occurring. The revenue loss is direct and immediate — each successful call represents the full annual or monthly value of the enterprise subscription that the attacker has obtained for free.

Beyond simple free plan acquisition, PRIVESC28-002 enables a subtler abuse pattern. The registry charges plan-proportional fees to skill publishers who list their skills under a certain tier — a skill listed at the enterprise tier has access to more infrastructure resources and a larger user pool, with the publisher paying a higher listing fee. An attacker who upgrades their organization to enterprise via PRIVESC28-002 gains not only consumer feature access but also publisher access to enterprise-tier infrastructure at no cost, allowing them to publish skills that consume premium registry resources — dedicated execution workers, priority scheduling, higher storage quotas — that the registry is provisioning and paying for without receiving the corresponding revenue from the publisher.

The correct fix requires a Stripe payment_intent ID to be present in the request body and verifies via the Stripe API that the payment intent is in succeeded state and that its metadata correctly identifies the requesting organization and target plan before the database is updated. An idempotency key on the Stripe call prevents double-charging if the endpoint is called multiple times. Every plan activation — including those that go through the payment flow successfully — must emit an audit log entry containing the userId, orgId, previous plan, new plan, payment intent ID, and timestamp, so that any anomalous activations are detectable during a post-incident review.

PRIVESC28-002 fix: Add requireSession. Require a Stripe payment_intent ID in the request body. Verify via the Stripe API that the payment intent has status === 'succeeded' and that metadata.orgId and metadata.targetPlan match the request before writing to the database. Use an idempotency key. Emit an audit log entry on every plan change.

WRONG
// WRONG — no payment verification; any authenticated user upgrades to any plan for free
router.post('/api/billing/upgrade',
  requireSession,
  async (req, res) => {
    const { targetPlan } = req.body;
    await db.query(
      'UPDATE subscriptions SET plan = $1 WHERE org_id = $2',
      [targetPlan, req.session.orgId]
    );
    res.json({ ok: true, plan: targetPlan });
  }
);
RIGHT
// RIGHT — Stripe payment_intent verification before plan activation + audit log
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);

router.post('/api/billing/upgrade',
  requireSession,
  async (req, res) => {
    const { targetPlan, paymentIntentId } = req.body;

    if (!paymentIntentId) {
      return res.status(400).json({ error: 'paymentIntentId required' });
    }

    // Verify payment intent with Stripe
    let paymentIntent;
    try {
      paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId, {
        idempotencyKey: `upgrade-${req.session.orgId}-${targetPlan}`
      });
    } catch (err) {
      return res.status(400).json({ error: 'invalid paymentIntentId' });
    }

    if (paymentIntent.status !== 'succeeded') {
      return res.status(402).json({ error: 'payment not completed' });
    }

    // Verify payment intent metadata matches this request
    if (
      paymentIntent.metadata.orgId !== req.session.orgId ||
      paymentIntent.metadata.targetPlan !== targetPlan
    ) {
      return res.status(403).json({ error: 'payment intent mismatch' });
    }

    const previousPlan = await db.getOrgPlan(req.session.orgId);

    await db.query(
      'UPDATE subscriptions SET plan = $1, updated_at = NOW() WHERE org_id = $2',
      [targetPlan, req.session.orgId]
    );

    await audit.log('plan_upgraded', {
      userId: req.session.userId,
      orgId: req.session.orgId,
      previousPlan,
      newPlan: targetPlan,
      paymentIntentId,
      timestamp: new Date().toISOString()
    });

    // Invalidate plan cache for all users in this org
    await billingEvents.emit('plan_changed', { orgId: req.session.orgId });

    res.json({ ok: true, plan: targetPlan });
  }
);

PRIVESC28-003 — PATCH /api/billing/seats missing org scoping allows cross-org seat count manipulation

The seat management endpoint PATCH /api/billing/seats allows an organization administrator to increase or decrease the number of licensed seats on their subscription, with Stripe prorating the billing adjustment at the time of the change. The vulnerability is a missing org scoping check: the endpoint accepts a subscriptionId parameter in the request body and applies the seat change to whatever subscription that ID refers to, without verifying that the subscription belongs to the requesting user's organization. Any authenticated user can enumerate Stripe subscription IDs (which follow a predictable sub_ prefix format and are often visible in support emails, invoice PDFs, and billing portal URLs that are not access-controlled) and increase the seat count for another organization's subscription, generating a Stripe billing event that charges the victim organization for seats they did not request.

The inverse attack is equally damaging: an attacker can decrease the seat count of a competitor's subscription to below the number of users that organization currently has active, triggering Stripe enforcement that blocks new logins until the organization resolves the seat deficit. For a software company whose employees depend on the registry to run their skills as part of their daily workflow, having their seat count reduced to one at the start of a business day is an effective operational disruption attack that does not require any exploit of the registry's own infrastructure — it merely abuses the billing system's enforcement mechanism against the victim. The attacker pays nothing and faces no direct evidence in their own account that they performed the manipulation.

The fix requires three independent controls that must all pass before the seat change is applied. First, the subscription record must be fetched from the database and its org_id column must match req.session.orgId — a database-level check that cannot be bypassed by supplying a valid subscription ID from a different organization. Second, the user must hold the admin role within their organization, since seat management is an administrative action that should not be available to standard members. Third, the Stripe customer ID on the subscription must match the customer ID stored in the requesting organization's record in the registry database, providing a second independent verification that the Stripe-side resource belongs to the same organization as the session.

PRIVESC28-003 fix: Fetch the subscription record and verify subscription.orgId === req.session.orgId before any Stripe API call. Add requireRole('admin'). Verify that the Stripe customer ID on the subscription matches the customer ID stored in the requesting org's database record. Emit an audit log entry on every seat change.

WRONG
// WRONG — no org scoping; any authenticated user manipulates any org's seat count
router.patch('/api/billing/seats',
  requireSession,
  async (req, res) => {
    const { subscriptionId, seats } = req.body;
    // No check that subscriptionId belongs to req.session.orgId
    const subscription = await stripe.subscriptions.update(subscriptionId, {
      items: [{ id: req.body.itemId, quantity: seats }],
      proration_behavior: 'always_invoice'
    });
    await db.query(
      'UPDATE subscriptions SET seats = $1 WHERE stripe_subscription_id = $2',
      [seats, subscriptionId]
    );
    res.json({ ok: true, seats });
  }
);
RIGHT
// RIGHT — org scoping + admin role + Stripe customer ID ownership verification
router.patch('/api/billing/seats',
  requireSession,
  requireRole('admin'),
  async (req, res) => {
    const { subscriptionId, itemId, seats } = req.body;

    // Verify subscription belongs to requesting org (DB-level check)
    const sub = await db.query(
      'SELECT org_id, stripe_customer_id FROM subscriptions WHERE stripe_subscription_id = $1',
      [subscriptionId]
    );
    if (!sub.rows.length || sub.rows[0].org_id !== req.session.orgId) {
      return res.status(403).json({ error: 'subscription not found for your org' });
    }

    // Verify Stripe customer ID matches org record (independent second check)
    const org = await db.getOrg(req.session.orgId);
    if (sub.rows[0].stripe_customer_id !== org.stripeCustomerId) {
      return res.status(403).json({ error: 'customer ID mismatch' });
    }

    // Verify seat count is within plan limits
    const planLimits = await db.getPlanSeatLimits(org.plan);
    if (seats < 1 || seats > planLimits.max) {
      return res.status(400).json({ error: `seats must be between 1 and ${planLimits.max}` });
    }

    // Apply seat change via Stripe
    await stripe.subscriptions.update(subscriptionId, {
      items: [{ id: itemId, quantity: seats }],
      proration_behavior: 'always_invoice'
    });

    await db.query(
      'UPDATE subscriptions SET seats = $1, updated_at = NOW() WHERE stripe_subscription_id = $2 AND org_id = $3',
      [seats, subscriptionId, req.session.orgId]
    );

    await audit.log('seats_changed', {
      userId: req.session.userId,
      orgId: req.session.orgId,
      subscriptionId,
      newSeats: seats,
      timestamp: new Date().toISOString()
    });

    res.json({ ok: true, seats });
  }
);

PRIVESC28-004 — Billing overage credit cache key uses planId without orgId — credits bleed across plan transitions

The billing overage credit system tracks additional API call credits that organizations accumulate by pre-purchasing overage bundles beyond their plan's included allowance. These credits are stored in a cache layer keyed on planId alone, without including orgId in the key. When an organization downgrades from a plan and a different organization later activates the same plan identifier, the cache for that planId still holds the previous organization's credit balance. The incoming organization immediately reads and consumes those credits as if they were their own, with no payment having been made for them. The outgoing organization's pre-purchased credits — which represent real revenue received by the registry — are silently transferred to a third party.

The exploitability of PRIVESC28-004 depends on the speed of plan reassignment. In practice, registry plans are not arbitrarily reassigned — the plan identifier pro_monthly_v2 is a fixed string that all organizations on the Pro Monthly plan share. This means the bleed is not about reassigning a plan slot to a specific new organization, but about the fact that a cache entry set when Organization A was on pro_monthly_v2 will be served to Organization B, which is also on pro_monthly_v2, if Organization A's downgrade event does not properly invalidate the cache. Because the cache key does not include orgId, the cache layer cannot distinguish between Organization A's credits and Organization B's credits — they hash to the same key and the most recently written value wins, or the first-written value persists until TTL expiry. With a long TTL (or no TTL at all), Organization A's downgrade may leave a cache entry with a large credit balance that any other organization on the same plan will read as their own.

The fix is straightforward but requires touching every cache read and write path in the billing overage system. The cache key must be changed from planId to orgId:planId, ensuring that credit balances are always namespaced to the specific organization that holds them. A downgrade event handler must explicitly delete the cache entry for the downgrading organization's orgId:planId key. The TTL must be reduced to a strict 30 seconds so that any cache inconsistency resolves within half a minute even if the invalidation event is missed. And every cache read must include a secondary verification step that confirms the returned record's orgId field matches the requesting session's orgId before serving the credits, providing defense-in-depth against future cache key regressions.

PRIVESC28-004 fix: Change cache key from planId to orgId:planId. Add a downgrade event handler that explicitly deletes the cache entry for the downgrading org. Set a strict 30s TTL on all credit cache entries. Always verify that the cached record's orgId matches req.session.orgId before serving credits — reject and re-fetch if there is a mismatch.

WRONG
// WRONG — cache key uses planId only; credits bleed across orgs on the same plan
const creditCache = new Map(); // key: planId

async function getOverageCredits(orgId, planId) {
  if (creditCache.has(planId)) {
    return creditCache.get(planId); // returns any org's credits for this planId
  }
  const credits = await db.getOverageCredits(orgId, planId);
  creditCache.set(planId, credits);
  return credits;
}

billingEvents.on('plan_downgraded', ({ planId }) => {
  // Does not include orgId — may delete another org's valid cache entry
  // or may not invalidate if planId is shared across orgs
  creditCache.delete(planId);
});
RIGHT
// RIGHT — cache key = orgId:planId; invalidate on downgrade; strict TTL; orgId verification
const creditCache = new Map(); // key: 'orgId:planId', value: { credits, orgId, expiresAt }

async function getOverageCredits(orgId, planId) {
  const cacheKey = `${orgId}:${planId}`;
  const cached = creditCache.get(cacheKey);

  if (cached && cached.expiresAt > Date.now()) {
    // Defense-in-depth: verify orgId before serving
    if (cached.orgId !== orgId) {
      creditCache.delete(cacheKey);
      // Fall through to DB fetch
    } else {
      return cached.credits;
    }
  }

  const credits = await db.query(
    'SELECT credits FROM overage_credits WHERE org_id = $1 AND plan_id = $2',
    [orgId, planId]
  );
  const creditBalance = credits.rows[0]?.credits ?? 0;

  creditCache.set(cacheKey, {
    credits: creditBalance,
    orgId,                           // store orgId for verification on read
    expiresAt: Date.now() + 30_000   // strict 30s TTL
  });

  return creditBalance;
}

billingEvents.on('plan_downgraded', ({ orgId, planId }) => {
  // Invalidate the specific org's cache entry, not all orgs on this plan
  creditCache.delete(`${orgId}:${planId}`);
});

// Usage in overage enforcement
router.post('/api/billing/consume-overage',
  requireSession,
  async (req, res) => {
    const { planId, units } = req.body;
    const available = await getOverageCredits(req.session.orgId, planId);
    if (available < units) {
      return res.status(402).json({ error: 'insufficient overage credits' });
    }
    await db.query(
      'UPDATE overage_credits SET credits = credits - $1 WHERE org_id = $2 AND plan_id = $3',
      [units, req.session.orgId, planId]
    );
    // Invalidate cache after consumption
    creditCache.delete(`${req.session.orgId}:${planId}`);
    res.json({ ok: true, consumed: units, remaining: available - units });
  }
);
Detect SA-SKL-PRIVESC28 in your registry

SkillAudit scans for JWT claim-based plan authorization bypasses, missing payment intent verification on upgrade endpoints, absent org scoping on seat management operations, and cache key patterns that omit orgId in billing and subscription sub-routers across your entire MCP skill registry codebase.

Scan your registry
FindingSeverityEndpointImpact
PRIVESC28-001CRITICALJWT subscriptionPlan claimJWT claim forgery unlocks all gated features at any tier without payment; stale JWT retains elevated access after downgrade
PRIVESC28-002CRITICALPOST /api/billing/upgradeAny authenticated user activates any plan tier for free; enterprise subscription revenue loss; publisher gains paid infrastructure at no cost
PRIVESC28-003CRITICALPATCH /api/billing/seatsCross-org seat count manipulation; victim org charged for unsolicited seats or denied service by seat count reduction
PRIVESC28-004HIGHOverage credit cachePre-purchased overage credits bleed to other orgs on plan transition; silent revenue loss on credit bundles already billed

See also: SA-SKL-PRIVESC27 (audit history and report access control privilege escalation patterns) and SA-SKL-PRIVESC26 (API key and service account management privilege escalation patterns) for related billing-adjacent access control issues that compound with the billing endpoint vulnerabilities documented in this advisory.