Files
elysium/tests
tomas.kracmar 0d8af5c52e fix(Update-KHDB): reject manifest shard names that escape the shard directory
Security. Shard names come from the downloaded manifest and were
joined onto local paths unchecked, both for the staging download and
the final Move-Item into the shard directory. A manifest served from
a compromised (or spoofed) KHDB bucket could name a shard
'../../something' with a matching SHA-256 and have that file written
outside the shard directory - outside the install directory with
enough '../' - on an admin host that also holds replication
credentials. Overwriting one of Elysium's own scripts would turn that
into code execution on the next run. TLS limits this to an attacker
who controls the storage.

Reproduced before the fix against the fake S3 store: the updater
logged "Shard '../../escaped.txt' updated." and the file appeared two
levels above the shard directory.

Validate-Manifest, which runs before any download, now rejects shard
names that are rooted, contain a '..' segment (either separator), or
contain ':' (Windows drive-relative paths, NTFS alternate data
streams). Plain relative subpaths like 'sub/00.txt' stay allowed.

Tests: unit cases for each rejected form plus an allowed subpath, and
an end-to-end case where the store serves such a manifest - the run
now fails naming the shard and nothing is written outside. 31/31
Pester tests pass.
2026-11-04 13:22:18 +01:00
..