Validate blob hashes, offsets and lengths read from the destination #195

Merged
clawbot merged 1 commits from issue-155-validate-destination-inputs into next 2026-09-22 16:11:29 +02:00
1 Commits
Author SHA1 Message Date
sneak ae07981902 Validate blob hashes, offsets and lengths from the destination (closes #155)
check / check (pull_request) Successful in 2m33s
A blob hash read back from the downloaded snapshot database or the store
listing was trusted unchecked. A hostile remote could set a hash such as
"aa/../../etc" and have a decrypted blob written outside the cache
directory, or feed a short or negative value that panicked a command.

blobDiskCache.path now refuses any key with a path separator, and ReadAt
rejects a negative offset or length, bounding with length > size-offset so
a sum cannot overflow past the check. A new isBlobHash helper (a plain
function, since the packer stores temp-placeholder-{uuid} as a hash) gates
FetchBlob, shallow and deep verify, and restore: buildBlobIndexes rejects
every hash from the snapshot database before any fetch. The blobs/ and
metadata/ listings skip a non-conforming name, and short-hash prefixes in
log and error text go through a shortHash helper that cannot panic.
verify's chunk reader rejects a negative length and streams the chunk.

Model: opus-4-8
2026-09-22 13:50:38 +00:00