/

CVE-2026-34178

Severity:

CRITICAL RISK

(9.1)

Improper Input Validation in Canonical LXD Backup Import

CVE-2026-34178

Analyzed

Vulnerability type

Category:

Improper Input Validation

CWE:

CWE-20

Impact:

Privilege Escalation to Host Compromise

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Canonical LXD before 6.8 contains an input validation flaw in the backup import path where project restrictions are validated against one metadata file in the archive but instance settings are actually taken from a different, unchecked file.

An authenticated remote attacker with permission to create instances in a restricted project can craft a malicious backup archive to bypass restriction policies (e.g., set security.privileged=true or inject raw.lxc directives), potentially achieving full host compromise.

Affected context

This vulnerability appears in LXD environments that:

  • Run a version of Canonical LXD prior to 6.8
  • Use projects with restriction policies to limit instance capabilities (e.g., no privileged containers, no raw.lxc)
  • Allow authenticated users or tenants to create or import instances via backup archives
  • Rely on LXD's project-level enforcement to prevent powerful instance configuration options

The risk is most pronounced in multi-tenant or shared-host deployments where less-privileged users are confined to restricted projects but still have instance creation privileges.

Exploit preconditions

  • Attack surface: LXD API / CLI endpoints handling instance backup import operations.
  • Required access: Valid, authenticated access to an LXD server with:
  • Permission to create/import instances within a restricted project.
  • Attacker capabilities: Ability to craft or modify backup tar archives, including:
  • backup/index.yaml (used for validation)
  • backup/container/backup.yaml (used for actual instance creation)
  • Trigger point: Importing a malicious backup archive into a restricted project, causing LXD to validate project restrictions against index.yaml but create the instance based on the unchecked backup.yaml.
  • Why exploitation is possible: The implementation assumes that validating configuration in one metadata file is sufficient, but then instantiates the instance from a different file that is not subject to the same restriction checks. This broken validation flow enables restricted settings to slip through.

Why this happens

The root cause is an improper input validation and inconsistent trust boundary between multiple configuration sources within the same backup archive.

During backup import, LXD validates project restrictions only against backup/index.yaml, but the authoritative configuration for the instance is later read from backup/container/backup.yaml without reapplying those restrictions.

This maps to CWE-20: Improper Input Validation, where an application performs validation on one representation of the input but uses another, effectively bypassing security checks.

Abstractly, the insecure pattern is:

  • Multiple input artifacts carry overlapping configuration.
  • Security checks apply only to one artifact.
  • The system ultimately uses a different, unchecked artifact for critical decisions (e.g., privileged mode, raw directives), causing policy enforcement gaps.

Potential impact

  • Bypass of LXD project restrictions designed to limit instance capabilities.
  • Creation of privileged containers (security.privileged=true) from within otherwise restricted projects.
  • Injection of powerful raw.lxc directives to manipulate container behavior at a low level.
  • Escalation from container-level to host-level privileges, enabling full host compromise.
  • Lateral movement to other workloads hosted on the same LXD server.
  • Undermining of multi-tenant isolation and containment guarantees.

General mitigation guidance

Effective mitigation focuses on enforcing consistent validation across all configuration sources and tightening trust boundaries around backup imports.

Recommended defensive patterns include:

  • Single-source-of-truth for configuration: Design backup and import logic so that only one canonical metadata file determines instance configuration, and apply all restriction checks to that file.
  • Re-validate at the point of use: Whenever configuration is read (e.g., from backup.yaml), enforce project restrictions immediately before creating or modifying an instance, not only during preliminary metadata checks.
  • Defense-in-depth policy enforcement: Implement layered checks so that even if a backup path is overlooked, the low-level instance creation logic still applies project restrictions (e.g., reject privileged or raw.lxc settings when project policies forbid them).
  • Restrict powerful options by default: Treat settings like security.privileged and raw.lxc as high-risk; require explicit, higher-trust contexts (administrative projects or roles) before allowing them.
  • Reduce privilege for routine users: Avoid granting broad instance-creation rights with the ability to import arbitrary backups to untrusted or semi-trusted tenants; where possible, route such operations through controlled workflows with additional validation.
  • Harden multi-tenant deployments: For shared environments, combine LXD restrictions with OS-level isolation (e.g., mandatory access control, reduced host capabilities) so that misconfigurations are less likely to lead directly to host compromise.

How teams detect issues like this

Identifying and monitoring for this class of weakness involves examining both code and operational behavior:

  • Code-level detection:
  • Look for code paths where configuration is validated in one place/file but later re-read from another file or structure without reapplying policy checks.
  • Use static analysis rules or internal code review checklists targeting "validate-then-use-different-source" patterns, especially around backup, import, and migration subsystems.
  • Flag usages where powerful options (e.g., privilege flags or raw configuration directives) are loaded from external archives or user-supplied metadata without explicit restriction checks tied to project or tenant policy.
  • Configuration and policy review:
  • Regularly review project restriction configurations and ensure they are enforced consistently in all lifecycle operations (create, restore, import, migrate).
  • Verify that instance creation APIs do not have alternate or legacy pathways that bypass policy enforcement.
  • Runtime monitoring:
  • Log and alert on creation of privileged instances or usage of raw.lxc directives, especially within projects that are supposed to be restricted.
  • Track anomalies such as restricted projects suddenly hosting instances with elevated capabilities or host-level mount/access patterns.
  • Automated assurance:
  • Integrate policy-as-code tools that can simulate instance creation from sample inputs and confirm that restrictions are always applied.
  • Use CI/CD security gates that enforce architectural rules: e.g., any change that reads configuration from backups must also call a common restriction-enforcement routine.

Sources

SourceLink
github.comgithub.com/canonical/lxd/pull/17921
github.comgithub.com/canonical/lxd/security/advisories/GHSA-q96j-3fmm-7fv4

Frequently asked

questions

Yes, it can be exploited remotely, but only by authenticated users who can reach the LXD API or CLI endpoint and have permission to create or import instances in a project. It is not exploitable by unauthenticated outsiders.

The attacker needs valid LXD credentials and instance-creation permissions within a restricted project. With that access, they can import a crafted backup archive that bypasses the project's restrictions.

The safest pattern is to consolidate configuration validation so that:

  • There is a single authoritative configuration source for instance creation, and
  • All project restrictions and security policies are enforced directly against that source at the moment of use.

Additionally, the low-level instance creation logic should refuse configurations that violate project or tenant restrictions, regardless of how the configuration was supplied.

Future prevention relies on:

  • Designing APIs so that security checks are centralized and reused by all code paths that create or modify instances.
  • Treating backup and import mechanisms as high-risk and applying the same or stricter validation as for normal instance creation.
  • Incorporating security-focused code reviews and automated tests that explicitly cover backup/restore, import/migration, and other "alternative" lifecycle operations.
  • Maintaining strong least-privilege practices for multi-tenant environments, granting powerful configuration capabilities only to highly trusted roles and projects.
Find out what's already
exploitable in your codebase.