Summary
Coder's config-ssh command previously wrote server-controlled values directly into a user's ~/.ssh/config file without sanitizing newlines or restricting allowed directives.
Under a malicious or compromised Coder deployment, this could allow arbitrary SSH configuration injection, enabling traffic redirection, credential theft, or command execution when users connect to remote development environments.
Affected context
The vulnerability appears in workflows where developers use the Coder CLI to configure SSH access to remote development environments.
Specifically, coder config-ssh consumes server-supplied HostnameSuffix and SSHConfigOptions values and writes them to ~/.ssh/config.
Risk exists when these values can be influenced by a malicious or compromised Coder server, a man-in-the-middle attacker on the control channel, or an administrator with access to the relevant settings, and when users routinely apply CLI-generated SSH configuration without manual review.
Exploit preconditions
- Attack surface: Developer workstations that run
coder config-sshand maintain a local~/.ssh/configfile. - Required access: Ability to control or tamper with
HostnameSuffixandSSHConfigOptionson the Coder server (malicious deployment, compromised server, misused admin privileges, or successful MITM on configuration delivery). - Trigger point: Execution of
coder config-sshby a user, which ingests server-provided values and writes them into the local SSH configuration file. - Why exploitation is possible: The CLI trusted server-supplied strings as safe configuration, allowing embedded newlines and unrestricted directives that break out of expected entries and inject arbitrary SSH options into
~/.ssh/config.
Why this happens
The core issue is unsanitized injection of server-controlled data into a client-side configuration file.
Coder's CLI treated HostnameSuffix and SSHConfigOptions as benign text and directly interpolated them into ~/.ssh/config without validating characters or restricting which SSH directives could be emitted.
This pattern aligns with CWE-74: Injection in Configuration File, where untrusted input alters configuration semantics, and is closely related to CWE-78: OS Command Injection because SSH configuration can be used to pivot into command execution or credential hijacking.
By allowing newline characters and control sequences, the tool enabled attackers to escape the intended configuration block and define arbitrary host entries, ProxyCommand, Match, and similar directives influencing subsequent SSH connections.
Potential impact
- Attackers may inject hostile SSH directives (e.g.,
ProxyCommand,ProxyJump) to transparently route connections through attacker-controlled hosts. - SSH traffic could be redirected or proxied, enabling session observation, manipulation, or credential theft.
- Malicious configuration can cause users to execute unintended commands when initiating SSH sessions, potentially leading to remote code execution on development hosts.
- Sensitive keys or agent-based authentication could be exposed by altering
IdentityFile,ForwardAgent, or related options. - Users may lose trust in local SSH behavior, as host mappings and security-related options are silently modified by server-provided configuration.
General mitigation guidance
Mitigation generally focuses on reducing trust in server-supplied configuration data and constraining what can be written into client configuration files.
Defensive patterns include validating configuration parameters against strict, allow-listed character sets and known-safe directives; rejecting control characters such as newlines and tabs that enable structural injection; and segregating auto-generated SSH configuration into separate, clearly labeled include files rather than directly editing ~/.ssh/config.
Organizations can also adopt least-privilege principles for administrative access to configuration settings, require human review of CLI-generated SSH configuration (for example via a dry-run mode or diff tools), and standardize secure defaults that avoid powerful options like ProxyCommand unless explicitly approved.
How teams detect issues like this
Detection typically combines configuration file inspection with behavioral monitoring.
Teams can periodically scan ~/.ssh/config and included files for unexpected or risky directives (e.g., ProxyCommand, ProxyJump, overly broad Match blocks, or suspicious host patterns) originating from automated tools.
Static checks in local security agents or developer environment hardening scripts can flag multi-line or unvalidated content generated by CLIs that interact with configuration files.
Code review of CLI tooling should look for direct concatenation of server-supplied strings into configuration outputs, lack of character-set validation, and absence of directive allow-listing.
Organizations may also use policy enforcement in CI/CD or endpoint management solutions to detect and alert on changes to SSH configuration that deviate from established baselines.

