Skip to content

ProxyCommand fails due to unescaped --url flag #479

Closed
@slushie

Description

@slushie

We received a report today of a user who is unable to connect to their Coder workspace due to their zsh shell failing to parse the ProxyCommand command line.

This issue appears to stem from the modifySSHConfig method calling escape() on the URL. The escape method seems to only surround an argument with quotes when it contains whitespace, but there is no support for other quoting other metacharacters that can cause shell parsing issues.

Here are the relevant logs from the user's JetBrains plugin:

2024-09-13 11:24:45,041 [ 858948]   INFO - CoderRemoteConnectionHandle - Connecting to remote worker on coder-jetbrains--someuser-python-dev.main--coder.prod.somecorp.net... (attempt 6)
2024-09-13 11:24:45,075 [ 858982]   INFO - net.schmizz.sshj.transport.random.JCERandom - Creating new SecureRandom.
2024-09-13 11:24:45,080 [ 858987]   INFO - #c.i.s.ProxyCommand - ProxyCommand for coder-jetbrains--someuser-python-dev.main--coder.prod.somecorp.net--bg:22: "/Users/someuser/Library/Application Support/coder-gateway/coder.prod.somecorp.net/coder-darwin-amd64" --global-config "/Users/someuser/Library/Application Support/coder-gateway/coder.prod.somecorp.net/config" --url https://coder.prod.somecorp.net/?workspace=someuser-python-dev&token=unused&agent=main ssh --stdio --disable-autostart --usage-app=disable someuser-python-dev.main
2024-09-13 11:24:45,087 [ 858994]   INFO - #c.i.s.ProxyCommand - Started ProxyCommand for coder-jetbrains--someuser-python-dev.main--coder.prod.somecorp.net--bg:22: Process[pid=67537, exitValue="not exited"]
2024-09-13 11:24:45,087 [ 858994]   INFO - #c.i.s.i.s.sshj - Client identity string: SSH-2.0-IntelliJ__Gateway_GW-242.20224.368__SSHJ_0.38.1_SNAPSHOT
2024-09-13 11:24:45,095 [ 859002]   WARN - #c.i.s.i.s.sshj - Received end of connection, but no identification received.
2024-09-13 11:24:45,095 [ 859002]   INFO - #c.i.s.ProxyCommand - End of Process[pid=67537, exitValue="not exited"] stderr:
zsh:1: parse error near `&'
2024-09-13 11:24:45,096 [ 859003]   WARN - #c.i.s.ProxyCommand - Process[pid=67537, exitValue=1] exited with code 1
2024-09-13 11:24:45,096 [ 859003] SEVERE - CoderRemoteConnectionHandle - Failed to connect (attempt 6; will retry in 153301 ms)
java.lang.Throwable: Failed to connect (attempt 6; will retry in 153301 ms)
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)

Note the zsh:1: parse error near &'causingexitValue=1`.

The command line is

ProxyCommand for coder-jetbrains--someuser-python-dev.main--coder.prod.somecorp.net--bg:22: "/Users/someuser/Library/Application Support/coder-gateway/coder.prod.somecorp.net/coder-darwin-amd64" --global-config "/Users/someuser/Library/Application Support/coder-gateway/coder.prod.somecorp.net/config" --url https://coder.prod.somecorp.net/?workspace=someuser-python-dev&token=unused&agent=main ssh --stdio --disable-autostart --usage-app=disable someuser-python-dev.main

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions