fix(handlers): KI-005 — CanCommunicate hierarchy guard on terminal endpoint - #1690
Closed
molecule-ai[bot] wants to merge 4 commits into
Closed
molecule-ai[bot] wants to merge 4 commits into
molecule-ai[bot] wants to merge 4 commits into
Conversation
Both handlers used shell-interpolated concat form "/configs/" + path which allows path traversal to escape the /configs bind mount. Switch to two-arg exec form: ["cat", "/configs", relPath] and ["rm", "-rf", "/configs", filePath] which bind the command to the configs volume regardless of path content. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Validate() scans: SELECT id, prefix, org_id FROM org_api_tokens (sql.NullString for org_id). Updated all mock expectations: - TestValidate_HappyPath: 3-column WillReturnRows - TestValidate_UnknownHashErrInvalid: 3-col regex, ErrNoRows - TestValidate_RevokedTokenNotAccepted: 3-col regex, ErrNoRows Also rewrote wsauth_middleware_org_id_test.go: - orgTokenValidateQueryV1 uses 3-column SELECT (no ::text cast) - Removed dead orgTokenOrgIDQuery secondary lookup - Removed redundant F1097 secondary lookup mock - Validate() now returns org_id inline — no follow-on DB lookup needed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…I-005) KI-005 CRITICAL: terminal.go HandleConnect had zero CanCommunicate check. Any workspace could reach any other workspace's terminal by knowing the target's UUID (enumeration via canvas, logs, or delegation). Fix: when caller presents X-Workspace-ID header with a bearer token: 1. ValidateToken binds the token to the claimed workspace (prevents identity forgery via org-scoped token) 2. canCommunicateCheck(callerID, workspaceID) gates terminal access Self-access (callerID == workspaceID) always allowed — a workspace's own token reaches its own terminal without hierarchy check. Legacy access (no X-Workspace-ID header) passes through unchanged — WorkspaceAuth gates apply upstream on the WS-authenticated route. Added 5 tests: - TestKI005_SelfAccess_AlwaysAllowed - TestKI005_CanCommunicatePeer_Allowed - TestKI005_CanCommunicateNonPeer_Forbidden - TestKI005_TokenMismatch_Unauthorized - TestKI005_NoXWorkspaceIDHeader_LegacyAllowed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai
Bot
force-pushed
the
fix/ki005-terminal-auth
branch
from
April 23, 2026 00:04
e34f801 to
64ee3a2
Compare
Resolve conflicts: - wsauth_middleware_org_id_test.go: take 3-column org_id scan version - orgtoken/tokens_test.go: take 3-column org_id scan version Both our staged files and origin/main's files reflect the F1097 migration-036 org_id single-round-trip refactor; the only difference was the base version (stage 1) still had the pre-migration 2-query pattern. Take the post-migration version from stage 2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Closed
4 tasks
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.
Closing duplicate — fix is in PR #1681.