Kopia: RCE via SSH ProxyCommand Injection
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= token in sshArguments causes OpenSSH to invoke ` 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:
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:
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= as a directive to execute ` via the user's shell ($SHELL -c `) 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.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Kopia HTTP server without password allows unauthenticated SSH ProxyCommand injection leading to remote code execution.
Vulnerability
The Kopia HTTP server, when started with --without-password, accepts unauthenticated requests to the /api/v1/repo/exists endpoint. The handler passes an attacker-supplied storage configuration to blob.NewStorage. For SFTP backends with externalSSH: true, the code splits sshArguments from the request body on spaces and passes the resulting tokens directly to exec.CommandContext("ssh"). This allows injection of an -oProxyCommand= token, which causes OpenSSH to execute ` via $SHELL -c` before any TCP connection is attempted. Affected versions: prior to 0.23.0. [1] [4]
Exploitation
An attacker with network access to the Kopia server can send a single HTTP POST request to /api/v1/repo/exists with a JSON body containing a storage configuration of type sftp with externalSSH: true and sshArguments set to include -oProxyCommand=. No authentication or user interaction is required. [4]
Impact
Successful exploitation allows arbitrary command execution as the Kopia process user. This can lead to full compromise of the server, including data disclosure, modification, or denial of service. [4]
Mitigation
The vulnerability is fixed in Kopia version 0.23.0, which restricts the --insecure and --without-password combination to loopback-only binds. Users should upgrade to 0.23.0 or later. As a workaround, do not start the server with --without-password unless it is bound to loopback, and restrict network access to the server. [1] [4]
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
2Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
3News mentions
0No linked articles in our index yet.