-1

I have been using cryptsetup for a while now and just found out about the option 'luksDump'. I am used to similar tools like veracrypt and truecrypt and I am a bit shocked that all these vulnerable data are so easily accessible. If I remember it right, vera- and truecrypt made it impossible to find out cipher and hash with just a small command.

Is there a way to hide these data? Thank You!

pekosi
  • 1
  • 1
    *"... all these vulnerable data ..."* - what exactly is vulnerable on these data? – Steffen Ullrich Jul 05 '21 at 17:22
  • 5
    You should probably [read up on Kerchoff's principle](https://en.wikipedia.org/wiki/Kerckhoffs%27s_principle). The key is secret. The rest is not secret, and not worth attempting to hide. – vidarlo Jul 05 '21 at 17:23
  • thank you booth for your answers, regarding "... all these vulnerable data ..." i think veracrypt has a big advantage since it uses many different ciphers which aren't known that easily. this would force an attacker to try all possible ciphers and also hash methods which adds to the effort someone would have to put in, thats why i was confused, @vidarlo thank you, i will take a look!:) – pekosi Jul 05 '21 at 18:03
  • https://security.stackexchange.com/questions/24449/how-valuable-is-secrecy-of-an-algorithm. – saurabh Jul 05 '21 at 18:18
  • 1
    @pekosi, Veracrypt supports 15 ciphers and 5 hash algorithms. Hiding your choice of algorithms provides only 6.2 bits of security, less than the 6.6 bits of security you'd get from making your password one character longer. – Mark Dec 11 '21 at 02:54

1 Answers1

0

Foreword

It should be noted that this process is what I'd consider overkill for the average person hoping to protect perhaps some private files that wouldn't have life-long effects on their livelihood. The below explanation is more so to elaborate on the answer to the question of what's possible and makes no means to make any claims as to what's realistic.

Yes, it's possible.

In fact, it would be the next level of security and steps you would take to secure a system containing highly sensitive or classified information. That is, if you really wanted to go the extra mile and hide it, you can. However, as others have mentioned, it's definitely overkill if it's just some private photos you are worried about, but if you had something more valuable to protect then it is possible to "hide" this by essentially putting it elsewhere.

Physically hiding by keeping it separate Also known as using a Detached Header for your LUKS device, you can remove the header and keep it separate from the system so that without it, there wouldn't seem to be a system to even boot because the separated header can act like a key whereas you would need the header file to supply the information needed by the system to identify the drive as an encrypted drive and provide the means to unlock the partition. Without it, a bad actor would only be able to destroy the data but not access it.

Since we're being cautious, you can take it a step further and also keep the boot partition on the same USB drive so that it also holds the kernel image and initramfs images files with the root partition's LUKS header file (keeping the boot partition and header fil in separate partition. That should address your concern as all that's left is encrypted data.

There are a number of online tutorials on how to accomplish this but an informational overview of the different methodologies and deeper understanding can be found here: https://medium.com/@privb0x23/lose-your-head-attempting-to-boot-from-luks-without-a-header-2d61174df360

And further reference at the man page for cryptsetup regarding the header:

--header <device or file storing the LUKS header>
  Use a detached (separated) metadata device or file where the LUKS header is stored. This options allows to store ciphertext and LUKS header on different devices.

A simple overview of the process would be something like the following, (depending if you decided to move the boot partition or not, you may find it easier to use a liveboot environment which means you'd have to chroot into the drive to make the updated changes but AFAIK it's not necessary other than for testing) All commands are run as root aside from the first, otherwise just add sudo

The hiding place

To hide the header information, we're going to make a copy of the header and wipe the current one. References to /dev/sda5 should be changed to your system (and could be /dev/nvme0n1p5 for example) while cleanup of items will be left to the individual, such as removing /tmp/usb/ after transferring the header to USB.

Backup the current header:

: mkdir /tmp/usb/
$ cryptsetup luksHeaderBackup /dev/sda5 --header-backup-file /tmp/usb/header.luks

copy it to a USB (alternatively, instead of using the header as a file, you can also use a raw partition that contains the header instead of it being a file inside the partition)

$ cp /tmp/usb/header.luks /dev/media/usb/header.luks

To transition to boot from the copied and newly located header, update system references such as in fstab, crypttab, etc. with new UUID for boot drive and routes (and chroot into the system at this point)

Updating System Configurations

Then edit the entry in fstab with the new UUID

$ nano /etc/fstab

# within the text editor - add a line for your USB device (and another for the /boot partition if you choose to separate that as well)
UUID={device partition UUID} {mount point} {filesystem} {mount options}  {dump order}{fsck order}

Alternatively you can just switch the UUID of the current entry for the boot drive and where {mount point} should be /boot and the {dump order}{fsck order} should be 0 1 to update the boot procedure.

Finally, update /etc/crypttab so that it knows to look for the header on the usb being sure to match how it was added in fstab (should be on a separate partition from /boot)

$ crypt_device /dev/sda5 luks,header=/mnt/usb/header.luks

To be sure, test the header backup works (make sure to close it before testing)

$ cryptsetup -v --header /mnt/usb/header.luks open /dev/sda5 decrypted_sda5

If the header is good to go and your Usb is all set, finalize the changes with the initramfs update

$ update-initramfs -u -all

Final Touches

Since you don't want the header information available, then using cryptsetup luksErase /dev/sda4 wouldn't work for you because it only erases the key slots. So to ensure the metadata you're worried about isn't made available, you'll need to completely wipe the header.

You'll need to get the filesystem block size and LUKS data offset

stat -fc %s /dev/sda5          # gives us the block size
cryptsetup luksDump /dev/sd5   # prints the header in human readable form for the offset

then

dd if=/dev/urandom of=/dev/sda5 bs={block size} count={offset}

For a more thorough walkthrough for anyone coming across this answer and may want a deeper understanding of all the commands, try: https://wiki.archlinux.org/title/dm-crypt/Device_encryption

Doedigo
  • 11
  • 3
  • 2
    *"In fact, it would be the next level of security"* Quick check: how much entropy do you think it adds, to make the attacker brute-force the encryption metadata? How does that compare to the entropy of an AES-128 key (good for at least the next few hundred years at the current rate of tech improvement), much less an AES-256 key (good for several times the complete lifetime of the universe, from big bang to heat death)? What exactly are you gaining there? – CBHacking Dec 11 '21 at 01:04
  • The OP asked if it was possible to hide the header data, so I answered. The context of "next level of security" refers to the next step of protecting the unencrypted partition with the bootloader and securing the system as a whole further by removing the metadeta itself and hiding it separately to protect the system from an evil maid-style attack. So to answer, it changes the entropy to less than or equal to infinite if it is unknown to the attacker, am I mistaken? But in any case... – Doedigo Dec 14 '21 at 04:52
  • ...Since I share a similar opinion on the matter, and find it an unnecessary precaution as I had attempted to infer in the "Afterword" portion of my answer then perhaps you should be asking the OP what **they had hoped to gained out of asking this question,** as I wouldn't know, I only provided an answer to their question with the hopes of providing whatever it is that they hoped to gain and without my knowledge of. If you've downvoted my answer for it not correctly answering the question, please elaborate on how I might improve my answer. – Doedigo Dec 14 '21 at 05:01