Skip to content

Commit 63268f4

Browse files
committed
Fix: check for cipher_null before attaching LUKS container
1 parent 639df27 commit 63268f4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/mount_luks.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ case $? in
1515
;;
1616
# failure; the directory is not a mountpoint, or device is not a block device on --devno
1717
32)
18+
LUKS_DUMP=$(cryptsetup luksDump --dump-json-metadata /var/lib/cosmian_vm/header)
19+
STATUS=$?
20+
21+
if [ $STATUS -ne 0 ]; then
22+
echo "LUKS header does not exist"
23+
exit 2
24+
fi
25+
26+
NULL_CIPHERS=$(echo "$LUKS_DUMP" | jq '[.keyslots.[].area.encryption] | select(any(contains("null")))')
27+
28+
if [ -n "$NULL_CIPHERS" ]; then
29+
echo "cipher_null is not allowed in LUKS header"
30+
exit 3
31+
fi
32+
1833
# unlock the partition
1934
/lib/systemd/systemd-cryptsetup attach cosmian_vm_container /var/lib/cosmian_vm/container - tpm2-device=auto,headless=true,header=/var/lib/cosmian_vm/header || exit 1
2035
# mount the partition

0 commit comments

Comments
 (0)