Claude MCP skill privilege escalation — skill webhook configuration and delivery management endpoints — SA-SKL-PRIVESC31
SA-SKL-PRIVESC31 documents four privilege escalation vulnerabilities in MCP skill registry webhook configuration and delivery management endpoints. These endpoints govern how webhook consumers configure delivery targets, manage delivery scopes, and control which events are forwarded to their registered endpoints. PRIVESC31-001 reads webhook delivery scopes directly from the JWT webhookScopes claim, allowing any user who can forge or modify a JWT to self-assign full admin delivery access including delivery to any registered endpoint. PRIVESC31-002 permits any webhook owner to expand their own delivery scopes beyond what their account role authorizes, adding administrator-tier delivery scopes to basic notification-only webhooks. PRIVESC31-003 allows any authenticated user to overwrite any other account's webhook delivery endpoints due to a missing ownership check, silently redirecting other accounts' webhook notifications to attacker-controlled URLs. PRIVESC31-004 bleeds elevated scope cache entries from deleted webhooks to new webhooks that reuse the same sequential integer ID, granting the new webhook owner the elevated privileges of the previous owner without any deliberate escalation action.
webhookScopes claim; craft JWT with webhookScopes:['admin:delivery:all'] grants full webhook admin access including delivery to any registered endpointPOST /api/webhooks/:id/scopes missing scope boundary check; any webhook owner expands delivery scopes beyond account role permits, adding admin:delivery:all scope to a basic notification-only webhook; fix: requireSession; validate requested scopes do not exceed account role's permitted scope set; Zod WebhookScopeSchema; audit logPATCH /api/webhooks/:id/endpoints missing ownership check; any authenticated user modifies any other account's webhook delivery endpoints, redirecting their webhook notifications to attacker-controlled URLsPRIVESC31-001 — JWT webhookScopes claim self-assignment grants full admin delivery access
The webhook delivery authorization middleware reads the set of delivery scopes granted to a webhook directly from the webhookScopes claim in the caller's JWT. The JWT is validated for signature authenticity and expiry, but the registry's scope enforcement logic trusts whatever scope values are present in the signed token without cross-referencing them against the database record for the webhook. Any user who can obtain a legitimately signed JWT — through the normal authentication flow — and can then construct a new JWT with a modified webhookScopes claim will have that claim accepted as authoritative if the JWT signing secret is known or obtainable, or if the registry is misconfigured to accept JWTs signed with a weaker algorithm like HS256 with a guessable key.
The scope admin:delivery:all is the registry's highest-privileged webhook scope, granting the ability to configure delivery to any endpoint registered in the system, receive event payloads from any org's skills, and modify global webhook routing rules. By embedding this scope in a crafted JWT, a low-privileged user with only notify:delivery:own authorization escalates to full webhook admin access. The escalation is particularly difficult to detect because the JWT signature validates correctly — the token is not forged in the cryptographic sense — and the scope values appear in the access log as legitimate claims on a valid token.
The fundamental design flaw is using the JWT as the source of truth for authorization data that must be validated against the database. JWTs are appropriate for carrying claims that do not require database validation on each request — user identity, session expiry, coarse-grained role assignment. Delivery scope grants are fine-grained, mutable, and subject to revocation; they must be sourced from the database, not from the token. A user who is stripped of elevated scopes by an administrator continues to hold those scopes in any unexpired JWT they already possess, creating a window during which the revocation is ineffective.
PRIVESC31-001 fix: Remove webhookScopes from the JWT entirely. The JWT carries only the subject identifier (sub). On each request to a scope-gated endpoint, look up the webhook's current delivery scopes from the database using a short-lived in-process Map cache keyed on webhookId with a 60-second TTL. Invalidate the cache entry immediately when a scope change is committed to the database. This ensures that scope revocations take effect within 60 seconds across all processes without requiring a full DB query on every request.
// Middleware reads webhook scopes directly from JWT claim
function requireWebhookScope(requiredScope) {
return (req, res, next) => {
const token = verifyJwt(req.headers.authorization);
// webhookScopes claim read from token — attacker can craft this value
const scopes = token.webhookScopes ?? [];
if (!scopes.includes(requiredScope)) {
return res.status(403).json({ error: 'insufficient scope' });
}
next();
};
}
// In-process cache: Mapconst scopeCache = new Map(); const SCOPE_TTL_MS = 60_000; async function requireWebhookScope(requiredScope, req, res, next) { const token = verifyJwt(req.headers.authorization); // JWT carries only sub — no scope claims trusted from token const webhookId = req.params.id; const cached = scopeCache.get(webhookId); let scopes; if (cached && Date.now() - cached.cachedAt < SCOPE_TTL_MS) { scopes = cached.scopes; } else { scopes = await db.getWebhookScopes(webhookId); scopeCache.set(webhookId, { scopes, cachedAt: Date.now() }); } if (!scopes.includes(requiredScope)) { return res.status(403).json({ error: 'insufficient scope' }); } next(); }
PRIVESC31-002 — Missing scope boundary check on scope expansion endpoint allows any webhook owner to add admin:delivery:all
The webhook scope management endpoint at POST /api/webhooks/:id/scopes accepts an array of delivery scope strings in the request body and appends them to the webhook's current scope set. The endpoint validates that the requesting user owns the webhook — preventing one user from modifying another user's webhook scopes — but does not validate that the requested scope values fall within the set of scopes permitted by the requesting account's role. A basic account with role member is permitted to hold webhooks with scopes limited to notify:delivery:own and read:events:own. The endpoint allows that same member-role account to add admin:delivery:all, write:webhooks:all, and other administrator-tier scopes to any webhook they own, because there is no check comparing the requested scope against the account's role-permitted scope ceiling.
The escalation is persistent: once the unauthorized scope is added to the webhook's database record, it remains there until an administrator discovers and removes it. The scope addition appears in the webhook's configuration as a legitimately owner-initiated change, with the requesting user correctly identified as the webhook's owner in the audit trail — the ownership check passed, so the audit log shows no anomaly. Organizations that audit webhook configurations periodically may not notice that a member-tier account holds administrator-scoped webhooks if they check only for ownership rather than scope-role consistency.
PRIVESC31-002 fix: Add requireSession and retrieve the requesting account's role from the session. Before appending any requested scope, validate each scope against PERMITTED_SCOPES[req.session.role] — the statically defined maximum scope set for each account role. Validate the full requested scope array against WebhookScopeSchema using Zod to ensure no scope values outside the known enum are accepted. Write an audit log entry for every scope addition, including the account's role and the specific scopes added, to enable automated scope-role consistency monitoring.
PRIVESC31-003 — Missing ownership check on webhook endpoint modification redirects any account's notifications to attacker-controlled URLs
The webhook delivery endpoint modification handler at PATCH /api/webhooks/:id/endpoints accepts an updated list of delivery endpoint URLs and replaces the webhook's current endpoint configuration. The handler validates that the requesting user is authenticated but does not verify that the target webhook (req.params.id) belongs to the requesting user's account. Any authenticated user who knows or enumerates a webhook ID can overwrite that webhook's delivery endpoints with URLs under their control. Webhook IDs are typically sequential integers or short UUIDs discoverable through the webhooks listing API or by observing the IDs assigned to their own webhooks.
The practical impact is notification hijacking: by replacing the delivery endpoints of a victim account's production webhook, the attacker begins receiving all event payloads that the victim's integration was supposed to receive. For skill registry webhooks, these payloads include install events (revealing which users are installing which skills), audit events (revealing administrative actions taken by the victim account), security alert events (revealing that the victim account's skills have been flagged for security issues before the owner is notified through legitimate channels), and billing events (revealing usage and cost data). The attacker's replacement endpoints receive these payloads while the victim's legitimate endpoints receive nothing, potentially causing the victim's automated integrations to miss critical events without any immediate visible indication that their webhook has been modified.
PRIVESC31-003 fix: Add an ownership check immediately after session validation: fetch the webhook record and assert webhook.userId === req.session.userId before accepting any endpoint modifications. For webhooks owned by org-level service accounts, check webhook.orgId === req.session.orgId and requireRole('admin'). Write an audit log entry for every endpoint modification, including the previous endpoint list and the new endpoint list, to enable detection of unauthorized modifications through audit log review. Consider sending an email notification to the webhook owner's registered address on every endpoint modification.
router.patch('/webhooks/:id/endpoints',
requireSession,
async (req, res) => {
// No ownership check — any authenticated user can modify any webhook
const { endpoints } = req.body;
await db.updateWebhookEndpoints(req.params.id, endpoints);
res.json({ updated: true });
}
);
router.patch('/webhooks/:id/endpoints',
requireSession,
async (req, res) => {
const webhook = await db.getWebhook(req.params.id);
// Ownership check — reject if webhook belongs to a different user
if (!webhook || webhook.userId !== req.session.userId) {
return res.status(403).json({ error: 'forbidden' });
}
const { endpoints } = EndpointUpdateSchema.parse(req.body);
const previous = webhook.endpoints;
await db.updateWebhookEndpoints(req.params.id, endpoints);
await auditLog.write({
event: 'webhook_endpoints_modified',
webhookId: req.params.id,
actor: req.session.userId,
previous,
updated: endpoints
});
res.json({ updated: true });
}
);
PRIVESC31-004 — Scope cache key collision bleeds elevated scopes from deleted webhooks to new webhooks with the same sequential ID
The webhook delivery scope cache uses webhookId alone as the cache key — a simple integer or short identifier assigned sequentially when webhooks are created. When a webhook with elevated delivery scopes (for example, an admin's webhook with admin:delivery:all) is deleted, the scope cache entry for that webhook's ID is not explicitly invalidated; it expires naturally after the cache TTL. If a new webhook is created before the TTL expires and the registry assigns it the same ID as the deleted webhook (a natural consequence of sequential integer assignment with ID reuse), the new webhook owner's requests hit the unexpired cache entry from the deleted webhook and are served the elevated scopes that belonged to the previous, now-deleted webhook owner.
The new webhook owner receives admin:delivery:all scope without any action on their part and without any administrative authorization. From the registry's perspective, the scope cache lookup returns a valid, non-expired entry for the requested webhook ID — there is no indication that the cached scopes belong to a different entity than the current webhook holder. The cache bleed persists until the TTL expires (up to 60 seconds in the nominal case, or longer if the cache TTL is configured for performance), during which the new webhook owner has unrestricted delivery admin access.
The vulnerability has an amplified impact in high-churn environments where webhooks are frequently created and deleted as part of CI/CD pipeline scaffolding or automated testing. Each deletion followed by rapid ID reuse creates a window during which the new ID holder inherits the previous ID's cached state. An attacker who can observe or control the ID assignment order — by deleting a known high-privilege webhook and immediately creating a new webhook to claim the freed ID — can deliberately inherit elevated scopes rather than waiting for a coincidental collision.
PRIVESC31-004 fix: Include orgId in the scope cache key: use `${orgId}:${webhookId}` as the Map key. On webhook deletion, explicitly delete the cache entry for that webhook's key before completing the deletion transaction. Enforce a strict 60-second TTL on all cache entries and always verify that the cached entry's orgId matches the requesting session's orgId before serving cached scopes, regardless of cache TTL status. Use UUIDs rather than sequential integers for webhook IDs to eliminate the possibility of deterministic ID reuse by an attacker who can time deletions and creations.
SkillAudit scans your registry's webhook configuration and delivery management endpoints for all four PRIVESC31 patterns, plus the other privilege escalation families documented in the SA-SKL-PRIVESC series. Get started free — 3 audits/month on public repos, results in 60 seconds.