Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/guides/remote-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ A machine link connects an OpenCodex **Home** computer to a **Child** computer o

Password SSH is not supported. Links can be started from Home or Child. Windows execution uses PowerShell over the same pinned OpenSSH connection.

On Linux, a recorded OpenCodex install is used only when its executable and optional package entrypoint belong to the SSH account and their permissions and parent directories prevent replacement by another account. If that cannot be checked, Remote Link skips the recorded install. On macOS, recorded installs are always skipped because the remote shell cannot reliably verify their extra access permissions (ACLs). Remote Link continues its existing Desktop, system and PATH discovery on both platforms. A macOS install available only through the runtime record therefore needs to be installed in a discoverable location or added to the SSH account’s PATH. Keep the installation in an account-owned directory instead of a shared writable folder; a successful version response alone does not establish ownership.

## Add a Child from `#remote`

1. Open the dashboard at `#remote` and switch Remote Link on.
Expand Down
2 changes: 2 additions & 0 deletions docs-site/src/content/docs/ko/guides/remote-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ disconnect는 소유한 키만 복구하므로 이후 편집한 모델·훅·신

## 보안

Linux에서는 기록된 OpenCodex 설치의 실행 파일과 패키지 진입 파일이 SSH 계정 소유이며, 파일 권한과 상위 폴더가 다른 계정의 교체를 막는 경우에만 사용합니다. 이를 확인할 수 없으면 해당 기록을 건너뜁니다. macOS에서는 원격 셸이 추가 접근 권한(ACL)을 확실하게 확인할 수 없으므로 기록된 설치를 항상 건너뜁니다. 두 플랫폼 모두 기존 Desktop·시스템·PATH 탐색을 계속합니다. macOS에서 실행 기록으로만 찾을 수 있던 설치는 탐색 가능한 위치에 설치하거나 SSH 계정의 PATH에 추가해야 합니다. 설치 파일은 여러 계정이 수정할 수 있는 공유 폴더 대신 계정 소유 폴더에 두세요. 버전 응답에 성공했다는 사실만으로 소유권이 확인되지는 않습니다.

Child는 링크를 통해 Home 컴퓨터의 프로바이더와 프로바이더 인증 정보를 사용합니다. Home은 Child마다 별도의 링크 키를 만들며, 링크를 제거하면 그 키를 폐기합니다. 확인 전에 호스트 지문을 비교하여 잘못된 컴퓨터나 변경된 호스트 키를 실수로 허용하지 않도록 하세요. Tailscale identity로 발급된 대시보드 세션은 머신 링크를 관리할 수 없습니다. Child에서 키는 OpenCodex 안에만 머뭅니다. Codex나 Claude Code가 Child에서 보내는 인증 정보는 Home으로 전달되지 않으며, Child에서 `127.0.0.1:<port>`에 접근하는 프로그램은 키 없이 Home을 사용합니다. 이는 독립형 설치가 로컬 프로그램에 주는 것과 같은 신뢰 수준입니다. 다른 사이트의 웹 페이지는 거부됩니다.

## CLI 레퍼런스
Expand Down
1 change: 1 addition & 0 deletions scripts/test-layout/layout-clients.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"link-served-runtime-trust.test.ts": "clients",
"claude-endpoint-lifetime.test.ts": "claude-integration",
"omo-responses-loop.test.ts": "clients",
"codex-launcher-endpoint.test.ts": "codex-integration",
Expand Down
69 changes: 69 additions & 0 deletions src/link/remote-runtime-trust.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* POSIX census targets are hints, not execution authority. Walk each path before its
* first version probe, including symlink destinations and directory replacement
* authority. Only root and the SSH account may control traversed components; the
* final regular file must belong to the SSH account and have no foreign write bit.
* Sticky shared directories are safe only with the same ownership checks on their
* children. Keep the verified original spelling so package-prefix discovery and
* interpreter entrypoint semantics remain unchanged.
* macOS recorded hints are skipped: mode bits miss ACL grants and system ls can
* conceal ACL read failures. Its existing known-install discovery still runs.
* These checks do not defend against root or unrestricted same-account mutation.
*/
export const REMOTE_SERVED_PATH_TRUST = `served_path_info() {
stat -c '%u %a' "$1" 2>/dev/null || stat -f '%u %Mp%03Lp' "$1" 2>/dev/null
}
trusted_served_path() (
case "$1" in /*) ;; *) return 1;; esac
# A portable shell cannot prove macOS ACL protection from stat/ls output.
[ "$(uname -s 2>/dev/null)" = Linux ] || return 1
served_uid=$(id -u 2>/dev/null) || return 1
case "$served_uid" in ''|*[!0-9]*) return 1;; esac
original=$1; pending=\${1#/}; resolved=/; steps=0; links=0
# The root is trusted only after the same ownership/mode validation as each directory.
component=/
while :; do
steps=$((steps + 1)); [ "$steps" -le 512 ] || return 1
info=$(served_path_info "$component") || return 1
case "$info" in ''|*[!0-9[:blank:]]*) return 1;; esac
set -- $info
[ "$#" -eq 2 ] || return 1
case "$2" in ''|*[!0-7]*) return 1;; esac
[ "\${#2}" -le 4 ] || return 1
[ "$1" = "$served_uid" ] || [ "$1" = 0 ] || return 1
if [ -L "$component" ]; then
links=$((links + 1)); [ "$links" -le 40 ] || return 1
# Preserve trailing newlines in a link target instead of validating a different path.
target=$(readlink "$component" 2>/dev/null && printf '.') || return 1
target=\${target%.}
case "$target" in *'
') target=\${target%?};; *) return 1;; esac
case "$target" in ''|*'
'*) return 1;; esac
[ -z "$pending" ] || target=$target/$pending
case "$target" in /*) resolved=/; pending=\${target#/};; *) pending=$target;; esac
elif [ -d "$component" ]; then
# Group/world write is allowed only on a trusted sticky directory. Its next
# entry must still be root/account-owned, so another account cannot replace it.
[ $((0$2 & 0022)) -eq 0 ] || [ $((0$2 & 01000)) -ne 0 ] || return 1
resolved=$component
else
[ -z "$pending" ] && [ -f "$component" ] || return 1
[ "$1" = "$served_uid" ] && [ $((0$2 & 0022)) -eq 0 ] || return 1
printf '%s\\n' "$original"
return 0
fi
while :; do
[ -n "$pending" ] || return 1
name=\${pending%%/*}
case "$pending" in */*) pending=\${pending#*/};; *) pending=;; esac
case "$name" in
''|.) continue;;
..) resolved=\${resolved%/*}; [ -n "$resolved" ] || resolved=/; continue;;
esac
component=\${resolved%/}/$name
break
done
done
)
`;
12 changes: 8 additions & 4 deletions src/link/ssh-argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { isRouteClientId, type RouteClientId } from "./route-intent";

import { isAbsolute } from "node:path";
import { ExplicitRouteError, explicitRouteSshOptions, type ExplicitRoute } from "./explicit-route";
import { REMOTE_SERVED_PATH_TRUST } from "./remote-runtime-trust";
import { POWERSHELL_ENCODED_MAX, PowerShellCommandTooLongError, ROUTE_OVERWRITE_MIN_CHILD_VERSION, windowsGatedOcxArgv, windowsOcxArgv, windowsOverwriteSyncArgv } from "./remote-windows";

export type TunnelDirection = "R" | "L";
Expand Down Expand Up @@ -207,7 +208,7 @@ export const REMOTE_PLATFORM_UNSUPPORTED = 125;
* unreadable file or a missing awk fails without writing to stderr.
* Shared by the ocx discovery, pinned sync and runtime inspection scripts.
*/
export const REMOTE_SERVED_RUNTIME = `served_runtime() {
export const REMOTE_SERVED_RUNTIME = `${REMOTE_SERVED_PATH_TRUST}served_runtime() {
# The count below reports wc's status, never dd's: a missing dd or an unreadable file ends here,
# and a dd that fails anyway counts zero bytes, which is refused like an oversized census.
[ -f "$1" ] && [ -r "$1" ] && command -v dd >/dev/null 2>&1 || return 1
Expand Down Expand Up @@ -237,7 +238,7 @@ export const REMOTE_SERVED_RUNTIME = `served_runtime() {

/**
* Tries the served install with \`attempt\`, which must read \`$served_bin\` and honour \`$ocx_entry\`:
* a compiled binary runs alone, and a package pair runs as \`bun <entry>\` only while the entry exists.
* a compiled binary runs alone, and both package paths must pass the same trust gate.
* The unquoted \`OCX_SERVED\` heredoc is safe only because \`served_runtime\` prints paths without
* quotes, backslashes or newlines; relaxing that character class would let a path expand or split.
*/
Expand All @@ -247,9 +248,12 @@ if served=$(served_runtime "\${OPENCODEX_HOME:-$HOME/.opencodex}/serving-runtime
{ IFS= read -r served_bin; IFS= read -r served_entry; } <<OCX_SERVED
$served
OCX_SERVED
if [ -z "$served_entry" ]; then
served_bin=$(trusted_served_path "$served_bin") || served_bin=
if [ -z "$served_bin" ]; then
:
elif [ -z "$served_entry" ]; then
${attempt}
elif [ -f "$served_entry" ]; then
elif served_entry=$(trusted_served_path "$served_entry"); then
ocx_entry=$served_entry
${attempt}
ocx_entry=
Expand Down
Loading
Loading