Repository navigation
Closed
Labels
P2Normal priority bug or improvement with limited blast radius.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:securityThis issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.leverLever delivery tracking issue
Description
Lane 2 of 5 for #2071. Filed by a Copilot agent.
Problem:
NodeService.StartMcpServer(~773-839) checks and then sets_enableMcpServer/_mcpServerwith no lock, and its catch sets_mcpServer = nullunconditionally.StopMcpServerAsyncswaps the fields with no lock.SetMcpEnabledholds_clientLock, and its comment wrongly says the stop is lock-protected.AttachClientcallsRegisterCapabilities()(which ends inStartMcpServer) after releasing_clientLock, on a threadpool thread from the NodeConnectorClientCreatedevent.
Failure: saving settings with node mode and MCP both on reconnects the node and calls SetMcpEnabled at the same time. That can start two servers, where the losing attempt nulls the winner, or it can lose a disable. Either way an untracked MCP listener, including system.run, keeps running and turning MCP off cannot stop it until restart.
Fix:
- Add a dedicated MCP lifecycle lock around start and stop.
- Re-check the enabled flag inside the lock.
- In the catch, clear the field only if it still holds this attempt.
- Correct the comment.
Done when:
- a regression test covers concurrent start/stop
- the required validation passes
- there is
winnodeMCP proof that enable/disable still works - a rubber-duck review is done
Reacted by clawsweeper
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:securityThis issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.leverLever delivery tracking issue
Type
Fields
Priority
None yet
Projects
- StatusShow more project fieldsBacklog
Activity
clawsweeper commentedon Nov 8, 2026
Codex review: this still needs some work.
Summary
Current main still permits competing MCP starts and disable-during-startup races; this collaborator-authored issue remains necessary.
Reproducibility: Source provides a concrete interleaving: startup passes its enabled check, disable observes no published server and returns, then startup publishes the listener; a separate competing-start failure can clear another attempt's server field. No live reproduction, build, or test was run.
Next step
Keep this security-sensitive repair with the audit owner: establish failing concurrent-start and disable-during-startup regressions, serialize lifecycle ownership, and verify MCP discovery, invocation, and disable through the shipped app.
Security
Needs attention: The race can leave authenticated MCP capabilities reachable after MCP is disabled.
Review details
Best possible solution:
Give enabled intent, listener publication, failed-attempt cleanup, and shutdown one synchronized lifecycle owner.
Do we have a high-confidence way to reproduce the issue?
Source provides a concrete interleaving: startup passes its enabled check, disable observes no published server and returns, then startup publishes the listener; a separate competing-start failure can clear another attempt's server field. No live reproduction, build, or test was run.
Is this the best way to solve the issue?
A dedicated lifecycle gate fits the defect if every startup and shutdown entry point participates, failed attempts cannot clear another listener, and asynchronous draining occurs without blocking capability or client locks.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against e70292487958.
Label changes
Label changes:
P2: Source establishes a limited local lifecycle race, without evidence of an active exploit or widespread broken workflow.impact:security: Disabling MCP can fail to revoke its listener, leaving authenticated access to sensitive capabilities available.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-security-review: Current issue advisory state selects this label.Label justifications:
P2: Source establishes a limited local lifecycle race, without evidence of an active exploit or widespread broken workflow.impact:security: Disabling MCP can fail to revoke its listener, leaving authenticated access to sensitive capabilities available.Evidence reviewed
Security concerns:
src/OpenClaw.Tray.WinUI/Services/NodeService.cs:775Startup and disable have no shared lifecycle synchronization, and failed startup can erase another attempt's listener reference. This threatens the user's transport-disable boundary; it does not establish bypass of bearer authentication, execution approvals, or sandbox controls.
Confidence: 0.97
What I checked:
src/OpenClaw.Tray.WinUI/Services/NodeService.cs:773, e70292487958)src/OpenClaw.Tray.WinUI/Services/NodeService.cs:870, e70292487958)src/OpenClaw.Tray.WinUI/Services/NodeService.cs:604, e70292487958)src/OpenClaw.Shared/Mcp/McpHttpServer.cs:169, e70292487958)tests/OpenClaw.Tray.Tests/AppRefactorContractTests.cs:719, e70292487958)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed November 8, 2026, 1:29 AM ET / 06:29 UTC.
fix(node): local MCP server can stay running or vanish when toggled d…