CVE-2026-136976 — Canonical LXD (4.0.16) — CWE-22
Improper link resolution before file access in recursive file pull in Canonical LXD before 4.0.15, 5.0.11, 5.21.9, and 6.8 on case-insensitive client filesystems allows an authenticated user with write access to an instance directory or custom volume to write arbitrary files outside the target directory and execute code as the operator via case-variant symlinks.
Improper link resolution before file access in recursive file pull in Canonical LXD before 4.0.15, 5.0.11, 5.21.9, and 6.8 on case-insensitive client filesystems allows an authenticated user with write access to an instance directory or custom volume to write arbitrary files outside the target directory and execute code as the operator via case-variant symlinks.
🎯 What is this vulnerability?
This vulnerability is a Path Traversal and Symlink Following flaw (CWE-22: Improper Limitation of a Pathname to a Restricted Directory) in Canonical LXD's recursive file pull mechanism.
Technical Flaw Analysis:
The core issue lies in how LXD handles symbolic links during a recursive file transfer operation (specifically, when pulling files from an instance/volume to the host or another location, or potentially pushing, but the description specifies "write arbitrary files outside the target directory... via case-variant symlinks").
1. Case-Insensitive Filesystem Dependency: The vulnerability is exploitable on case-insensitive client filesystems (e.g., macOS APFS/HFS+, Windows NTFS). On these systems, File.txt and file.txt are treated as the same inode.
2. Improper Link Resolution: When LXD performs a recursive pull, it likely resolves symlinks to determine their target paths. If an attacker creates a symlink with a name that differs only in case from a legitimate file or directory, or if the symlink target itself contains case-variant characters that bypass a naive string comparison check, the LXD process may resolve the symlink to a path outside the intended sandboxed directory.
3. Missing Canonicalization Check: The software fails to properly canonicalize the final resolved path against the allowed base directory after symlink resolution, specifically accounting for case-insensitivity. It likely checks if the path starts with the allowed prefix using a case-sensitive string comparison, which fails on case-insensitive filesystems if the attacker manipulates the case of the symlink name or target.
4. Privilege Context: The LXD daemon runs with elevated privileges (typically root or a dedicated lxd user with significant capabilities). Writing a file outside the instance directory allows the attacker to place files in critical system locations (e.g., /etc/cron.d, /root/.ssh/authorized_keys, or LXD's own configuration files) leading to code execution as the operator.
CVSS Vector Interpretation:
AV:N/AC:L/AT:N/PR:N/UI:A: Network vector, low complexity, no attack required, no privileges required (initially), but User Interaction: Active is required. This suggests the attacker must trick a user (or an automated process acting on user input) into initiating the file pull operation, or the "authenticated user" mentioned in the description refers to the LXD API user who triggers the pull. Correction based on description: The description says "allows an authenticated user with write access...". This contradicts PR:N in the vector. However, CVSS 4.0 PR:N might refer to the initial network access not requiring auth, but the exploit requires an authenticated LXD API token. Let's re-read carefully: "allows an authenticated user... to write...". The CVSS vector PR:N is likely a misclassification in the provided data or refers to the fact that the vulnerability itself* doesn't require OS-level auth, just LXD API auth. Given UI:A, it implies a user must be convinced to perform an action (e.g., "Pull this file from my instance").
- VC:H/VI:H/VA:N: High Confidentiality and Integrity impact. No Availability impact.
- SC:N/SI:N/SA:N: No scope change.
- Identify LXD Installation: Use network scanning (Nmap) to identify the LXD API port (default
8443). - Version Fingerprinting: Query the LXD API endpoint
/1.0or/1.0/clusterto determine the version. Confirm it is4.0.16,5.0.11,5.21.9, or6.8(or earlier unpatched versions).
Filesystem Check: Determine if the host running LXD uses a case-insensitive filesystem. This is harder remotely but can be inferred if the host is macOS or Windows. For Linux hosts, this vulnerability is not exploitable via this specific case-variant symlink method (Linux ext4/btrfs are case-sensitive). Note: The CVE explicitly states "on case-insensitive client filesystems".*
- Credential Acquisition: Obtain valid LXD API credentials (client certificate or token) for a user with write access to an instance or custom volume. This could be via phishing, credential stuffing, or a compromised user account.
- Attacker has LXD API access with write permissions to an instance/volume.
- Host filesystem is case-insensitive (e.g., macOS).
- Attacker can create files/symlinks inside the instance/volume.
⚡ Attack Chain
1. Discovery & Reconnaissance
2. Exploitation
Prerequisites:Step-by-Step Exploitation (Illustrative PoC):
1. Create Malicious Symlink in Instance:
The attacker uses the LXD API to create a symbolic link inside the instance's filesystem. The symlink's name or target is crafted to exploit case-insensitivity.
Example: Suppose the allowed directory is /var/snap/lxd/common/lxd/storage-pools/default/instances/myinstance/rootfs/.
The attacker creates a file secret.txt in the instance.
Then, they create a symlink Secret.txt (different case) pointing to /etc/cron.d/evil.
Wait, the description says "write arbitrary files outside the target directory... via case-variant symlinks". This implies the pull operation follows the symlink and writes the content of the symlinked file to the destination, but the path resolution is flawed.
More Accurate Mechanism:
The attacker creates a directory structure in the instance:
/instance/rootfs/
├── legit_dir/
│ └── file.txt
└── Legit_Dir/ (Case-variant directory name)
└── symlink -> /etc/cron.d/evilWhen the user initiates a "recursive pull" of /instance/rootfs/, LXD traverses the directories. On a case-insensitive FS, legit_dir and Legit_Dir might be treated as the same or cause confusion in the path construction logic. If LXD constructs the destination path using the case-variant name from the filesystem but checks permissions against the canonical name, or if it resolves the symlink symlink -> /etc/cron.d/evil and writes the content of file.txt (or the symlink itself) to the resolved path, it could write to /etc/cron.d/evil.
Alternative Interpretation (More Likely):
The attacker creates a symlink link in the instance pointing to /etc/passwd.
The attacker names the symlink LINK (case-variant).
The pull operation is triggered. LXD reads LINK, resolves it to /etc/passwd, and attempts to write the content to the destination. If the destination path construction is flawed due to case-insensitivity, it might write to an unintended location.
However, the description says "write arbitrary files outside the target directory". This suggests the destination path is manipulated.
Refined PoC (Illustrative):
1. Attacker creates a file payload.sh in the instance.
2. Attacker creates a symlink payload.SH (case-variant) pointing to payload.sh.
3. Attacker triggers a recursive pull of the instance directory to a local directory on the host.
4. Due to case-insensitivity, the LXD process might resolve the symlink payload.SH to a path that, when combined with the base directory, escapes the sandbox. For example, if the base directory is /home/user/pulls/ and the symlink is named ../../etc/cron.d/evil (but case-variant tricks are used to bypass a simple startsWith check).
Actually, the most common case-variant symlink attack on case-insensitive FS is:
1. Create a directory dir in the instance.
2. Create a symlink dir/link -> /etc/cron.d/evil.
3. Rename dir to DIR (case-variant).
4. Trigger pull. The path becomes .../DIR/link. If the security check compares .../dir/link (lowercase) against the allowed base, it might pass, but the actual file system operation uses .../DIR/link, which resolves to /etc/cron.d/evil.
Curl Example (Illustrative):
# 1. Create instance (if not exists)
curl -k --cert client.crt --key client.key https://localhost:8443/1.0/instances -d '{"name":"vuln-test"}'
# 2. Create malicious symlink structure inside the instance
# This requires executing commands inside the instance or using the LXD API to create files.
# Assuming we can create files via the API or exec:
curl -k --cert client.crt --key client.key -X POST https://localhost:8443/1.0/instances/vuln-test/exec -d '{"command":["mkdir","-p","/tmp/evil"],"user":"root"}'
curl -k --cert client.crt --key client.key -X POST https://localhost:8443/1.0/instances/vuln-test/exec -d '{"command":["ln","-s","/etc/cron.d/evil","/tmp/evil/link"],"user":"root"}'
# 3. Trigger the recursive pull (Exact API endpoint for pull is not specified in CVE, this is illustrative)
# The user (or attacker with API access) initiates a pull of /tmp/evil to a host directory.
curl -k --cert client.crt --key client.key -X POST https://localhost:8443/1.0/instances/vuln-test/files -d '{"path":"/tmp/evil","type":"dir"}'
# Note: The actual "pull" operation might be a different API call or a client-side action triggered by the user.3. Post-Exploitation
/etc/cron.d/, they can schedule a cron job that executes arbitrary commands as root (or the LXD user).🌍 Real World Impact
/etc/shadow, SSH keys, LXD configuration) by writing a script that exfiltrates them.🛡️ Remediation & Mitigation
Exact Affected Versions & Upgrade Recommendation
4.0.15, 5.0.11, 5.21.9, and 6.8.4.0.15 or later. For LXD 5.0, upgrade to 5.0.11 or later. For LXD 5.21, upgrade to 5.21.9 or later. For LXD 6.8, upgrade to the patched version (likely 6.8.1 or later, check Canonical's release notes).Actionable Workarounds
1. Disable Recursive File Pull: If possible, disable the recursive file pull feature via LXD configuration or API restrictions. 2. Restrict API Access: Limit LXD API access to trusted users only. Use strong authentication (client certificates) and disable password-based authentication if possible. 3. Use Case-Sensitive Filesystem: If running on a case-insensitive filesystem (macOS, Windows), consider migrating to a case-sensitive filesystem (e.g., APFS with case-sensitive option, or Linux ext4) if feasible. 4. Network Segmentation: Isolate the LXD host from untrusted networks. Use firewalls to restrict access to the LXD API port (8443) to specific IP addresses.Detection
/etc/cron.d, /root/.ssh) for unauthorized changes./etc/cron.d/ or /var/spool/cron/.
* New SSH keys in /root/.ssh/authorized_keys.
* Unusual LXD API calls to the /files endpoint with recursive flags.
* Symlinks in instance directories pointing to absolute paths outside the instance.⚠️ Urgency
FOFA Query