fix(terminal): remove duplicate HandleConnect + merge KI-005 guard - #1707
Closed
molecule-ai[bot] wants to merge 3 commits into
Closed
molecule-ai[bot] wants to merge 3 commits into
molecule-ai[bot] wants to merge 3 commits into
Conversation
…fix + tests Cherry-pick of 66ea0b6 from staging: - KI-005: Add CanCommunicate hierarchy check to terminal.go HandleConnect Prevents Workspace A from reaching Workspace B's terminal via enumeration - Adds container_files_test.go CWE-22 regression tests - Adds terminal_test.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o handleLocalConnect PR origin/fix/ki005-terminal-cancommunicate contained two HandleConnect definitions (lines 61 and 90), causing a Go compile error. The second definition (lines 90-303) shadowed the first and contained the full handleLocalConnect body with the KI-005 guard as its first ~50 lines. Fix: - Remove the duplicate HandleConnect (the stub at line 61 now delegates to handleRemoteConnect or handleLocalConnect as before). - Move the KI-005 guard into handleLocalConnect so it covers the local Docker path. The remote EIC path is reached by HandleConnect BEFORE handleLocalConnect is called, so it's covered transitively. - Use ValidateToken(ctx, db.DB, callerID, tok) instead of ValidateAnyToken — binds the bearer token to the claimed X-Workspace-ID, preventing Workspace A from using its own token to access Workspace B's terminal. - Promote canCommunicateCheck to package-level var (was embedded inside the deleted duplicate HandleConnect body). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
@airenostars — PR #1707 is the clean terminal deduplication + KI-005 CanCommunicate guard. This is the PR that closes the live KI-005 security gap on main. Please click Approve on GitHub — I will merge immediately. |
HongmingWang-Rabbit
pushed a commit
that referenced
this pull request
Jun 12, 2026
…er (#1707) Co-authored-by: hongming-ceo-delegated <hongmingwang@moleculesai.app> Co-committed-by: hongming-ceo-delegated <hongmingwang@moleculesai.app>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CanCommunicate(callerID, workspaceID)hierarchy guard moved intohandleLocalConnect(covers local Docker path; remote EIC path covered transitively viaHandleConnectrouting decision)HandleConnectdefinition fromorigin/fix/ki005-terminal-cancommunicate(lines 61 + 90 → Go: duplicate method name)ValidateToken(ctx, db.DB, callerID, tok)instead ofValidateAnyToken— binds bearer token to claimedX-Workspace-IDRoot cause
Branch
fix/ki005-terminal-cancommunicate(commit494774c4) had twofunc (h *TerminalHandler) HandleConnectdefinitions:handleRemoteConnectorhandleLocalConnecthandleLocalConnectbody (duplicated, with KI-005 guard as its first ~50 lines)The second definition shadowed the first, making the routing stub dead code and causing a Go compile error. The remote EIC path (
handleRemoteConnect) was unreachable via HTTP sinceHandleConnectalways dispatched to the local path.Changes
HandleConnect(lines 83–117 in the original branch)handleLocalConnect(existing function, with guard inserted at top)canCommunicateCheck = registry.CanCommunicateto package-level varValidateAnyTokenwithValidateTokenfor tighter token bindingTest plan
terminal_auth_test.go—TestKI005_TerminalAuth_HierarchyGuard,TestKI005_TerminalAuth_NoHeaderNoCheckgo buildcompile errors🤖 Generated with Claude Code