dstack-util: bound LUKS2 keyslot area to the metadata region#799
Open
h4x3rotab wants to merge 1 commit into
Open
dstack-util: bound LUKS2 keyslot area to the metadata region#799h4x3rotab wants to merge 1 commit into
h4x3rotab wants to merge 1 commit into
Conversation
The in-memory header validator pinned the cipher/KDF shape but never checked the keyslot area.offset/size — the byte range the encrypted key material is read from. A host with raw disk access could redirect it inside an otherwise-conforming header. cryptsetup's digest check already stops this from yielding a usable key, so it isn't exploitable on its own, but the validator shouldn't accept a header pointing its key material somewhere arbitrary. Bound the area to [2 * hdr_size, PAYLOAD_OFFSET) and reject anything outside it. Also note why salts stay unchecked (high-entropy KMS-derived passphrase, per #552) so the gap doesn't read as an oversight next time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The in-memory LUKS2 header validator checks the cipher and KDF shape exhaustively, but never bounds the keyslot
area.offset/area.size— the on-disk byte range the encrypted key material is read from. This adds a bounds check.Why
A malicious host has raw read/write access to the disk. Without this check it can point the keyslot area anywhere inside an otherwise fully-conforming header, and the validator still accepts it.
It's not exploitable on its own: cryptsetup decrypts the keyslot under the KMS-derived passphrase and verifies the recovered key against the digest, so a redirected area just yields the wrong key and
luksOpenaborts (a DoS a host with disk write already has). But a validator whose whole job is to pin the header shouldn't let the key material come from an arbitrary offset. This closes the gap as defense-in-depth.Change
[2 * hdr_size, PAYLOAD_OFFSET)— after both header copies, before the payload.No cross-copy comparison is added: both copies already pass the same strict whitelist independently, so once the area is bounded they can't meaningfully diverge.
🤖 Generated with Claude Code