Skip to contentSkip to conversation

fs/crypto: file-name encryption, optional ?

DISCUSSION Anand Jain 4 participants 11 messages Feb 9, 2017 – Feb 13, 2017 VFS

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

Hi,

File-name encryption was optional if I remember it correctly ? Now I don't see it as optional anymore, any idea ?

Thanks, Anand

#1 lore raw
Quoted 5 lines · Anand Jain

Hi,

File-name encryption was optional if I remember it correctly ? Now I don't see it as optional anymore, any idea ?

No idea, these days it is not optional.

Signature · 2 lines
Thanks,
//richard
#2 lore raw
Quoted 8 lines · Richard Weinberger
Quoted 5 lines · Anand Jain

Hi,

File-name encryption was optional if I remember it correctly ? Now I don't see it as optional anymore, any idea ?

No idea, these days it is not optional.

You can create a zero-length file, and then set the encrypt flag, and I believe that will still work. In that case, the file will be encrypted, even though the file name will not be encrypted. It's not something that we test explicitly, so it's possible it has broken.

Let me explain why we do things the way that we do. The original production use case of ext4 and f2fs encryption was for Android. In that world, you have a locked bootloader, and the system image is protected against tampering using dm-verity. This means that even if your cell phone is left unattended in your hotel room in Beijing, and an "Evil Maid" takes your phone, does a "chip off" attack where the eMMC storage device is desoldered, and then accessed directly, and then the phone is returned to your hotel room before you get back from breakfast, they can't tamper with the system to capture data.

OK, but what if in this "Evil Maid" attack, a particular encrypted directly is replaced with an empty, unencrypted directory (by messing with the file system metadata), and it's a directory where data ends up getting stored after its downloaded from the air --- your e-mail, for example, or maybe the directory where your pictures from the cell phone camera is stored.

Now a few days later, when you leave your cell phone unattended in your hotel room in Shanghai, another "Evil Maid" might take your phone, and harvest the data from the unencrypted directory --- and since the directory is unencrypted, the newly created files would also be encrypted. Win! The "Evil Maids" can now determine if you're from that horrible terrorist group, the Falun Gong. Or maybe the "Evil Maids" are working for your competitor, and they're just after your company's business secrets. :-)

The defense against this is that if a directory is encrypted, the files and sub-directory must also be encrypted, and by the same key. This is enforced at lookup and open time. And the hash of the key of the top-level directories for each user are stored in a small amount of "secure storage" available on the phone, and this is verified when the system is booted.

(An example of such a secure storage might be a small amount of memory, implemented in hardware where the encryption keys are stored, and are unlocked by your pin/password. If the pin/password is entered incorrectly too many times, the secure storage unit will automatically erase all of the keys stored inside.)

Cheers,

- Ted

author
#3 lore raw

Hi Ted,

IMO not all data center solutions would need file-name encryption, its better to bring back the option to disable the file-name encryption.

Thanks, Anand

Quoted 58 lines · Theodore Ts'o
Quoted 8 lines · Richard Weinberger
Quoted 5 lines · Anand Jain

Hi,

File-name encryption was optional if I remember it correctly ? Now I don't see it as optional anymore, any idea ?

No idea, these days it is not optional.

You can create a zero-length file, and then set the encrypt flag, and I believe that will still work. In that case, the file will be encrypted, even though the file name will not be encrypted. It's not something that we test explicitly, so it's possible it has broken.

Let me explain why we do things the way that we do. The original production use case of ext4 and f2fs encryption was for Android. In that world, you have a locked bootloader, and the system image is protected against tampering using dm-verity. This means that even if your cell phone is left unattended in your hotel room in Beijing, and an "Evil Maid" takes your phone, does a "chip off" attack where the eMMC storage device is desoldered, and then accessed directly, and then the phone is returned to your hotel room before you get back from breakfast, they can't tamper with the system to capture data.

OK, but what if in this "Evil Maid" attack, a particular encrypted directly is replaced with an empty, unencrypted directory (by messing with the file system metadata), and it's a directory where data ends up getting stored after its downloaded from the air --- your e-mail, for example, or maybe the directory where your pictures from the cell phone camera is stored.

Now a few days later, when you leave your cell phone unattended in your hotel room in Shanghai, another "Evil Maid" might take your phone, and harvest the data from the unencrypted directory --- and since the directory is unencrypted, the newly created files would also be encrypted. Win! The "Evil Maids" can now determine if you're from that horrible terrorist group, the Falun Gong. Or maybe the "Evil Maids" are working for your competitor, and they're just after your company's business secrets. :-)

The defense against this is that if a directory is encrypted, the files and sub-directory must also be encrypted, and by the same key. This is enforced at lookup and open time. And the hash of the key of the top-level directories for each user are stored in a small amount of "secure storage" available on the phone, and this is verified when the system is booted.

(An example of such a secure storage might be a small amount of memory, implemented in hardware where the encryption keys are stored, and are unlocked by your pin/password. If the pin/password is entered incorrectly too many times, the secure storage unit will automatically erase all of the keys stored inside.)

Cheers,

- Ted

author
#5 lore raw
Quoted 6 lines · Theodore Ts'o
Quoted 4 lines · Anand Jain

IMO not all data center solutions would need file-name encryption, its better to bring back the option to disable the file-name encryption.

Quoted 6 lines

Why, because you trust the HDD firmware[1]?

[1] https://www.theregister.co.uk/2015/02/17/kaspersky_labs_equation_group/

- Ted

Hi Ted, Richard,

I think my any other reason for not having file-name encryption is easily overridden by the reason that, if file-name encryption is not optional now then, it would be a regression as because it was indeed optional before, in EXT4. Here its optional to an extent that, if Andorid finds file-name encryption is mandatory protection to effectively secure the file-data then, of course the file-name encryption can be enabled for their solutions. I hope fs/crypto could provide such a flexibility.

Moreover the data center solutions has to worry about the compatibility of the tools and applications which may or may not run with the uid of the file-data.

Thanks, Anand

#6 lore raw
Quoted 4 lines · Anand Jain

I think my any other reason for not having file-name encryption is easily overridden by the reason that, if file-name encryption is not optional now then, it would be a regression as because it was indeed optional before, in EXT4.

Are you sure it was optional? If so, when? That would have been a bug, because the inductive requirement of the crypto policy was in the design from the very beginning of our implementation phase. There may have been some design docs that talked about it being optional, but they date from before we started thinking about how to protect against Evil Maid attacks.

Quoted 3 lines

Moreover the data center solutions has to worry about the compatibility of the tools and applications which may or may not run with the uid of the file-data.

Even without file name encryption, some tools and applications can be blocked due to SELinux; does that mean we should give up on SELinux because it breaks "compatibility"?

Or if they were expecting to read the data contents, the updatedb(8) program will break once file encryption is turned on. That doesn't mean we should give up on data block encryption.

It perhaps might be more useful if you were to talk about *specific* tools and applications you are concerned about, instead of trying to talk about this in the abstract, since by definition enhanced security techniques will always break *some* compatibility --- of rootkits, and attack tools used by Evil Maids if nothing else!

Regards,

- Ted

author
#7 lore raw
Quoted 6 lines · Theodore Ts'o
Quoted 4 lines · Anand Jain

I think my any other reason for not having file-name encryption is easily overridden by the reason that, if file-name encryption is not optional now then, it would be a regression as because it was indeed optional before, in EXT4.

Quoted 6 lines

Are you sure it was optional? If so, when? That would have been a bug, because the inductive requirement of the crypto policy was in the design from the very beginning of our implementation phase. There may have been some design docs that talked about it being optional, but they date from before we started thinking about how to protect against Evil Maid attacks.

Ok. I can't locate now. Its confusing.
Similarly I am corrected about the encryption context not being a SElinux attr, not sure where I had seen them, it rather very confusing.

Thanks, Anand

#8 lore raw
In reply to Anand Jain

Anand,

Am 10.02.2017 um 16:21 schrieb Anand Jain:

Quoted 6 lines

Hi Ted,

IMO not all data center solutions would need file-name encryption, its better to bring back the option to disable the file-name encryption.

do you fear the overhead?
If so, did you measure it?

Thanks,
//richard

#9 lore raw
Quoted 4 lines · Richard Weinberger

Anand,

Am 10.02.2017 um 16:21 schrieb Anand Jain:

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

Hi Ted,

IMO not all data center solutions would need file-name encryption, its better to bring back the option to disable the file-name encryption.

do you fear the overhead?
If so, did you measure it?

We did measurements on an android phone; I don't recall the exact numbers, but it's wasn't anything we were worried about. Certainly not with any kind of realistic workload where the dcache means that it's rare for the user to see the overhead in real life, but we did do some microbenchmarks[1] as well.

[1] https://git.kernel.org/cgit/fs/ext2/xfstests-bld.git/tree/misc/fname_benchmark.c

- Ted

author
#10 lore raw
In reply to Theodore Ts'o
Quoted 18 lines

OK, but what if in this "Evil Maid" attack, a particular encrypted directly is replaced with an empty, unencrypted directory (by messing with the file system metadata), and it's a directory where data ends up getting stored after its downloaded from the air --- your e-mail, for example, or maybe the directory where your pictures from the cell phone camera is stored.

Now a few days later, when you leave your cell phone unattended in your hotel room in Shanghai, another "Evil Maid" might take your phone, and harvest the data from the unencrypted directory --- and since the directory is unencrypted, the newly created files would also be encrypted. Win! The "Evil Maids" can now determine if you're from that horrible terrorist group, the Falun Gong. Or maybe the "Evil Maids" are working for your competitor, and they're just after your company's business secrets. :-)

Quoted 6 lines

The defense against this is that if a directory is encrypted, the files and sub-directory must also be encrypted, and by the same key. This is enforced at lookup and open time. And the hash of the key of the top-level directories for each user are stored in a small amount of "secure storage" available on the phone, and this is verified when the system is booted.

Right. How does file-name encryption comes as a defense for the above Evil maid attack ? Sorry looks like I am missing something to be convinced.

Thanks, Anand