T05 · Unauthorized Access and Privilege Escalation
- Location
index.ts:313- Finding
Callback-Supplied Session Keys Permit Cross-Session Targeting
- Content
View full analysis
Vulnerability Details
File Location:
index.ts:313-332andindex.ts:457-476
Vulnerability Type: Callback authorization and session-binding weakness
Risk Level: MediumVulnerable Code
Approval callback:
typescript // Try sessionKey from body first (gateway strips query params), then URL params const bodySessionKey = body.sessionKey; const sessionKey = bodySessionKey || url.searchParams.get('sessionKey'); if (!sessionKey) { res.statusCode = 400; res.end(JSON.stringify({ error: "Missing sessionKey parameter" })); return true; } console.error(`[approval-callback] Using sessionKey: ${sessionKey} (from body: ${!!bodySessionKey})`); // Bind TaskFlow to the main session for webhook context const taskFlowApi = api.runtime?.taskFlow; if (!taskFlowApi) { res.statusCode = 500; res.end(JSON.stringify({ error: "TaskFlow API not available", request_id })); return true; } const boundTaskFlow = taskFlowApi.bindSession({ sessionKey, requesterOrigin: "snarling-webhook" });Notification callback:
typescript // sessionKey from body, or fall back to URL query params const url = new URL(req.url || '/', `http://localhost`); const sessionKey = bodySessionKey || url.searchParams.get('sessionKey'); if (!sessionKey) { res.statusCode = 400; res.end(JSON.stringify({ error: "Missing sessionKey parameter" })); return true; } console.error(`[notification-callback] Using sessionKey: ${sessionKey} (from body: ${!!bodySessionKey})`); // Bind TaskFlow to the session const taskFlowApi = api.runtime?.taskFlow; if (!taskFlowApi) { res.statusCode = 500; res.end(JSON.stringify({ error: "TaskFlow API not available", notification_id })); return true; } const boundTaskFlow = taskFlowApi.bindSession({ sessionKey, requesterOrigin: "snarling-webhook" });Technical Analysis
The callback handlers trust a
sessionKeysupplied i ...[truncated 2146 chars]- Remediation
View remediation
Remediation Suggestions
- Store the originating
sessionKeyin every pending approval and notification entry. - Resolve the session exclusively from the trusted pending entry:
typescript const entry = pendingApprovals.get(request_id); if (!entry) { // Reject unknown or expired request. } const sessionKey = entry.sessionKey; - Do not accept a session key from callback bodies or query parameters.
- If compatibility requires accepting it, compare it with the stored key and reject any mismatch.
- Bind each request identifier cryptographically to its session, request type, and expiration time.
- Use separate narrowly scoped callback credentials where practical instead of one global secret.
- Add tests proving that a callback cannot resume, wake, or enqueue events for a different session.
- Store the originating
