Skip to content

fix: reject glob characters in the SSH hostname prefix - #32570

Merged
fioan89 merged 1 commit into
mainfrom
fix-ssh-hostname-prefix-glob
Nov 23, 2026
Merged

fioan89 merged 1 commit into
mainfrom
fix-ssh-hostname-prefix-glob

Conversation

@fioan89

@fioan89 fioan89 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Currently, ValidateWorkspaceHostnamePrefix rejects only whitespace and control characters in the deployment SSH hostname prefix. The coder config-ssh command writes this prefix as "Host ". When an administrator sets CODER_SSH_HOSTNAME_PREFIX to "", the user's SSH config gets a "Host **" block. This block matches every host, so the Coder SSH options, such as StrictHostKeyChecking=no, UserKnownHostsFile=/dev/null, and the Coder ProxyCommand, apply to all SSH connections on the user's machine, not only to Coder workspaces.

ValidateWorkspaceHostnamePrefix now also rejects "*" and "?", the same as ValidateWorkspaceHostnameSuffix. The glob check runs after the whitespace and control character check, so an injection payload still reports the control character error.

Both callers of SSHConfigResponse.Validate apply the new check. The server now refuses to start when the prefix contains a glob character. The coder config-ssh command now refuses a server response with such a prefix and leaves the SSH config file unchanged. New tests cover the validator, the server startup check, and both client paths.

Currently, ValidateWorkspaceHostnamePrefix rejects only whitespace and
control characters in the deployment SSH hostname prefix. The coder
config-ssh command writes this prefix as "Host <prefix>*". When an
administrator sets CODER_SSH_HOSTNAME_PREFIX to "*", the user's SSH
config gets a "Host **" block. This block matches every host, so the
Coder SSH options, such as StrictHostKeyChecking=no,
UserKnownHostsFile=/dev/null, and the Coder ProxyCommand, apply to all
SSH connections on the user's machine, not only to Coder workspaces.

ValidateWorkspaceHostnamePrefix now also rejects "*" and "?", the same
as ValidateWorkspaceHostnameSuffix. The glob check runs after the
whitespace and control character check, so an injection payload still
reports the control character error.

Both callers of SSHConfigResponse.Validate apply the new check. The
server now refuses to start when the prefix contains a glob character.
The coder config-ssh command now refuses a server response with such a
prefix and leaves the SSH config file unchanged. New tests cover the
validator, the server startup check, and both client paths.
@linear-code

linear-code Bot commented Nov 20, 2026

Copy link
Copy Markdown

CLI-70

@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Nov 20, 2026
@fioan89
fioan89 merged commit f45d527 into main Nov 23, 2026
51 checks passed
@fioan89
fioan89 deleted the fix-ssh-hostname-prefix-glob branch November 23, 2026 19:49
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 23, 2026

This branch had an error being deployed

1 failed and 1 inactive deployments
main — dc9f9bae Deployed Nov 23, 2026 by fioan89 via Backport to release/2.29 #7288
docs-preview — dc9f9bae Deployed Nov 23, 2026 by fioan89 via cleanup #362
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants