Skip to content

fix: enforce link relay input permissions - #4

Open
NeerajCodz wants to merge 1 commit into
mainfrom
codex/fix-link-session-mode-enforcement
Open

fix: enforce link relay input permissions#4
NeerajCodz wants to merge 1 commit into
mainfrom
codex/fix-link-session-mode-enforcement

Conversation

@NeerajCodz

Copy link
Copy Markdown
Member

Motivation

  • The link relay path allowed approved sessions (including view_only or approve_only) to send terminal input, bypassing the intended access-mode approval shown to desktop users.
  • Relay messages and desktop relay handling did not validate the approved mode or reliably verify the session_id/terminal mapping before writing to the PTY, creating an authorization bypass.

Description

  • Require that a relay websocket session is approved before registering the client by checking session.status in apis/link/src/relay.ts during relay.auth processing.
  • Persist the approved mode on the relay Client and reject mobile relay.message frames with direction === "input" unless client.mode === "full_control" in apis/link/src/relay.ts.
  • Add LinkManager::session_allows_terminal_input in crates/orphix-core/src/link/mod.rs to verify the inbound session_id matches the stored desktop session, the stored mode is full_control, and the relay mapping points the session to the terminal before accepting input.
  • Apply the desktop-side authorization check in the LinkMessage::RelayMessage branch to deny unauthorized input before any RPC handling or TerminalManager::write occurs.

Testing

  • Ran cargo check -p orphix-core which completed successfully.
  • Ran bunx prettier --check apis/link/src/relay.ts which passed formatting checks after applying changes.
  • Attempted to build the link API with bun --filter @orphix/link-api build but the TypeScript build failed in this environment due to missing/resolvable dev/peer dependencies and type packages (e.g. fastify, ws, jose, @types/node, @orphix/encryption), so a full API build could not be completed here.

Codex Task

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant