|
|
Log in / Subscribe / Register

Thwarting the "evil maid"

LWN.net needs you!

Without subscribers, LWN would simply not exist. Please consider signing up for a subscription and helping to keep LWN publishing.

By Jake Edge
July 15, 2015

The "evil maid" attack against disk encryption has been known for quite a few years now. We looked at it back in 2009, shortly after Joanna Rutkowska (who first described the attack) announced a proof-of-concept "evil maid" attack on the popular TrueCrypt disk-encryption tool. In 2011, she also came up with an "Anti Evil Maid" tool; more recently, Matthew Garrett has come up with some refinements that he calls "Anti Evil Maid 2 Turbo Edition". These methods for stopping evil maids (and others with physical access to our systems) are worth a look.

The "evil maid" attack got its name from a scenario where the maid at a hotel (or someone pretending to be) would access a guest's laptop while they were out of their room. The attacker would install a kind of malware in the master boot record (MBR) of the system that would record the decryption password. Another visit is all it would take for the attacker to get the password (and perhaps to decrypt some data). More sophisticated attacks might send the password to the attacker over the network. Some way to access the disk's data, now that it can be decrypted, would need to be arranged (e.g. copy the disk at installation time, steal the laptop later, etc.).

Ensuring the code being run by the system is the same as what is expected is the only mechanism to thwart many of these kinds of attacks. Using the Trusted Platform Module (TPM) hardware that is present on many systems these days can provide a way to ensure that the system's firmware, bootloader, and other code involved in the disk encryption have not changed. Garrett described how the TPM can be used:

[TPMs] have a bunch of Platform Configuration Registers (PCRs) that are cleared on power cycle but otherwise have slightly strange write semantics - attempting to write a new value to a PCR will append the new value to the existing value, take the SHA-1 of that and then store this SHA-1 in the register. During a normal boot, each stage of the boot process will take a SHA-1 of the next stage of the boot process and push that into the TPM, a process called "measurement". Each component is measured into a separate PCR - PCR0 contains the SHA-1 of the firmware itself, PCR1 contains the SHA-1 of the firmware configuration, PCR2 contains the SHA-1 of any option ROMs, PCR5 contains the SHA-1 of the bootloader and so on.

If any of those components has been modified, the TPM measurement by the previous component will detect it. In addition, the TPM can be used to encrypt some data that it will only decrypt if all of the PCR values match their expected values. So an encrypted key for the disk could be stored in such a way that it can only be decrypted if the system has not been modified. So far, so good.

But, either the disk decryption key is applied automatically at boot time, which leaves the system open to simply being stolen and booted, or a password can be applied to the boot process. However, that leaves another problem behind, as Garrett outlined:

You can add a password, but the obvious attack is then to modify the boot process such that a fake password prompt is presented and the malware exfiltrates the data. The TPM won't hand over the secret, so the malware flashes up a message saying that the system must be rebooted in order to finish installing updates, removes itself and leaves anyone except the most paranoid of users with the impression that nothing bad just happened. It's an improvement over the state of the art, but it's not a perfect one.

This is where Rutkowska's Anti Evil Maid comes into play. Users can encrypt a secret phrase with the TPM, which can be used in one of two forms. It can be stored on a USB stick that is consulted whenever the user believes there is a reason to check the integrity of their system. If the TPM can decrypt the phrase, then all is well. That does, however, require the user to decide when to check, which is not fully reliable.

An alternative is to do it on every boot, but that has its flaws as well. The attacker could simply boot the system, see the phrase, and modify their malware to simply print the proper phrase. That can also be handled by password-protecting the TPM, but that results in the scenario where a fake password prompt is offered, the password is stored, the malware removes itself, and the system is rebooted. As Garrett noted, users can be trained to recognize the attack: "if the system reboots without the user seeing the secret, the user must assume that their system has been compromised and that an attacker now has a copy of their TPM password."

The usability of that mechanism is not all that good, though. Garrett has come up with his "Turbo Edition" that adds a dynamic element into the mix, so that both the user and the computer can independently agree on a password that changes frequently. As he pointed out, many already use a one-time password (OTP) for two-factor authentication. In that scenario, users prove to the computer that they can generate the proper OTP, while Garrett's mechanism would reverse that: the computer would prove that it can generate the proper OTP to show that it hasn't been compromised.

Garrett has created a prototype that uses the time-based OTP (TOTP) algorithm to generate the passwords. TOTP takes a secret and the time of day to generate the OTP. That secret can be encrypted by the TPM so it will only be available if the system has not been tampered with. Enrolling the secret into a TOTP smartphone app allows the user to generate the same OTP. So instead of a static secret phrase that gets decrypted and printed to the screen (which a physically present attacker could learn), the boot process calculates an OTP and prints that to the screen, which the user verifies on their smartphone. An attacker who learns an OTP will have no advantage as long as the user is diligent about verifying the OTP on every boot.

It is a clever combination of two existing security technologies that should work well, once all of the pieces are in place. As Garrett pointed out, there are caveats:

Do pay attention to the list of limitations - without a bootloader that measures your kernel and initrd, you're still open to compromise. Adding TPM support to grub is on my list of things to do. There are also various potential issues like an attacker being able to use external DMA-capable devices to obtain the secret, especially since most Linux distributions still ship kernels that don't enable the IOMMU by default. And, of course, if your firmware is inherently untrustworthy there's multiple ways it can subvert this all. So treat this very much like a research project rather than something you can depend on right now. There's a fair amount of work to do to turn this into a meaningful improvement in security.

There is an alternative to all of these complicated "Anti Evil Maid" techniques, of course: maintaining physical control of laptops (or other systems) at all times. That is a tall order for most people; for the truly paranoid (or targeted), though, it is the safest course. But, for that to be effective, any loss of control, even for a short time, has to result in the system being discarded as "compromised". Obtaining a new, trusted system and retrieving the data from backups will be required, though now the system used for backups is the big target—and may be far harder to prevent physical access to.


Index entries for this article
SecurityEncryption/Disk
SecurityPhysical security


to post comments

Thwarting the "evil maid"

Posted Jul 16, 2015 13:23 UTC (Thu) by mjthayer (guest, #39183) [Link] (4 responses)

Can't an attacker with physical access to the machine just discretely add a bit of radio hardware to the keyboard?

Thwarting the "evil maid"

Posted Jul 16, 2015 17:23 UTC (Thu) by HIGHGuY (subscriber, #62277) [Link] (2 responses)

Or apply acoustic stickers to the keys and use a microphone to know what keys were typed.

Thwarting the "evil maid"

Posted Jul 16, 2015 18:33 UTC (Thu) by mjthayer (guest, #39183) [Link] (1 responses)

I was thinking more of sending key events. I think (from my armchair) that picking them up (and even reading the VDU) is theoretically possible even without additional hardware, just by monitoring emission.

Thwarting the "evil maid"

Posted Jul 16, 2015 20:32 UTC (Thu) by droundy (guest, #4559) [Link]

I think this requires physical proximity while the user is typing the password, right? And the scary thing with the evil maid attack is that it doesn't require such proximity.

Thwarting the "evil maid"

Posted Jul 16, 2015 22:03 UTC (Thu) by mjg59 (subscriber, #23239) [Link]

Detecting physical tampering is much closer to being a solved problem - at even the most basic level, covering all screws on your machine with glitter nail polish and taking a picture of the pattern will deal deter even advanced adversaries. Replacing the firmware or bootloader is much more attractive because most users have fewer tools to detect that.

Thwarting the "evil maid"

Posted Jul 16, 2015 15:17 UTC (Thu) by jhoblitt (subscriber, #77733) [Link] (5 responses)

Doesn't this depend on your cellphone both being secure and never being out of your direct control?

Thwarting the "evil maid"

Posted Jul 16, 2015 17:29 UTC (Thu) by raven667 (subscriber, #5198) [Link]

Nothing is perfect but it greatly increases the difficulty, cell phones do more to protect themselves than general purpose computers do and you are much more likely to have it under your direct control far more of the time than a general purpose computer. It's pretty hard to make a solid plan that depends on being able to both exfiltrate the OTP from the phone and modify the laptop without being detected in either case against a device owner who is taking this level of effort to protect themselves.

Thwarting the "evil maid"

Posted Jul 16, 2015 22:04 UTC (Thu) by mjg59 (subscriber, #23239) [Link] (3 responses)

Forcing an attacker to compromise two devices that share very little common code is a significant increase in difficulty over them only needing to compromise one.

Thwarting the "evil maid"

Posted Jul 20, 2015 11:09 UTC (Mon) by nix (subscriber, #2304) [Link] (2 responses)

I thought phones were more less entirely compromised by Five Eyes and other state-level attackers as it is? (Or is the point that that compromise is down limited channels, along the lines of "remotely turn on the microphone", and it might be hard for them to fiddle things so they can spy on your TOTP app.)

Still, I guess it'll defend you from non-state attackers who are willing to go to these lengths. I can't really think of any. Perhaps if you're mixed up in the Mafia...

Thwarting the "evil maid"

Posted Jul 20, 2015 15:42 UTC (Mon) by raven667 (subscriber, #5198) [Link]

Sure, the phone is not impossible to break into, neither is the laptop, but now instead of being able to tackle them individually you have to spend your expensive techniques to break both, which makes the cost (in deniability, in the disclosure of a vulnerability that can't be used again) justifiable for a smaller and smaller number of targets.

Thwarting the "evil maid"

Posted Jul 20, 2015 15:44 UTC (Mon) by ortalo (guest, #4654) [Link]

Another issue is to ensure actual code diversity: with Android smartphones and Android laptops (for example), this diversity may not be so important.

Anyway, personnally, I fully recognize the improvement in trying to have another device to help in the verification. But I wonder if, in order to have actual guarantees, the real issue is not to have fully open hardware at some step.
We probably know here (maybe contrarily to most of the rest of the world) that such an open hardware is feasible if you only want it to be able to perform some cryptographic calculations (whether OTP calculations or heavy assymetric crypto. depending on one's mileage) or simple external memory verifications.
The most difficult thing seems finding the political support and the funding to do that (and only that). Governements or companies seem to invest so much more money into mistrust-raising devices rather than trust-building ones...

Thwarting the "evil maid"

Posted Jul 20, 2015 15:05 UTC (Mon) by ortalo (guest, #4654) [Link]

Why not resort to a portable device (like a smartcard) in order to bootstrap the verification, possibly via a cooperation between the TPM and the smartcard (could be tricky - but the idea is to have a portable physical part)?

Those truely paranoid about physical security will go towards contactless smartcard implanted under their skin.
Just my 0.02 cents though. (Especially, I am very contemplative at how they will plug the keypad to enter the s/c PIN...)


Copyright © 2015, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds