Repository navigation
fix(link): refuse an identity file in a directory others can write, and correct the missing-key docs - #8718
Merged
Conversation
The request-time check looked at the key file alone. Another user who can write to its directory could rename a file of their own into the key's name after the check, and ssh would then offer it. The directory that holds the key (after symlinks in its path resolve) must now be owned by this user or root and not writable by group or others; otherwise the request answers 400 invalid_identity_file with hint identity_file_directory before any SSH. A world-writable sticky directory such as /tmp is refused too.
No test covered confirm-host's own key check: a key removed between probe and confirm-host now has a case asserting 400 invalid_identity_file (identity_file_missing), no new SSH and no confirmed host.
…key, and the tombstone a forced revoke leaves
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Contributor
|
✅ Deterministic PR hygiene checks passed. |
…t be safe Checking only the directory that holds the key left a gap: with /shared writable by another user and /shared/keys a private directory of this user, the other user could rename keys away and put a directory or symlink with another key in its place after the check. The path is now resolved entry by entry, as the kernel does, and every directory it passes through (each one on the way, each directory holding a symlink and each symlink's target) must be owned by this user or root and not writable by group or others unless it is sticky, as /tmp is. The key's own directory stays strict: not writable by group or others, sticky or not. The docs also say the check is a metadata check at request time that cannot bind ssh to the file it checked.
…he new link stays alias_linked lasts while the new link for the alias exists. Once that link is revoked and the old key is back, ocx link recover --link-id <id> can clean the machine and settle the tombstone, so --forget is the way out only for someone keeping the new link.
…n the key's path must be this user's or root's - A refusal now tells the operator what to fix without naming the path: identity_file_directory for the key's own directory, identity_file_ancestor for a directory or symlink above it, each with fixed text (IDENTITY_FILE_GUIDANCE) that the Home answers as its message and that ocx link probe|add prints with the code and hint (the CLI printed only "Management request failed (400)" before). The rule stays: a group-writable directory is refused even when the group is the user's own, as sshd's StrictModes does, so a folder created under umask 002 needs chmod g-w; the guides (en, es), capability text, skill reference and structure state it in full with the owner rule. New test: a 0775 ancestor owned by this user. - A symlink on the path must be owned by this user or root: another user's link in a sticky directory can be repointed. The walk takes lstat as a parameter so a test can give a link another owner. - After an absolute symlink target the walk also reads "/" again, so the final directory's metadata is never the link's containing directory. - The keyed server cases skip on Windows, where every identity file is refused before these checks; a Windows-only case asserts that refusal.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 13, 2026
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
Three review follow-ups to #8714 (link.route/2,
--ssh-identity-file)./tmpdoes. That covers each directory on the way, each directory holding a symlink, and each symlink's target. The key's own directory is stricter: group and others cannot write it, sticky or not. Every symlink on the path must also be owned by this user or root, because another user's link can be repointed even in a sticky directory. A failure answers400 invalid_identity_filebefore any SSH, with hintidentity_file_directoryfor the key's own directory oridentity_file_ancestorfor a directory or symlink above it. The message is fixed text per hint (IDENTITY_FILE_GUIDANCE) that says what to fix and names no part of the path;ocx link probe|addprints the same text with the code and hint (before, it printed only "Management request failed (400)"). The rule stays: a group-writable directory is refused even when the group is the user's own, as sshd's StrictModes does. So a home or state folder created under umask 002 (per-user groups on Ubuntu or Fedora) is refused untilchmod g-w, and OpenCodex does not look up group membership. GOAT will make its own directories meet this rule before passing a key. The guides, capability text, skill reference and structure state the rule in full, including the owner rule. I chose refusal over a docs-only rule because the usual places for a key pass:~/.ssh(0700), any directory the user owns that others can only read (0755), and a private directory under/tmp. A key placed directly in/tmp, or in a shared group-writable directory, is refused, and the guides say to keep the key in a private directory like~/.ssh. This is a metadata check at request time. ssh opens the path later, so a change this user or root makes in between is not caught, and nothing binds ssh to the file that was checked; structure/remote-link.md says so. - confirm-host's own key check has a test. A key removed between probe and confirm-host answers400 invalid_identity_file(identity_file_missing) with no new SSH and no confirmed host. This is coverage: the check already existed and the test passed when added.502 remote_recover_failedwith hintssh_failed(src/link/link-recover.ts), and structure/remote-link.md and both guides now say so. The missing-key remedy now adds that a forced revoke of a disposable Child leaves a tombstone that keeps this route and its missing key. Once the alias is enrolled again, recover answersalias_linkedfor it, and while that new link exists only a person can clear it, withocx link recover --forget --link-id <id> --yes; after the new link is revoked and the old key is back,ocx link recover --link-id <id>can clean the machine and settle it. The guides (en and es, identical code spans), structure and theocx link probe|addcapability text also describe the directory rule, and the skill reference is regenerated.Note, no change: a Windows Home still declares
link.route/2inocx capabilities --contracts(the flag and body key exist on every platform) and refuses the identity file at probe withidentity_file_unsupported_platform. A caller that seeslink.route/2on a Windows Home therefore gets a 400 before any SSH, never a link that silently ignores the key.Commits:
Platforms and temp directories: the accepted cases build their keys under
mkdtempSync(tmpdir()), so they pass only where the runner's temp directory chain passes the walk. That holds for Linux/tmp(root 1777, sticky) and for macOS/var/folders/…(checked on this Mac). CI'stest changedat a5f859b ran both identity-file test files green on the self-hosted Linux runnerlidge-ocx-03. The Windows shards of alane=allrun execute the whole suite. A Windows Home refuses every identity file before these checks, so the keyed server cases (this PR's and #8714's) now skip on Windows, a Windows-only case asserts that refusal, and the symlink-owner unit test skips there too. Nolane=allrun has included #8714 yet.Verification
lstatas a parameter to give the link another owner. Thestatreset after an absolute symlink target has no test of its own.bun teston the explicit-route suites (server, clients, paths, no-ssh-config, CLI, route edit), link-recover, cli-link-recover, skill-ocx and the Spanish docs test (temporaryOPENCODEX_HOME): plus cli-link-enrollment: 356 pass, 1 skip (the Windows-only case), 0 fail. The Spanish docs test passes 30/30.bun run typecheck,structure:check,skill:surface:check,privacy:scan: pass.NOT RUN: full
bun run test; Windows; a real enrollment.Checklist