Skip to main content
Menu
Advisories

LXD exposes migration websocket secrets to project event listeners, allowing migration hijack

GHSA-W75W-3WF7-G5PGPublished Updated GitHub

Description

Reported from github.com/lxc/incus/security/advisories/GHSA-h2j8-4crh-vhfc

Instance, volume and snapshot migration operations embed their per-connection websocket secrets in the operation metadata. That metadata is broadcast to every event listener holding view access on the operation's project, and is also returned by operation queries. Unlike exec and console, the migration websocket authorizes a connection on the secret alone, with no binding to the operation's requestor. A client with event-view access to the project can therefore read the secret and connect to an in-flight migration's data channels before the legitimate peer, hijacking the transfer of an instance it may not otherwise read.

Details

The migration source/sink renders its per-connection secrets into the operation metadata:

cmd/incusd/migrate.go:181   migrationSourceWs.Metadata() -> {control: <secret>, fs: <secret>}

That metadata is broadcast on the operation event stream to every listener with can_view_events on the project, while the operation is still Pending:

internal/server/operations/operations.go:537   rendered operation includes Metadata
internal/server/operations/linux.go:63          sendEvent -> Send(projectName, EventTypeOperation, ...)

The migration websocket authorizes on the secret only — no requestor check, in contrast to exec and console:

cmd/incusd/migrate.go:190-211        migrationSourceWs.Connect(): matches r.FormValue("secret") only
cmd/incusd/instance_exec.go:96       execWs.connect(): if !op.IsSameRequestor(r) { Forbidden }
cmd/incusd/instance_console.go:94    consoleWs.connect(): if !op.IsSameRequestor(r) { Forbidden }

and the websocket endpoint itself is AllowUntrusted:

cmd/incusd/operations.go:54   operationWebsocketGet  AllowUntrusted: true

A restricted certificate scoped to a project is granted every entitlement on that project, so it holds both can_view_events and can_view_operations — meaning the secret is reachable both through the event stream and through GET /1.0/operations/{id}.

Proof of concept

Runtime-verified on Incus 6.0.0 (single daemon, privileged container, attacker remote looped back over HTTPS — the CLI-mediated migration path that generates websocket secrets):

=== operation event broadcast (sniffer view, secrets masked) ===
{"type":"operation","project":"default",
 "metadata":{"class":"websocket","description":"Migrating instance","id":"2689233b-...",
   "metadata":{"control":"bc553c24...","fs":"2ea16bec..."},
   "resources":{"instances":["/1.0/instances/c1"]},"status":"Pending","status_code":105}}

=== attacker websocket connection times (natural race) ===
control: connected +0.012s after secret broadcast
fs:      connected +0.013s after secret broadcast

=== legitimate migration target, arriving second (incusd journal) ===
level=error msg="Failed migration on target" err="Failed getting migration target
  filesystem connection: websocket: bad handshake" instance=c2m

=== attacker receives migration-channel bytes ===
first data frame = 3715-byte migration index header JSON
  {"config":{"Container":{...full instance config, image fingerprint, volatile.*...}}}

Controls in the same lab: incus restart operations broadcast no secret-bearing events (0/3), and the same migration without the hijacker succeeds. Recorded limitations: the event subscriber used an admin-equivalent certificate (the can_view_events-only restricted path is code-chain); the demo was single-daemon; and the full rootfs transfer after the index header was not captured — the channel hijack, rejection of the legitimate consumer, and first payload bytes are the captured facts.

Impact

A client with event-view access to a project can capture the connection secrets of an in-flight migration and hijack its data websockets, winning a race measured at tens of milliseconds in the lab. The legitimate migration then fails server-side, and the attacker receives the migration channel — including the full instance configuration, image fingerprint and volatile keys in the index header, and the instance's filesystem stream that follows — for an instance it may not otherwise read.

References

GitHub · canonical/lxd