Canonical LXD Arbitrary File Read via Template Injection in Snapshot Patterns
Date: 2025-10
Affected: go/github.com/lxc/lxd, go/github.com/lxc/lxd, go/github.com/lxc/lxd
Attack vector: path-traversal
Category: vulnerability-disclosure
Severity: High
CVE: CVE-2025-54287
CWE: CWE-1336
CVSS: 6.5 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N)

### Impact In LXD's instance snapshot creation functionality, the Pongo2 template engine is used in the `snapshots.pattern` configuration for generating snapshot names. While code execution functionality has not been found in this template engine, it has file reading capabilities, creating a vulnerability that allows arbitrary file reading through template injection attacks. ### Reproduction Steps 1. Log in to LXD-UI with an account that has permissions to modify instance settings 2. Set the following template injection payload in the instance snapshot pattern: ``` {% filter urlencode|slice:":100" %}{% include "/etc/passwd" %}{%endfilter %} ``` Note that the above template uses the Pongo2 template engine's include tag to read system files. It also uses urlencode and slice filters to bypass character count and type restrictions. 3. Set scheduled snapshots to run every minute and wait for snapshot generation 4. Wait about a minute and confirm that file contents can be obtained from the created snapshot name ### Risk The attack requires having configuration change permissions for LXD instances. The attack allows reading arbitrary files accessible with LXD process permissions. This could lead to leakage of the following information: -​ LXD host configuration files (/etc/passwd, /etc/shadow, etc.) -​ LXD database files (containing information about all projects and instances) -​ Configuration files and data of other instances -​ Sensitive information on the host system ###


Mitigations:

Architectural layers (MAESTRO):