← Back to Pull requests

fix(tasks): bind tasks to token issuer as well as subject #296

Closed
unknown closed this pull request without merging on Oct 15, 2026 06:55 UTC
View on GitHub
unknown unknown commented on Oct 14, 2026 08:48 UTC
Author

Problem

Tasks were owned by the token sub alone. A subject is only unique within its issuer, so on a server with several authorizationServers a user from idp-b with the same sub as a user from idp-a could see the other user's tasks in tasks/list and call tasks/get, tasks/result and tasks/cancel on them. #245 fixed this for sessions but not for tasks.

Fix

  • TaskRecord gets authIssuer, set at creation from request.tokenIssuer (the normalized issuer from the auth preHandler, including introspection:<endpoint> for introspected tokens without iss). It is stripped from the wire format like authSubject.

  • With authorization enabled, assertTaskAccess requires both subject and issuer to match. A foreign task still answers exactly like an unknown id, so callers cannot tell existence from ownership.

  • TaskStore.list(owner, options) now takes { subject, issuer } (new exported type TaskOwner) instead of a bare subject. Both stores and the interface are updated. This signature was changed by #239 and has not been released yet.

  • The Redis per-owner index key is now mcp:tasks:owner:<encodeURIComponent(iss)>:<encodeURIComponent(sub)>, so a : in either part cannot make two owners share a key. delete removes the entry from the same key.

  • Without authorization nothing changes. Tasks stay reachable by their random id, and tasks/list stays refused.

  • README: the task security note now says tasks are bound to issuer and subject, and the custom-store list contract is updated.
  • Migration note

    With authorization enabled, tasks created before this change have no issuer. They fail closed: they cannot be reached and expire with their ttl. Old Redis index keys (mcp:tasks:owner:<sub>) are no longer read and expire on their own.

    Overlap

    Open #289 (fix/249-task-retention-quota) also uses the per-owner Redis key layout and the store list owner argument. Whichever PR merges second needs to adopt the issuer-aware key and the TaskOwner signature.

    Tests

  • test/task-owner-issuer.test.ts: the issue's scenario (two issuers, same sub) for tasks/get, tasks/result, tasks/cancel and tasks/list, on memory and Redis; the same issuer and subject still works, including a trailing-slash issuer; a task without authIssuer is unreachable when auth is on (memory and Redis); auth off is unchanged.

  • Store tests: issuer-scoped list on both stores, Redis index keys with : in the issuer or subject, and toWireTask dropping authIssuer.

  • npm run lint, npm run typecheck, npm test: 677/677 pass.
  • Fixes #295

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM

    Diff: 339 lines (+254 / -85) across 4 files Reviewer: rozzilla Review duration: 1326m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.65) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.65 · 339 lines diff across 4 files
    0.65
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.349
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.065
    Real PR Conversation Timeline
    1 comments
    "Review active on #296"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.4% (HIGH) · Higher = larger blast radius
    65.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.9% · Safe to merge
    25.9%