Skip to content

Quote bridge commands so a fish login shell cannot reopen them - #14

Merged
dhivadhiva merged 4 commits into
mainfrom
fix/bridge-fish-quoting
Nov 16, 2026
Merged

dhivadhiva merged 4 commits into
mainfrom
fix/bridge-fish-quoting

Conversation

@dhivadhiva

Copy link
Copy Markdown
Contributor

The bug

A security fix for the AI Bridge's read tools in 1.6.0.

The server's sshd hands the whole command line to the account's login
shell. The bridge embedded values in POSIX single quotes, where nothing
is special. fish reads a backslash inside single quotes as an escape,
so a value ending in a backslash escaped its closing quote, and the
rest of the line could be re-read by the shell.

Paths and file-name patterns come from the assistant. On a host whose
login shell is fish, a read-only tool could therefore be made to run
text the app did not intend. Hosts with sh, bash or zsh as the login
shell are not affected.

The fix

  • BridgeCommands.loginShellQuote: no backslash is ever left inside
    single quotes. For a value without a backslash the output is identical
    to the old quoting.
  • Only one value reaches the login shell, the command template inside
    supervised, and it now uses that quoting. Values inside a template
    are read by /bin/sh only and keep POSIX quoting, which is correct
    there. A comment says which shell reads which layer.

Tested

  • Real sh and bash, each read tool's command with hostile values
    (trailing backslash, quote runs, $(), backticks, ;, a leading
    -): the inner command receives exactly the value and a marker file
    the value tries to create never appears.
  • The real-sshd test (SSGO_SSHD=1): 8 passed.
  • Local CI on a clean checkout: analysis, the full test suite, the Linux
    release build and the launcher build.

Not tested

fish itself. It is not installed where this was written. The quoting is
checked against a model of fish's single-quote rules, and
test/bridge_shell_quoting_test.dart has a test that runs the same
check through real fish when it is installed. Worth running once on a
machine that has fish.

Related, not changed here

FleetExecService.wrap (the user's own "run a command on many servers")
quotes the same way. There the command is the user's, so under a fish
login shell it is a correctness bug rather than a security one.

Before tagging 1.6.0

1.6.0 is merged but not tagged. If this lands first, the line in
docs/changes/bridge-shell-quoting.md belongs in the changelog's 1.6.0
Security section.

The server's sshd hands the whole command line to the account's login
shell. Values were embedded in POSIX single quotes, where nothing is
special. fish reads a backslash inside single quotes as an escape, so a
value ending in a backslash escaped its closing quote and the rest of
the line could be re-read by the shell. Paths and file-name patterns
come from the assistant, so on a host whose login shell is fish a
read-only tool could be made to run text the app did not intend.

The outer command line is now quoted so that no backslash is ever left
inside single quotes. Text read by /bin/sh inside the wrapper keeps
POSIX quoting, which is correct there. A comment says which shell reads
which layer.

Tested against real sh and bash with hostile values. fish is not
installed where this was written, so its rules are checked against a
model; a test runs the same check through real fish when it is present.
dhivadhiva and others added 3 commits November 16, 2026 20:05
The test ran the supervised wrapper with its input already at
end-of-file. That is the wrapper's stop signal, so on a slow runner the
command was ended before it printed and the test failed. Run it as the
app does, with the input held open until the command has finished.
The backup fix, the fish quoting fix and the departed-peer fix all ship
in 1.6.0, so their notes move from docs/changes into the 1.6.0 section
of CHANGELOG.md. The release date is 16 November 2026 in the changelog,
the Debian changelog, the Flatpak metadata and the privacy policy.
@dhivadhiva
dhivadhiva merged commit 6cc5695 into main Nov 16, 2026
14 of 16 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.

1 participant