2

Is it possible to set up a bootloader that automatically begins shredding the header.img file and then the encrypted partition itself upon X failed attempts at decrypting the partition?

If this does not already exist - is it possible to create any such software without extensive work?

Cheers,

1
  • 1
    Of course preferably without informing the intruder before the process is well underway.
    – cxou
    May 20, 2015 at 18:49

2 Answers 2

3

Yes (for your own bootloader / initramfs) and No (for a thief who tries to decrypt it from a Live CD and thus circumvents your trap). So the question is, which situation are you trying to cover here...

From a security standpoint it's not a good idea since it doesn't work and the password should be impossible to bruteforce anyhow. Also there is a high risk of triggering that trap yourself.

It's entirely possible to make mistakes when entering a passphrase. My favourite is the caps lock key, hit it accidentally and not notice (since the password is not echoed) and... in your case it goes boom.

In order to implement it you'd have to see if your distro's flavour of initramfs has a hook system or similar. A normal cryptsetup call may look like this:

cryptsetup -T 5 luksOpen /dev/sda1 luksroot

To boobytrap it you could simply do something like:

cryptsetup -T 5 luksOpen /dev/sda1 luksroot || boobytrap

And boobytrap would be a function that deletes your stuff while keeping the thief occupied. In addition to that you must absolutely check the error code of cryptsetup; so you don't delete because of wrong parameters or anything like that. Check the RETURN CODES section in the manpage.

Pseudocode: (untested and not recommended)

boobytrap() {
    if [ $? -eq 2 ]
    then
        # kill the disk silently in the background...
        dd bs=1M if=/dev/zero of=/dev/sda1 seek=2 2> /dev/null &
        # ...while keeping the thief busy entering more passwords
        cryptsetup -T 9999 luksOpen /dev/sda1 luksroot \
        && echo Congrats, but I already deleted your data...
    fi
}

I hope you have a good backup.

2

A quick look around my Debian "wheezy" system suggests that it would be perfectly possible to insert such a boobytrap in the function do_luks, located in the shell script library /lib/cryptsetup/cryptdisks.functions, which is called from /etc/init.d/cryptdisks-early.

After changing the code it would be necessary to run update-initramfs to ensure that the initial boot disk image was also updated.

My Debian "jessie" system also has these files but I have not confirmed whether or not they are actually used in this brave new world of systemd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.