← Security advisories

Claude MCP skill privilege escalation — skill notification and alert subscription endpoints — SA-SKL-PRIVESC35

SA-SKL-PRIVESC35 documents four privilege escalation vulnerabilities in MCP skill registry notification and alert subscription endpoints. Notification subscription surfaces are high-value targets for privilege escalation because they control who receives security alerts, audit findings, and compliance notifications — information whose redirection or unauthorized access can silently neutralize an organization's operational security posture. A JWT notificationScope claim that is trusted without database verification allows any attacker with JWT signing capability to subscribe to all organizations' notification streams including private security advisories. A missing scope boundary check allows any user to self-assign administrative alert scopes beyond their account tier. A missing ownership check on the subscription update endpoint allows redirecting any account's alert delivery to attacker-controlled endpoints. And a cache key that uses only the subscription ID allows elevated scopes from deleted subscriptions to bleed into newly created subscriptions with the same sequential integer ID.

SA-SKL-PRIVESC35 findings at a glance
CRITICALPRIVESC35-001 — notification subscription scope read from JWT notificationScope claim; craft JWT with notificationScope:'admin:all' grants access to all organizations' notification streams including private security alerts; fix: DB-backed 60s Map cache keyed on userId+subscriptionId; JWT carries only sub; invalidate on scope change event
CRITICALPRIVESC35-002 — POST /api/notifications/subscriptions missing scope boundary check; any user subscribes to notification scopes exceeding their account permissions, adding admin:security:all scope to a basic notification subscription; fix: requireSession; validate requested scope does not exceed account role's permitted scope set; Zod NotificationScopeSchema; audit log
CRITICALPRIVESC35-003 — PATCH /api/notifications/subscriptions/:id missing ownership check; any authenticated user modifies any other account's notification subscription settings, redirecting their alert notifications to attacker-controlled endpoints; fix: require subscription.userId === req.session.userId; requireSession; audit log
HIGHPRIVESC35-004 — notification subscription scope cache key uses subscriptionId without userId; scope cache entries bleed across subscription deletion and recreation: deleted subscription's elevated scopes served to new subscription with same sequential integer ID; fix: cache key = userId:subscriptionId; invalidate on subscription deletion; strict 60s TTL

PRIVESC35-001 — JWT notificationScope claim grants cross-org notification stream access

Severity: CRITICAL

The notification subscription service reads the subscriber's notification scope from the notificationScope claim in the session JWT, without verifying the claim against the database record. An attacker who can craft a JWT — by exploiting a JWT signing weakness, a misconfigured JWT library, or a leaked signing key — sets notificationScope: 'admin:all' in the token payload. The notification service grants the attacker access to all organizations' notification streams, including private security advisory notifications, compliance audit alerts, and incident response escalations that contain details of unpatched vulnerabilities.

The fix moves notification scope storage out of the JWT entirely. The JWT carries only the subject identifier (sub). Subscription scope is read from a DB-backed in-memory cache keyed on userId:subscriptionId, with a 60-second TTL. Cache entries are invalidated immediately when an admin changes a subscription's scope, ensuring that scope changes propagate within one TTL window.

Vulnerable
// middleware/notification-auth.js — trusts JWT notificationScope claim
function getNotificationScope(req) {
  const token = verifyJwt(req.headers.authorization);
  return token.notificationScope; // 'admin:all' from attacker-crafted JWT
}

router.get('/stream', (req, res) => {
  const scope = getNotificationScope(req);
  if (scope === 'admin:all') {
    return streamAllOrgNotifications(res); // all orgs' private security alerts
  }
  return streamOwnNotifications(req.userId, res);
});
Fixed
// middleware/notification-auth.js — DB-backed scope cache
const scopeCache = new Map(); // key: 'userId:subscriptionId' → { scope, expiresAt }

async function getNotificationScope(userId, subscriptionId) {
  const key = `${userId}:${subscriptionId}`;
  const cached = scopeCache.get(key);
  if (cached && cached.expiresAt > Date.now()) return cached.scope;

  const sub = await NotificationSubscription.findOne({ _id: subscriptionId, userId });
  if (!sub) throw new Error('Subscription not found');

  scopeCache.set(key, { scope: sub.scope, expiresAt: Date.now() + 60_000 });
  return sub.scope;
}

router.get('/stream', requireSession, async (req, res) => {
  const scope = await getNotificationScope(
    req.session.userId, req.query.subscriptionId
  ); // scope from DB, not JWT
  return streamNotificationsForScope(req.session.userId, scope, res);
});

PRIVESC35-002 — Missing scope boundary check allows self-assignment of admin alert scopes

Severity: CRITICAL

The subscription creation endpoint at POST /api/notifications/subscriptions accepts a scope array in the request body without checking whether the requested scopes are within the caller's account tier's permitted scope set. A basic free-tier user submits a subscription creation request with scopes: ['admin:security:all', 'org:billing:all', 'platform:incidents:all']. The endpoint creates the subscription with these elevated scopes, granting the user access to all organizations' security alerts, billing events, and platform incident notifications — features restricted to Team-plan users with admin roles.

The fix validates the requested scope array against a role-scoped permission set before creating the subscription. The PERMITTED_SCOPES map defines the maximum scope set for each account role. Any requested scope that is not in the caller's permitted set is rejected with a 403, and the full request is logged for security review.

Vulnerable
// POST /api/notifications/subscriptions
router.post('/', requireSession, async (req, res) => {
  const { scopes, webhookUrl, name } = req.body;
  // No scope boundary check — any scope can be requested
  const sub = await NotificationSubscription.create({
    userId: req.session.userId,
    scopes, webhookUrl, name,
  });
  return res.json(sub);
});
Fixed
// POST /api/notifications/subscriptions
const PERMITTED_SCOPES = {
  free: new Set(['own:security', 'own:usage', 'own:billing']),
  pro: new Set(['own:security', 'own:usage', 'own:billing', 'org:security', 'org:usage']),
  team_admin: new Set(['own:security', 'own:usage', 'own:billing',
    'org:security', 'org:usage', 'org:billing', 'admin:security:all']),
};

router.post('/', requireSession, async (req, res) => {
  const { scopes, webhookUrl, name } = NotificationSubCreateSchema.parse(req.body);
  const user = await User.findById(req.session.userId);
  const permitted = PERMITTED_SCOPES[user.planRole] ?? PERMITTED_SCOPES.free;
  const forbidden = scopes.filter(s => !permitted.has(s));
  if (forbidden.length > 0) {
    await AuditLog.create({ action: 'notification.scope.boundary.violation',
      userId: req.session.userId, attemptedScopes: scopes });
    return res.status(403).json({ error: 'Requested scopes exceed account permissions' });
  }
  const sub = await NotificationSubscription.create({
    userId: req.session.userId, scopes, webhookUrl, name,
  });
  return res.json(sub);
});

Scope escalation via self-service subscription creation is a silent privilege boundary violation. Unlike role elevation attacks that target admin endpoints, self-assigned scope expansion occurs through normal subscription flows that are rarely audited. Validate every requested scope against the caller's permitted scope set before persisting the subscription, and log every boundary violation for security review.

PRIVESC35-003 — Missing ownership check redirects any account's alert notifications to attacker endpoints

Severity: CRITICAL

The subscription update endpoint at PATCH /api/notifications/subscriptions/:id does not verify that the subscription belongs to the authenticated caller. Any authenticated user can modify any other account's notification subscription by supplying its ID, including changing the webhookUrl to an attacker-controlled endpoint. Security-conscious organizations that have configured notification subscriptions to deliver alerts to their internal SIEM or incident response system find those alerts silently redirected to the attacker's collection endpoint, with no indication that the delivery destination has changed.

The alert redirection is particularly impactful for security advisory notifications: the target organization continues to believe their SIEM is receiving SkillAudit alerts, while the attacker receives advance notice of unpatched vulnerabilities in the organization's installed skills. The fix adds an ownership check that verifies subscription.userId === req.session.userId before applying any update, and logs every subscription modification to the audit trail.

Vulnerable
// PATCH /api/notifications/subscriptions/:id
router.patch('/:id', requireSession, async (req, res) => {
  const sub = await NotificationSubscription.findById(req.params.id);
  if (!sub) return res.status(404).json({ error: 'Not found' });
  // No ownership check — any authenticated user can modify any subscription
  Object.assign(sub, req.body);
  await sub.save();
  return res.json(sub);
});
Fixed
// PATCH /api/notifications/subscriptions/:id
router.patch('/:id', requireSession, async (req, res) => {
  const sub = await NotificationSubscription.findById(req.params.id);
  if (!sub) return res.status(404).json({ error: 'Not found' });
  if (sub.userId.toString() !== req.session.userId) {
    return res.status(403).json({ error: 'Forbidden' });
  }
  const updates = NotificationSubUpdateSchema.parse(req.body);
  Object.assign(sub, updates);
  await sub.save();
  await AuditLog.create({
    action: 'notification.subscription.updated',
    subscriptionId: sub._id,
    userId: req.session.userId,
    changes: updates,
    timestamp: new Date(),
  });
  return res.json(sub);
});

PRIVESC35-004 — Scope cache key collision bleeds elevated scopes to newly created subscriptions

Severity: HIGH

The notification scope cache uses only the subscription ID as the cache key, without including the user ID. When a subscription is deleted, the cache entry is not invalidated. If a new subscription is subsequently created with the same sequential integer ID — which occurs naturally in auto-increment primary key schemes under sequential-delete-and-recreate patterns — the new subscription inherits the cached scope of the deleted subscription.

An attacker who holds a Team-plan subscription with admin:security:all scope deletes their subscription (which does not invalidate the cache), then induces a new basic-tier subscription to be created with the same ID via the sequential integer sequence. The basic-tier subscription owner finds their subscription delivering admin-scoped security alerts they should not have access to — and the attacker, who originally held the elevated subscription, retains a window to harvest those alerts before the cache entry expires.

The fix changes the cache key to userId:subscriptionId, explicitly invalidates the cache entry on subscription deletion, and enforces a strict 60-second TTL to limit the blast radius of any future collision. Because the user ID is included in the key, a new subscription created with the same integer ID for a different user will generate a different cache key and not inherit any prior entry.

Vulnerable
// scope cache keyed on subscriptionId only
const scopeCache = new Map(); // key: subscriptionId

async function getScopeForSubscription(subscriptionId) {
  if (scopeCache.has(subscriptionId)) {
    return scopeCache.get(subscriptionId); // stale entry from deleted subscription
  }
  const sub = await NotificationSubscription.findById(subscriptionId);
  scopeCache.set(subscriptionId, sub.scopes);
  return sub.scopes;
}

// No cache invalidation on DELETE
router.delete('/:id', requireSession, async (req, res) => {
  await NotificationSubscription.findByIdAndDelete(req.params.id);
  // scopeCache entry not cleared — bleeds to next subscription with same ID
  return res.status(204).end();
});
Fixed
// scope cache keyed on userId:subscriptionId
const scopeCache = new Map(); // key: 'userId:subscriptionId'

async function getScopeForSubscription(userId, subscriptionId) {
  const key = `${userId}:${subscriptionId}`;
  const cached = scopeCache.get(key);
  if (cached && cached.expiresAt > Date.now()) return cached.scopes;

  const sub = await NotificationSubscription.findOne({ _id: subscriptionId, userId });
  if (!sub) throw new Error('Subscription not found');
  scopeCache.set(key, { scopes: sub.scopes, expiresAt: Date.now() + 60_000 });
  return sub.scopes;
}

router.delete('/:id', requireSession, async (req, res) => {
  const sub = await NotificationSubscription.findOne({
    _id: req.params.id, userId: req.session.userId,
  });
  if (!sub) return res.status(404).json({ error: 'Not found' });
  await sub.deleteOne();
  scopeCache.delete(`${req.session.userId}:${req.params.id}`); // explicit invalidation
  return res.status(204).end();
});

Remediation summary

FindingSeverityPrimary remediationSecondary hardening
PRIVESC35-001CriticalRemove scope from JWT; use DB-backed cache keyed on userId+subscriptionId; invalidate on scope changeJWT carries only sub; short JWT TTL; scope change audit log
PRIVESC35-002CriticalValidate requested scopes against PERMITTED_SCOPES[planRole] before persisting; audit log on boundary violationZod NotificationScopeSchema; scope review in account upgrade/downgrade flow
PRIVESC35-003CriticalRequire subscription.userId === req.session.userId before update; audit log every changeWebhook URL change notification to subscription owner; delivery destination change alert
PRIVESC35-004HighCache key = userId:subscriptionId; invalidate on deletion; strict 60s TTLUUID primary keys instead of sequential integers to prevent ID reuse

Find privilege escalation vulnerabilities like these before attackers do. SkillAudit scans your MCP skill registry notification endpoints for all four SA-SKL-PRIVESC35 patterns plus the broader privilege escalation advisory series. See the SA-SKL-PRIVESC34 team workspace advisory and the SA-SKL-PRIVESC33 audit history advisory for related findings. Connect your repository at skillaudit.dev.