Monitor vulnerabilities like this one. Sign up free to get alerted when software you use is affected.
9.8

CVE-2026-45695: Kopia: Unauthenticated Access via SSH Command Injection

GHSA-2q4c-3mrw-63c3 CVE-2026-45695 GO-2026-5009
Summary

Kopia's HTTP server allows unauthenticated access when started without a username or password. An attacker can inject malicious commands into the SSH connection, potentially executing arbitrary code as the Kopia process user. To mitigate this risk, start the Kopia server with a username and password, or use a more secure configuration.

What to do
  • Update github.com kopia to version 0.23.0.
  • Update kopia github.com/kopia/kopia to version 0.23.0.
Affected software
Ecosystem VendorProductAffected versions
go github.com kopia <= 0.22.3
Fix: upgrade to 0.23.0
Go kopia github.com/kopia/kopia < 0.23.0
Fix: upgrade to 0.23.0
Original title
Kopia: RCE via SSH ProxyCommand Injection
Original description
## Summary

Kopia's HTTP server, when started with `--without-password `, accepts unauthenticated requests to `/api/v1/repo/exists`. The handler forwards an attacker-supplied storage configuration to `blob.NewStorage`. For SFTP backends with `externalSSH: true`, that path constructs a process command line by splitting `sshArguments` on spaces and passes the result directly to `exec.CommandContext("ssh")`. An `-oProxyCommand=<cmd>` token in `sshArguments` causes OpenSSH to invoke `<cmd>` via `$SHELL -c` before any TCP connection is attempted, giving the requester arbitrary command execution as the Kopia process user.

## Analysis

[`internal/server/server_authz_checks.go` lines 61–73](https://github.com/kopia/kopia/blob/v0.22.3/internal/server/server_authz_checks.go#L61-L73):

when the server is started without `--server-username` or `--server-password`, `getAuthenticator()` returns `nil` and `requireUIUser` unconditionally authorizes the request. Every endpoint registered through `handleUIPossiblyNotConnected` becomes accessible without credentials.

[`repo/blob/sftp/sftp_storage.go` lines 448–468](https://github.com/kopia/kopia/blob/v0.22.3/repo/blob/sftp/sftp_storage.go#L448-L468):

`opt.SSHArguments` is populated from the JSON request body (`storage.config.sshArguments`). The string is split only on the literal ASCII space character, there is no shell style tokenizer, no quote handling, and no allowlist. Whatever tokens the caller supplies are appended to the `ssh` argv.

OpenSSH treats `-oProxyCommand=<value>` as a directive to execute `<value>` via the user's shell (`$SHELL -c <value>`) and pipe the SSH transport over its stdio. The shell invocation happens before SSH attempts a TCP connection, so the command runs even when the target host is unreachable.

## Impact

No user interaction is required. No valid credentials are required. The exploit is a single HTTP request.

## Credits

This vulnerability was discovered and responsibly disclosed by Daniele Berardinelli.

## Mitigation
https://github.com/kopia/kopia/pull/5354 disallows starting of a server without a password which also listens on a non-loopback interface.
ghsa CVSS3.1 9.8
Vulnerability type
CWE-78 OS Command Injection
CWE-306 Missing Authentication for Critical Function
Published: 19 May 2026 · Updated: 21 May 2026 · First seen: 19 May 2026