GHSA-x9qq-236j-gj97: Github.com/canonical/lxd Canonical LXD Documentation Improvement To Vulnerability

LOW
Published
Advisory Summary

GHSA-x9qq-236j-gj97 is a LOW canonical lxd documentation improvement to vulnerability (General Security Weakness) affecting Github.com/canonical/lxd libraries in the Go ecosystem. The issue involves canonical lxd documentation improvement to make clear restricted.devices.disk=allow without restricted.devices.disk.paths also allows shift=true. Remediation is available by upgrading affected packages to version 5.20.0, 0.0.0-20240118092008-ce1bd0dd37bb.

GHSA-x9qq-236j-gj97 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-x9qq-236j-gj97
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Github.com/canonical/lxd
Package Ecosystem Go
Published Date
Last Updated

How to Fix GHSA-x9qq-236j-gj97

To remediate this vulnerability, upgrade all affected Github.com/canonical/lxd dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/canonical/lxd fixed: 5.20.0
Upgrade github.com/canonical/lxd to 5.20.0
github.com/canonical/lxd fixed: 0.0.0-20240118092008-ce1bd0dd37bb
Upgrade github.com/canonical/lxd to 0.0.0-20240118092008-ce1bd0dd37bb
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/canonical/lxd

How to Check if You Are Affected

To determine whether your application is affected by GHSA-x9qq-236j-gj97, inspect your project dependencies for Github.com/canonical/lxd:

inspect dependencies for github.com/canonical/lxd

Analyze the terminal output to locate any version of Github.com/canonical/lxd in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.20.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Github.com/canonical/lxd, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary If a user has restricted access to a project that is configured with `restricted=true`, they can gain root access on the system by creating a disk device with `shift=true` and creating a setuid root executable. This is possible because the `shift` property is not restricted unless `restricted.devices.disk.paths` is set. ### Details The following patch shows the offending code with a possible fix: ```patch --- a/lxd/device/disk.go +++ b/lxd/device/disk.go @@ -429,17 +429,19 @@ func (d *disk) validateEnvironmentSourcePath() error { if instProject.Name != api.ProjectDefaultName { // If restricted disk paths are in force, then check the disk's source is allowed, and record the // allowed parent path for later user during device start up sequence. - if shared.IsTrue(instProject.Config["restricted"]) && instProject.Config["restricted.devices.disk.paths"] != "" { - allowed, restrictedParentSourcePath := project.CheckRestrictedDevicesDiskPaths(instProject.Config, d.config["source"]) - if !allowed { - return fmt.Errorf("Disk source path %q not allowed by project for disk %q", d.config["source"], d.name) + if shared.IsTrue(instProject.Config["restricted"]) { + if instProject.Config["restricted.devices.disk.paths"] != "" { + allowed, restrictedParentSourcePath := project.CheckRestrictedDevicesDiskPaths(instProject.Config, d.config["source"]) + if !allowed { + return fmt.Errorf("Disk source path %q not allowed by project for disk %q", d.config["source"], d.name) + } + + d.restrictedParentSourcePath = shared.HostPath(restrictedParentSourcePath) } if shared.IsTrue(d.config["shift"]) { return fmt.Errorf(`The "shift" property cannot be used with a restricted source path`) } - - d.restrictedParentSourcePath = shared.HostPath(restrictedParentSourcePath) } } ``` ### PoC ```bash $ lxc project create restricted -c restricted=true -c restricted.devices.disk=allow $ lxc project switch restricted $ lxc profile device add default root disk path=/ pool=default $ lxc init ubuntu:22.04 c1 $ lxc config device add c1 d1 disk source=/ path=/mnt shift=true $ lxc start c1 # no error $ lxc project set restricted restricted.devices.disk.paths=/ # explicitly allow mounting / $ lxc restart c1 Error: Failed to start device "d1": The "shift" property cannot be used with a restricted source path ``` Created https://github.com/canonical/lxd/issues/12606 to improve the documentation as per https://github.com/canonical/lxd/security/advisories/GHSA-x9qq-236j-gj97#advisory-comment-91918

GHSA-x9qq-236j-gj97 Affected Github.com/canonical/lxd Versions

2 component(s)
Fixed Versions:
5.20.00.0.0-20240118092008-ce1bd0dd37bb
Product / Package Ecosystem Affected Versions Fixed Version
github.com/canonical/lxd
Go
≥ 5.19.0
< 5.20.0
All 1 versions
5.19.0
5.20.0
github.com/canonical/lxd
Go
≥ 0.0.0-20230920084527-cbe39c5d3f14
< 0.0.0-20240118092008-ce1bd0dd37bb
0.0.0-20240118092008-ce1bd0dd37bb

References

Frequently Asked Questions

What is GHSA-x9qq-236j-gj97?
GHSA-x9qq-236j-gj97 is a security vulnerability in Github.com/canonical/lxd involving Canonical LXD documentation improvement to make clear restricted.devices.disk=allow without restricted.devices.disk.paths also allows shift=true under General Security Weakness.
Which Github.com/canonical/lxd versions are affected?
Affected versions include releases prior to 5.20.0, 0.0.0-20240118092008-ce1bd0dd37bb across affected packages: github.com/canonical/lxd.
What version fixes GHSA-x9qq-236j-gj97?
Upgrading to 5.20.0, 0.0.0-20240118092008-ce1bd0dd37bb (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/canonical/lxd affected?
Yes, github.com/canonical/lxd is affected in releases prior to 5.20.0, 0.0.0-20240118092008-ce1bd0dd37bb. Upgrade your dependency to 5.20.0, 0.0.0-20240118092008-ce1bd0dd37bb or later.
What CWE is associated with GHSA-x9qq-236j-gj97?
GHSA-x9qq-236j-gj97 is classified under General Security Weakness.
How can I check Go dependencies for GHSA-x9qq-236j-gj97?
Run the dependency tree command: 'inspect dependencies for github.com/canonical/lxd'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-x9qq-236j-gj97",
  "modified" : "2025-07-22T14:57:33Z",
  "published" : "2023-12-05T23:32:58Z",
  "aliases" : [ ],
  "summary" : "Canonical LXD documentation improvement to make clear restricted.devices.disk=allow without restricted.devices.disk.paths also allows shift=true",
  "details" : "### Summary\n\nIf a user has restricted access to a project that is configured with `restricted=true`, they can gain root access on the system by creating a disk device with `shift=true` and creating a setuid root executable. This is possible because the `shift` property is not restricted unless `restricted.devices.disk.paths` is set.\n\n### Details\n\nThe following patch shows the offending code with a possible fix:\n```patch\n--- a/lxd/device/disk.go\n+++ b/lxd/device/disk.go\n@@ -429,17 +429,19 @@ func (d *disk) validateEnvironmentSourcePath() error {\n        if instProject.Name != api.ProjectDefaultName {\n                // If restricted disk paths are in force, then check the disk's source is allowed, and record the\n                // allowed parent path for later user during device start up sequence.\n-               if shared.IsTrue(instProject.Config[\"restricted\"]) && instProject.Config[\"restricted.devices.disk.paths\"] != \"\" {\n-                       allowed, restrictedParentSourcePath := project.CheckRestrictedDevicesDiskPaths(instProject.Config, d.config[\"source\"])\n-                       if !allowed {\n-                               return fmt.Errorf(\"Disk source path %q not allowed by project for disk %q\", d.config[\"source\"], d.name)\n+               if shared.IsTrue(instProject.Config[\"restricted\"]) {\n+                       if instProject.Config[\"restricted.devices.disk.paths\"] != \"\" {\n+                               allowed, restrictedParentSourcePath := project.CheckRestrictedDevicesDiskPaths(instProject.Config, d.config[\"source\"])\n+                               if !allowed {\n+                                       return fmt.Errorf(\"Disk source path %q not allowed by project for disk %q\", d.config[\"source\"], d.name)\n+                               }\n+\n+                               d.restrictedParentSourcePath = shared.HostPath(restrictedParentSourcePath)\n                        }\n\n                        if shared.IsTrue(d.config[\"shift\"]) {\n                                return fmt.Errorf(`The \"shift\" property cannot be used with a restricted source path`)\n                        }\n-\n-                       d.restrictedParentSourcePath = shared.HostPath(restrictedParentSourcePath)\n                }\n        }\n```\n\n### PoC\n\n```bash\n$ lxc project create restricted -c restricted=true -c restricted.devices.disk=allow\n$ lxc project switch restricted\n$ lxc profile device add default root disk path=/ pool=default\n$ lxc init ubuntu:22.04 c1\n$ lxc config device add c1 d1 disk source=/ path=/mnt shift=true\n$ lxc start c1  # no error\n\n$ lxc project set restricted restricted.devices.disk.paths=/  # explicitly allow mounting /\n$ lxc restart c1\nError: Failed to start device \"d1\": The \"shift\" property cannot be used with a restricted source path\n```\n\nCreated https://github.com/canonical/lxd/issues/12606 to improve the documentation as per https://github.com/canonical/lxd/security/advisories/GHSA-x9qq-236j-gj97#advisory-comment-91918",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/canonical/lxd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.19.0"
      }, {
        "fixed" : "5.20.0"
      } ]
    } ],
    "versions" : [ "5.19.0" ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/canonical/lxd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.0.0-20230920084527-cbe39c5d3f14"
      }, {
        "fixed" : "0.0.0-20240118092008-ce1bd0dd37bb"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/canonical/lxd/security/advisories/GHSA-x9qq-236j-gj97"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/canonical/lxd/issues/12606"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/canonical/lxd/commit/ce1bd0dd37bb3810fe6f16c237a4b65257f231f1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/canonical/lxd"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-12-05T23:32:58Z",
    "nvd_published_at" : null
  }
}