Skip to content

fix(desktop): harden remote SSH runtime - #705

Open
skb50bd wants to merge 2 commits into
crafter-station:mainfrom
Brotal-LLC:codex/remote-ssh-hardening
Open

fix(desktop): harden remote SSH runtime#705
skb50bd wants to merge 2 commits into
crafter-station:mainfrom
Brotal-LLC:codex/remote-ssh-hardening

Conversation

@skb50bd

@skb50bd skb50bd commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Scope

  • discover and invoke an absolute Windows OpenSSH client without a POSIX supervisor
  • enforce private remote Petdex runtime-directory permissions
  • replace managed executable symlinks instead of following an unrelated target
  • retain config-symlink relocation support and extend remote tunnel regression coverage

Why

Relative Windows SSH lookup could fall back to current-directory search behavior, permissive pre-existing runtime directories were not corrected, and following a managed executable symlink could overwrite an unrelated target.

Impact

Windows desktops can manage POSIX SSH targets through the installed OpenSSH client. Existing POSIX desktop and remote behavior remains compatible. Managed remote state is private and symlink replacement cannot escape its intended path.

Size

3 files changed, 182 insertions, 22 deletions.

Validation

  • git diff --check
  • zig fmt --check src/remote_ssh.zig
  • pinned Native SDK native test .: 213/213 passed
  • passing GitHub Actions app and lockfile checks
  • passing GitHub Actions Native SDK builds and tests on macOS, Linux, and Windows
  • passing Linux real-SSH remote-agent writeback scenario

Merge readiness

  • One focused commit directly on crafter-station/petdex:main at 0243af6.
  • The local macOS environment limitation does not leave the tunnel unverified: the passing Linux CI job exercises the real SSH writeback path end to end.
  • This remains a draft only because the Vercel preview needs Crafter Station team authorization. That is an external administrative gate; all repository checks passed.

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

@skb50bd is attempting to deploy a commit to the Crafter Station Team on Vercel.

A member of the Team first needs to authorize it.

@skb50bd

skb50bd commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@Railly, when you have a moment, could you please review this independent remote-SSH hardening slice? The macOS, Linux, and Windows checks passed, including Linux real-SSH writeback; the remaining Vercel status is authorization-only. Thank you.

@Railly

Railly commented Aug 20, 2026

Copy link
Copy Markdown
Member

Reviewed the Zig. It holds up. zig test src/remote_ssh.zig passes 86/86 on this branch against 84 on base.

Checked the parts that looked risky and found them sound:

  • detect() returning the "ssh.exe" sentinel on Windows is safe. The only two consumers, main.zig:1761 and remote_ssh.zig:160, compare against null and discard the value, so no spawn path receives it.
  • Scratch has no dangling slice. All six builders share one call site at main.zig:1717, in the same frame as the spawn at 1741.
  • writeArgv with resolve_link disabled keeps $target well defined, and config relocation still works because non-executables keep the readlink branch. Reverting that line turns test 9 red, so the coverage is real.
  • windowsSshCandidate handles C:\, UNC, quoted, trailing-slash and relative entries. The > 3 guard is what stops C:\ from degrading to C:.

Two notes.

The Windows comment on installTunnelSupervisor reaches the right conclusion for the wrong reason. owner=$PPID is the remote sshd session, not the desktop, so owner_alive does not fire when ssh.exe dies. What actually closes the orphan is healthy() failing its probe against the in-process hook server: 3 misses at 2s each, so exit 75 in about 6 seconds. Worth correcting the comment so the next reader does not rely on the stated mechanism.

tunnelArgv is the only runtime-dir builder without chmod 700 (remote_ssh.zig:294). Not a defect today, since the state machine forces quiesce before tunnel and quiesce must exit 0. It is safe by call ordering rather than on its own, so it is worth hardening if that sequence changes.

I could not run the Windows binary or the docker SSH test here, so the orphan finding rests on mechanism reproduction with POSIX stand-ins plus reading the SDK teardown path, not an end-to-end Windows run.

@skb50bd

skb50bd commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@Railly, thanks again for the careful review. I pushed 6d37faf addressing both notes: the Windows orphan-cleanup comment now describes the health-probe mechanism accurately, and the tunnel runtime directory is hardened with chmod 700 plus regression coverage. The Zig suite passes 86/86. When you have a chance, would you mind taking another look?

@skb50bd
skb50bd force-pushed the codex/remote-ssh-hardening branch from 6d37faf to 1721e79 Compare August 30, 2026 05:44
@skb50bd
skb50bd marked this pull request as ready for review September 1, 2026 05:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T05:11:00.010645Z 1721e79 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@skb50bd

skb50bd commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@Railly this one got green signal from codex review. can we merge this?

@skb50bd skb50bd closed this Sep 1, 2026
@skb50bd skb50bd reopened this Sep 1, 2026
@skb50bd

skb50bd commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

sorry, accidentally closed it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants