[M-1] Client secrets hashed with unsalted SHA-256 and compared non-timing-safe #13

Closed
opened 2026-11-14 18:28:46 +01:00 by amiryahaya · 0 comments
Owner

Finding

hash_secret/1 is a plain unsalted SHA-256; verify_secret compares with == (length-first short-circuit).

Evidence

  • lib/mdid_ws/oauth/client_credentials.ex:24-30

Impact

Low-entropy secrets are rainbow-table reversible from the Mnesia file; marginal timing oracle.

Fix

  • Hash with a KDF (Plug.Crypto.scrypt / argon2, or HMAC-SHA256 with a server pepper from env)
  • Compare with Plug.Crypto.secure_compare/2

Line numbers refer to the initial import commit 282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).

## Finding `hash_secret/1` is a plain unsalted SHA-256; `verify_secret` compares with `==` (length-first short-circuit). ## Evidence - `lib/mdid_ws/oauth/client_credentials.ex:24-30` ## Impact Low-entropy secrets are rainbow-table reversible from the Mnesia file; marginal timing oracle. ## Fix - [ ] Hash with a KDF (Plug.Crypto.scrypt / argon2, or HMAC-SHA256 with a server pepper from env) - [ ] Compare with `Plug.Crypto.secure_compare/2` _Line numbers refer to the initial import commit `282cb11`. Source: comprehensive audit, 2026-11-12 (first review of this codebase)._
Sign in to join this conversation.
No description provided.