GHSA-2Q4C-3MRW-63C3

Vulnerability from github – Published: 2026-05-19 19:18 – Updated: 2026-05-19 19:18
VLAI
Summary
Kopia: RCE via SSH ProxyCommand Injection
Details

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:

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=<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.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 0.22.3"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/kopia/kopia"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.23.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-45695"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-306",
      "CWE-78"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-05-19T19:18:32Z",
    "nvd_published_at": null,
    "severity": "CRITICAL"
  },
  "details": "## Summary\n\nKopia\u0027s 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=\u003ccmd\u003e` token in `sshArguments` causes OpenSSH to invoke `\u003ccmd\u003e` via `$SHELL -c` before any TCP connection is attempted, giving the requester arbitrary command execution as the Kopia process user.\n\n## Analysis\n\n[`internal/server/server_authz_checks.go` lines 61\u201373](https://github.com/kopia/kopia/blob/v0.22.3/internal/server/server_authz_checks.go#L61-L73):\n\nwhen 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.\n\n[`repo/blob/sftp/sftp_storage.go` lines 448\u2013468](https://github.com/kopia/kopia/blob/v0.22.3/repo/blob/sftp/sftp_storage.go#L448-L468):\n\n`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. \n\nOpenSSH treats `-oProxyCommand=\u003cvalue\u003e` as a directive to execute `\u003cvalue\u003e` via the user\u0027s shell (`$SHELL -c \u003cvalue\u003e`) 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.\n\n## Impact\n\nNo user interaction is required. No valid credentials are required. The exploit is a single HTTP request.\n\n## Credits \n\nThis vulnerability was discovered and responsibly disclosed by Daniele Berardinelli.\n\n## Mitigation\nhttps://github.com/kopia/kopia/pull/5354 disallows starting of a server without a password which also listens on a non-loopback interface.",
  "id": "GHSA-2q4c-3mrw-63c3",
  "modified": "2026-05-19T19:18:32Z",
  "published": "2026-05-19T19:18:32Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/kopia/kopia/security/advisories/GHSA-2q4c-3mrw-63c3"
    },
    {
      "type": "WEB",
      "url": "https://github.com/kopia/kopia/pull/5354"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/kopia/kopia"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Kopia: RCE via SSH ProxyCommand Injection"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…