3 ms·
AES-CBC for quick and dirty encryption can be a red flag: the scheme needs to include an encrypt-then-MAC phase or it'll be vulnerable to padding oracle attacks
by woodruffw 5y ago
AES-CBC for quick and dirty encryption can be a red flag: the scheme needs to include an encrypt-then-MAC phase or it'll be vulnerable to padding oracle attacks. I tried to do a quick scan of the code[1] to determine whether it does that, but I couldn't locate it, possibly because my PHP comprehension is terrible.
[1]: https://github.com/GigaMick/burnernote https://github.com/GigaMick/burnernote
- woodruffw 5y agoUpdate: As far as I can tell, this is the encryption encrypoint[1]. It does seem to be vulnerable to a padding oracle attack, unless the `$request->note` parameter is something much more complicated than it appears to be (i.e., it appears to be the plaintext). It's always great to see people experiment with encryption (and burn-after-use schemes are very cool!) but, absent of further information, I think it's actively dangerous to encourage people to use this. Edit: It might also be a stretch to call this a "burn-after-use" scheme: there's no affirmative proof of a note's destruction on the server side. It seems to just update the database to mark the note as empty and deleted[2]. [1]: https://github.com/GigaMick/burnernote/blob/6c01eddfc5195b15f3d44b1c6a935eb403cbd26a/app/Http/Controllers/NoteController.php#L23 https://github.com/GigaMick/burnernote/blob/6c01eddfc5195b15... [2]: https://github.com/GigaMick/burnernote/blob/6c01eddfc5195b15f3d44b1c6a935eb403cbd26a/app/Http/Controllers/NoteController.php#L50-L54 https://github.com/GigaMick/burnernote/blob/6c01eddfc5195b15...
- woodruffw 5y agoAnother update: it looks like it uses Laravel's encryption API under the hood, which does indeed perform encrypt-then-MAC[1]. So this is probably not vulnerable to a padding oracle attack. But that wasn't obvious from the description, and it gave me a decent fright :-) [1]: https://laravel.com/docs/8.x/encryption#encrypting-a-value https://laravel.com/docs/8.x/encryption#encrypting-a-value
- gigamick 5y agoSo are you saying this is a good thing? You think I should highlight this?
- woodruffw 5y agoIt's a very good thing that it isn't susceptible to that particular weakness, as that would have been a disastrous one. But there are a lot of things that are left to be desired about this setup: 1. Message secrecy and the soundness of the encrypt-then-MAC protection seem to be partially, if not completely, dependent on the `APP_KEY` that you generated and are currently running the service with. For all anyone knows, that `APP_KEY` is all zeroes or comes from a bad RNG source. A better scheme wouldn't introduce a fundamental dependency on untrusted server randomness. 2. Message deletion is unsound: I have no proof that a note being "deleted" means that it's actually purged from your storage. I'm decently sure proving that is actually impossible in the general case, which is another reason why it's dangerous to have the note's encryption handled on the server side. 3. The "password" functionality seems to just be a string comparison against a DB-stored password. It's not mixed into the secret material for encryption at all. It's hashed at least, which is good, but it doesn't look like it's salted, which is bad.
- gigamick 5y ago"there's no affirmative proof of a note's destruction on the server side. It seems to just update the database to mark the note as empty and deleted" Isn't updating the note to be empty and deleted enough? It is totally zapped. What else would you like to see here?
- woodruffw 5y agoMy point was that it's a claim that's impossible to formally prove: we don't really know how to do formal proofs of destruction, at least not with the scheme you're using. But even beyond that, there are a lot of weaknesses in this setup. I'll post a list of them in response to the other comment you left, since they'll be more relevant there. > What else would you like to see here? Frankly, you should either disable this service or put a big red banner on it explaining that it it (1) hasn't been audited, and (2) doesn't encrypt messages on the client side. As it is, people are going to make incorrect and potentially dangerous assumptions about the privacy of data they put on your service. Please don't take that as a personal rebuke, because it isn't! I just don't want you to be the most recent person in a long lineage of developers to be publicly burned for teaching themselves applied cryptography.