Skip to content

Cross-session cancel is not authorized against the owning job session #53

@nficano

Description

@nficano

src/runtime/server.rs:407 dispatches every cancel envelope to handle_cancel without passing the authenticated session, and src/runtime/server.rs:925 then calls jobs.cancel(&job_id) solely by parsed job id. The global JobRegistry already stores the owning session_id, and job.subscribe has same-session or same-principal authorization at src/runtime/server.rs:1118, but cancel does not perform an equivalent check. A client that learns another session's job id can therefore cancel that job even though src/messages/subscriptions.rs documents that a job subscription does not grant cancel authority and the README describes subscribers as read-only.

Fix prompt: Update cancel handling so MessageType::Cancel passes the current SessionState into handle_cancel, look up the target job with a snapshot or an ownership-aware registry method, and return cancel.refused with a permission-denied reason unless the requester owns the job session or satisfies an explicit same-principal policy. Preserve cancellation for the owning session, keep malformed and unknown job id behavior, and add an integration test with two authenticated sessions where one session can observe or know the other job id but cannot cancel it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity:criticalCritical severity issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions