Skip to content

fix(ssh): preserve literal backslashes in quoted SSH config paths - #50411

Merged
nwparker merged 1 commit into
stablyai:mainfrom
Afloat16:fix/ssh-quoted-backslashes
Nov 27, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
Afloat16:fix/ssh-quoted-backslashes

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Orca read your SSH config file, it threw away backslashes inside quoted file paths. Windows paths use backslashes, so "C:\Users\Me\.ssh\key" turned into C:UsersMe.sshkey, and Orca looked for a key file that doesn't exist. Orca now reads backslashes the same way OpenSSH does, so the path stays correct.

What Changed

  • Before: splitOpenSshArguments in src/main/ssh/config/ssh-config-parser.ts dropped every backslash inside double quotes and kept the character after it. IdentityFile "C:\Users\Test User\.ssh\id_ed25519" was imported as C:UsersTest User.sshid_ed25519, and IdentityAgent "/tmp/agent\socket" as /tmp/agentsocket. Outside quotes, \ and \\ were not handled at all, so C:\Users\My\ Keys\\id_ed25519 was cut off at the space.
  • After: The splitter follows OpenSSH argv_split (misc.c). It consumes a backslash only before ", ' or \, or before a space outside quotes, both inside and outside quotes. Every other backslash stays literal, including a trailing one.
  • A new regression test in src/main/ssh/config/ssh-config-loader.test.ts covers quoted Windows paths, escaped quotes and backslashes, and an unquoted path with \ and \\. The expected values were checked against native ssh -G.

Why

These parsed values are saved on imported SSH targets (SshConnectionStore sync), shown in the host picker, and used for fallback authentication when ssh -G cannot resolve a value. Matching OpenSSH's own escape rule fixes the root cause in the one tokenizer the importer uses. It doesn't add a separate Windows-path special case.

Linked Issue

Fixes #50410

Visual Proof

N/A. This is a config-parsing change with no layout or interaction change. A differential run against native ssh -G stands in as before/after evidence (see Testing).

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • Reproduced on origin/main: the new loader test fails with C:UsersTest User.sshid_ed25519 and /tmp/agentsocket. With this change, pnpm test src/main/ssh/config/ passes 8/8.

  • Differential check on macOS against OpenSSH_10.5p1 ssh -G -F <cfg> on 18 IdentityFile values. On main, 11 differ from ssh. With this change, 16 match, ssh rejects one as invalid, and one (/k/x\#y) still differs. That last one is a separate # comment-handling gap that main also has, so it is not a regression.

  • Targeted oxlint, oxfmt, the anti-slop, code-quality and ast-grep gates, and the changed-code quality gate are all clean.

  • Platforms: macOS. The change is a pure string function, so it behaves the same on Linux and Windows.

Performance

None, because this only runs on cold main-process paths (SSH config import, host picker, route snapshot). There is no new I/O or subprocess work. Micro-benchmark, old vs new:

  • Typical values: about 1.1 us vs 0.94 us per set of 7 values.
  • 200k-character adversarial lines: 3.0 ms vs 0.61 ms, 3.8 ms vs 0.64 ms, 1.1 ms vs 0.54 ms, 3.2 ms vs 2.5 ms.

Risk

Level: Low

  • Unquoted \\, \", \' and \ now collapse the way OpenSSH collapses them. For example, \\server becomes \server.
  • Targets that were already imported with mangled values are rewritten once on the next reconcile. The rewrite is idempotent, but it forgets one remembered sign-in for each affected target.
  • Orca never writes SSH config files, so nothing is written back.
  • To back it out, a plain revert restores the old behavior.

Review

The fix was compared with OpenSSH argv_split and verified against native ssh -G. These gaps exist on main and are out of scope here:

  • Single quotes are not treated as quote characters.
  • # stops parsing anywhere outside quotes, but OpenSSH treats it as a comment only at the start of a token.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: no new endpoints, credentials or permissions. Cross-platform: pure string parsing. SSH/remote: only affects how the local ~/.ssh/config is imported. Backwards compatibility: see Risk.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Original fix by @Afloat16 in #50411

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

splitOpenSshArguments now preserves backslashes except when they precede quotes, another backslash, or an unquoted space. A new loadUserSshConfig test checks quoted and unquoted identity paths and agent paths, including Windows-style paths and escaped characters.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 959bf

This fixes quoted SSH identity paths that contain Windows-style backslashes, and the parsing change is small and localized. No merge-blocking risk was found; hosted CI results are still pending.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed [#50410] requires that quoted SSH identity and agent paths keep literal backslashes, such as C:\Users\Test User\.ssh. At head, splitOpenSshArguments in src/main/ssh/config/ssh-config-parser.ts consume…
Out of Scope Changes check Passed The whole-PR diff touches splitOpenSshArguments in src/main/ssh/config/ssh-config-parser.ts and adds a loadUserSshConfig regression test. Both changes support the [#50410] requirement. The parser rewr…
Title check Passed The title names the main change: SSH config parsing now keeps literal backslashes in quoted paths. It follows the fix(ssh) convention and matches the parser and loader test changes in the summary. The…
Description check Passed The description covers every required template section: ELI5, What Changed, Why, Linked Issue (Fixes #50410), Visual Proof (N/A with reason), Testing, Performance, Risk with level and revert plan, Rev…
Full details: Linked Issues check

Explanation

[#50410] requires that quoted SSH identity and agent paths keep literal backslashes, such as C:\Users\Test User.ssh. At head, splitOpenSshArguments in src/main/ssh/config/ssh-config-parser.ts consumes a backslash only when the next character is a double quote, single quote, or backslash. It also consumes a backslash before a space when outside quotes. Any other backslash stays a literal character. For a quoted Windows-style path, separators are kept, which matches the requirement. The whole-PR diff against the merge base shows this parser change and a loader regression test in src/main/ssh/config/ssh-config-loader.test.ts. Since the previous reviewed head, the change added the unquoted-space escape branch. The PR author reports 8 passing loader tests and a native ssh -G comparison on Linux. I did not run the tests. The test result rests on the author's report, and the code evidence supports the fix.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff touches splitOpenSshArguments in src/main/ssh/config/ssh-config-parser.ts and adds a loadUserSshConfig regression test. Both changes support the [#50410] requirement. The parser rewrite replaces the escaped flag with index-based iteration, and the new branch applies only to backslashes. The new unquoted-space branch changes unquoted token handling, which the PR description states is retained. This branch relates to the issue's concern with paths containing spaces and is covered by the added test, so it is not an unrelated change. I did not inspect the test file hunks in detail, and the incremental diff from the previous reviewed head could not be read. The conclusion rests on the parser diff and the PR summary. No parallel implementation, extra process, or file read appears in the evidence.

Full details: Title check

Explanation

The title names the main change: SSH config parsing now keeps literal backslashes in quoted paths. It follows the fix(ssh) convention and matches the parser and loader test changes in the summary. The title is concise and specific.

Full details: Description check

Explanation

The description covers every required template section: ELI5, What Changed, Why, Linked Issue (Fixes #50410), Visual Proof (N/A with reason), Testing, Performance, Risk with level and revert plan, Review, Agent skill boundary, Notes, and Checklist. It explains the before and after behavior and the mechanism, and it gives a clear risk assessment. The AI Disclosure section is left blank, which the template allows for internal contributors. The last checklist item is unchecked, and the Risk section has no rollback caveat issue. Those gaps are minor.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: af39bb48-5d8b-496f-9cad-81f33dcdd500
Commits

Reviewing files that changed from the base of the PR and between a1a5691 and 959bfb0.

Files selected for processing: 2

  • src/main/ssh/config/ssh-config-loader.test.ts
  • src/main/ssh/config/ssh-config-parser.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

splitOpenSshArguments dropped every backslash inside double quotes, so
IdentityFile "C:\Users\Test User\.ssh\id_ed25519" was imported as
C:UsersTest User.sshid_ed25519. Follow OpenSSH argv_split instead: a
backslash is consumed only before ", ' or \, or before a space outside
quotes. Every other backslash stays literal.

Fixes stablyai#50410

Co-authored-by: Neil <[email protected]>
@nwparker
nwparker force-pushed the fix/ssh-quoted-backslashes branch from a1a5691 to 959bfb0 Compare November 27, 2026 05:12
@nwparker nwparker changed the title fix(ssh): preserve literal backslashes in quoted identity paths fix(ssh): preserve literal backslashes in quoted SSH config paths Nov 27, 2026
@nwparker
nwparker merged commit 94bc956 into stablyai:main Nov 27, 2026
55 of 56 checks passed
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.

[Bug]: preserve literal backslashes in quoted identity paths

2 participants