Skip to content

Close thread_stop/thread_archive approval bypass #1432

Closed

Description

@currentbits

Security fix in the Solenta repo (electron/orchServer.js, the coder-threads MCP server).

Bug: cross-thread stop/archive are meant to be "the user's decision in every permission mode, including Auto and Bypass" (issues #551 / #322). But assertCrossThreadApproved(args, action) (electron/orchServer.js ~line 536) starts with if (!fromId || fromId === targetId) return;, where fromId comes from the OPTIONAL, agent-supplied fromThreadId argument. thread_stop (~line 1058) and thread_archive (~line 1012, when archived:true) only run requireOwnThread (same-project check) before that gate. So any agent that simply omits fromThreadId can stop or archive ANY thread in its project with no human approval. The same "claimed caller id" weakness affects the merge gate's machine-turn check (runner.isAutoTurn(self.id) runs on whichever thread id the caller claims; see the "turn check is the real lock" comment ~line 500).

Root-cause fix (preferred): bind the caller's thread id at the transport, the same way #671 bound projectId. The per-thread MCP config is written in electron/memory-sup.js (search for where the coder-threads URL gets ?projectId=, ~line 1713) and the server reads projectId from the request URL in electron/orchServer.js (~line 1964). Add threadId=<caller> to that URL, pass it into createToolHandlers as a bound caller id, treat it as the caller everywhere, and reject a conflicting claimed fromThreadId (mirror the #671 projectId behaviour). Then in assertCrossThreadApproved a missing fromThreadId resolves to the bound id, so omitting it no longer skips the gate; self-stop/self-archive (bound id === target) stays ungated. External pairing clients (electron/pairing.js) keep their own capability tokens — check how they reach these handlers and make sure they are not broken or newly bypassing.

Minimum acceptable fallback if transport binding is too big: when fromThreadId is absent and the target is not provably the caller, require approval instead of returning early.

Tests: add a test that a worker calling thread_stop on its lead WITHOUT fromThreadId is refused, one that self-stop still works, and one that a conflicting claimed fromThreadId is rejected. Find the existing orchServer tests under test/ (grep for assertCrossThreadApproved or "Stopping another thread"). Note: electron/providers.js contains a NUL byte, so use LC_ALL=C grep -a on it. Before running electron tests in a worktree, clone node_modules and build core/dist per the repo's worktree setup.

Filed from a Solenta suggested-work chip.

Activity

  1. added
    plan:todo
    on Oct 4, 2026
  2. currentbits commented on Oct 4, 2026

    @currentbits
    OwnerAuthor

    Reproduced at 615b38a0. With fromThreadId left out, a lead on a machine turn stops and archives another thread with no approval. The existing test at electron/test/orch-server.test.js:1066-1071 asserts this behaviour as correct, so it has to be rewritten.

    Scope this issue to the fallback, which needs no transport binding. In assertCrossThreadApproved, treat an empty fromThreadId as an unknown caller. Refuse cross-thread stop/archive unless the call is provably a self-action, i.e. it carries fromThreadId === threadId. That repro passes without any binding.

    The rest belongs to #1425's transport binding:

    • I2: a claimed threadId on thread_merge lets a sibling worker merge another worker onto main. Reproduced.
    • I4 for bound callers.
    • I4 for unbound callers (omitting fromThreadId on thread_send skips the unattended-sender refusal) can't be fixed inside a handler at all.

    The repro tests are in research_notes/T3 orchestrator ACP UX and repros/repros/ on branch coder/i-want-you-to-research-t3-codes-orchestr-fae77a.

  3. added
    plan:doing
    and removed
    plan:todo
    on Oct 11, 2026
  4. currentbits commented on Oct 11, 2026

    @currentbits
    OwnerAuthor

    Working the preferred fix: bind threadId=<caller> on the coder-threads MCP URL (same as #671 projectId), pass it into createToolHandlers as boundThreadId, reject a conflicting claimed fromThreadId, and treat a missing fromThreadId as the bound id (or as not-self when unbound). Self-stop/self-archive stay ungated. Pairing stays on its own capability-token handlers.

    Tests first (TDD): worker thread_stop on lead without fromThreadId refused; self-stop still works; conflicting fromThreadId rejected.

  5. currentbits commented on Oct 11, 2026

    @currentbits
    OwnerAuthor

    Implemented the transport bind (not just the fallback).

    • coder-threads MCP URL now includes threadId=<caller> next to projectId= (memory-sup + every runner/workflow caller that already had a thread id).
    • createToolHandlers takes boundThreadId from the request URL. Conflicting claimed fromThreadId is rejected. Missing fromThreadId resolves to the bound id; if still empty, the target is not treated as self and approval is required.
    • Self-stop/self-archive stay ungated when bound id === target.
    • Merge/PR threadId (the caller) is the same bound id, so isAutoTurn cannot run on a claimed lead.
    • Pairing stays on createExternalHandlers + capability tokens.

    Tests: worker thread_stop on lead without fromThreadId refused; bound self-stop works; conflicting fromThreadId rejected. orch-server, orch-merge, kimi-home, pairing green. Nothing committed.

  6. currentbits commented on Oct 11, 2026

    @currentbits
    OwnerAuthor

    PR: #1598

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:doing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions