Skip to content

Add integrity protection using Encrypt-Then-MAC to default encryption module#21557

Merged
LukasReschke merged 20 commits intomasterfrom
use-hmac-over-encryption
Feb 9, 2016
Merged

Add integrity protection using Encrypt-Then-MAC to default encryption module#21557
LukasReschke merged 20 commits intomasterfrom
use-hmac-over-encryption

Conversation

@LukasReschke
Copy link
Copy Markdown
Member

This adds an integrity protection using Encrypt-Then-MAC to the default encryption module. Authenticated encryption prevents that a storage administrator can tamper with the files such as performing bitflipping attacks on them.

To achieve this the following changes have been done by @schiesbn and me:

  1. Switched to AES-CTR-256 as default cipher for new or modified files
  2. All new files have the HMAC data in the metadata as well.
  3. When decrypting files the signature gets verified. All files encrypted using CTR need this field to be there mandatory, the old CFB mode can have this field but it is not enforced.

This approach gives us the possibility to have complete backwards compatibility with the existing encrypted files (as in: you should be able to read all files as before as well) as well as an easy way to differentiate whether a file needs to have a mandatory HMAC.

To test this also try to modify the encrypted ciphertext in the encrypted document on new or modified files and see whether you can still open the document. With this change applied you should not, it will simply fail to decrypt the file.

There will be no automatic migration as we all know the pain of such. Thus this will only affect new or modified files.

Partially addresses https://github.com/owncloud/security-tracker/issues/191. Some documentation changes are still pending.

@mention-bot
Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @schiesbn, @nickvergessen and @DeepDiver1975 to be potential reviewers

@LukasReschke
Copy link
Copy Markdown
Member Author

@owncloud/qa Please do some testing with encryption enabled. Thanks.
@schiesbn Our branch 🎉

@karlitschek
Copy link
Copy Markdown
Contributor

👍

@rullzer
Copy link
Copy Markdown
Contributor

rullzer commented Jan 8, 2016

So crypto stays a complex thing. And the more you learn about it the further you know to stay away from it ;).

Having said that I can follow the commits here. And the changes make sense to me.

@LukasReschke
Copy link
Copy Markdown
Member Author

Needs some more love to prevent shuffling the entries. Setting back to 2.

@LukasReschke LukasReschke force-pushed the use-hmac-over-encryption branch 3 times, most recently from 86b5842 to 01a9bab Compare February 3, 2016 14:04
@LukasReschke LukasReschke force-pushed the use-hmac-over-encryption branch 2 times, most recently from f37fd5e to c3f18f8 Compare February 4, 2016 00:27
@PVince81
Copy link
Copy Markdown
Contributor

PVince81 commented Feb 5, 2016

@PVince81
Copy link
Copy Markdown
Contributor

PVince81 commented Feb 5, 2016

  • TEST: regular encryption/decryption/overwrite
  • TEST: upgrade with old encrypted files, files can still be read
  • TEST: overwriting old encrypted files switches the encryption to the new mode

@PVince81
Copy link
Copy Markdown
Contributor

PVince81 commented Feb 5, 2016

Code looks good.

LukasReschke and others added 20 commits February 9, 2016 23:43
CTR is recommended over CFB mode.
The previous IV was actually 12 byte extended to 16 byte using base64. As the encrypted file should be fine with containing binary data as well we can simply remove the encoding like that here.
This way it is not possible anymore for an external storage admin to put up old versions of the file.
Prevents switching single blocks within the encrypted file.
…herwise it can happen that we decrease it twice and end up with the wrong value
Saves a call to fetch the file id which didn't even work for a reason.

This fix properly sets the version in the database.
@LukasReschke LukasReschke force-pushed the use-hmac-over-encryption branch from da41a85 to ca35029 Compare February 9, 2016 22:43
LukasReschke added a commit that referenced this pull request Feb 9, 2016
Add integrity protection using Encrypt-Then-MAC to default encryption module
@LukasReschke LukasReschke merged commit 53d57bf into master Feb 9, 2016
@LukasReschke LukasReschke deleted the use-hmac-over-encryption branch February 9, 2016 22:45
@lock
Copy link
Copy Markdown

lock Bot commented Aug 7, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants