Cloak / Cloak Ecto alternatives

I considered using Cloak and Cloak Ecto for encryption-at-rest but I noticed that both seem like abandonware these days. Moreover there are CVEs, one with severity rating high and unaddressed for almost a month now. Any suggestions for something well established and actively maintained instead?

I would just hand-roll an ecto type and use Erlang crypto module.

A dependency seams pretty excessive for this, also consider just encrypting the database itself.

Seems like quite an exaggerated CVE to me. Block ciphers in counter mode are unauthenticated ciphers by definition; the CVE is basically saying “that bicycle only has two wheels, it’s dangerously unstable”. So just take the car then: Cloak natively supports authenticated ciphers like AES-GCM perfectly fine and you can configure it to use those trivially.

Additionally, Cloak offers features that are tricky to get right when rolling your own type, notably key rotation. It is a pity that the lib seems abandoned, but maybe I would prefer forking it (temporarily) over rolling my own. On the other hand, if you just need the basic functionality, it is very doable like @Schultzer says. Just my two cents :wink:

if you do hand-roll it, id stick to the aead path in :crypto (aes_gcm) rather than plain ctr - the unauthenticated bit is basically the cve complaint

I wanted to maybe fork these libraries sometime soon or create a new compatible library. In addition to be abandonned, there are some painful things like the Vault configuration being a GenServer that doesn’t really make sens IMO, and the key rotation command is not made for production since it’s a mix task.

Sure, but key rotation is not that hard again, if you’re a working professional you should be able to do this as you’ve very likely encountered data integrity and inconsistency issues before.

Anyway it looks like Ecto is going to have something builtin going forward, another options is to use the database to encrypt columns.

It’s merged! Add Ecto.Encrypted and Ecto.HMAC by josevalim · Pull Request #4814 · elixir-ecto/ecto · GitHub

Yes, I’ve been considering this too (even initially included this idea when writing the post but then cut it out for brevity). This is of course an option, but – you know – with crypto stuff it’s always good to be able to point finger away from yourself in case :-)))

My concern is not so much about this particular CVE, which to my understanding can be easily mitigated with specific configuration. The concern is about the fact that it’s not being addressed at all for that long. Yes, it might be related, but this does not build confidence, does it?

Exactly what I meant a little above. I am sure I can do it. But in case… :wink:

Noticed that too and was actually scratching my head over it. I think I read something that explained why it is done this way, but can’t recall now.

Good to know! I’ll have an eye on Ecto updates then and see how this one fits. DB level encryption might be an option too, but I am usually reluctant to delegate things to DB without really cogent arguments.

Thanks to all who responded!