Miggo Logo

CVE-2025-54287: Canonical LXD Arbitrary File Read via Template Injection in Snapshot Patterns

6.5

CVSS Score
3.1

Basic Information

EPSS Score
0.10965%
Published
10/2/2025
Updated
10/2/2025
KEV Status
No
Technology
TechnologyGo

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
github.com/lxc/lxdgo>= 4.0, < 5.21.45.21.4
github.com/lxc/lxdgo>= 6.0, < 6.56.5
github.com/lxc/lxdgo>= 0.0.0-20200331193331-03aab09f5b5c, < 0.0.0-20250827065555-0494f5d47e410.0.0-20250827065555-0494f5d47e41

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability lies in the RenderTemplate function in shared/util.go, which is responsible for processing snapshot name patterns. The core of the issue is that the Pongo2 template engine was used without proper sandboxing, allowing an attacker with instance configuration permissions to inject malicious template directives. Specifically, the include tag could be used to read arbitrary files from the LXD host's filesystem. The provided patch directly addresses this by creating a restricted TemplateSet and banning several dangerous tags, including include. Therefore, the RenderTemplate function is the primary vulnerable function. Any function that calls RenderTemplate with user-controllable input for the template would be part of the exploitable path. The provided information indicates that this is the case for snapshot name generation, making RenderTemplate the key function to monitor for exploitation attempts.

Vulnerable functions

RenderTemplate
shared/util.go
The `RenderTemplate` function in `shared/util.go` was vulnerable to a template injection attack. It used the Pongo2 template engine to render snapshot names from a user-provided pattern (`snapshots.pattern`). The vulnerability stemmed from the lack of sandboxing, which allowed malicious users to include dangerous tags like `{% include "/etc/passwd" %}` in the template. This tag would then be processed by the template engine, leading to the contents of the specified file being included in the snapshot name, thus exposing sensitive information from the host system. The patch mitigates this by creating a restricted `TemplateSet` and explicitly banning the `include`, `ssi`, `extends`, and `import` tags, which could be abused for file inclusion.

WAF Protection Rules

WAF Rule

### Imp**t In LX*'s inst*n** sn*ps*ot *r**tion *un*tion*lity, t** Pon*o* t*mpl*t* *n*in* is us** in t** `sn*ps*ots.p*tt*rn` *on*i*ur*tion *or **n*r*tin* sn*ps*ot n*m*s. W*il* *o** *x**ution *un*tion*lity **s not ***n *oun* in t*is t*mpl*t* *n*in*, it

Reasoning

T** vuln*r**ility li*s in t** `R*n**rT*mpl*t*` *un*tion in `s**r**/util.*o`, w*i** is r*sponsi*l* *or pro**ssin* sn*ps*ot n*m* p*tt*rns. T** *or* o* t** issu* is t**t t** Pon*o* t*mpl*t* *n*in* w*s us** wit*out prop*r s*n**oxin*, *llowin* *n *tt**k*r