greenpau / caddy-security

🔐 Authentication, Authorization, and Accounting (AAA) App and Plugin for Caddy v2. 💎 Implements Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0 (Github, Google, Facebook, Okta, etc.), SAML Authentication. MFA/2FA with App Authenticators and Yubico. 💎 Authorization with JWT/PASETO tokens. 🔐
https://authcrunch.com/
Apache License 2.0
1.49k stars 73 forks source link

Insecure Randomness #265

Closed ahpaleus closed 11 months ago

ahpaleus commented 1 year ago

Severity: High

The caddy-security plugin uses the math/rand Golang library with a seed based on the Unix timestamp to generate strings for three security-critical contexts in the application, which could possibly be predicted via a brute-force search. Attackers could use the potentially predictable nonce value used for authentication purposes in the OAuth flow to conduct OAuth replay attacks. In addition, insecure randomness is used while generating multifactor authentication (MFA) secrets and creating API keys in the database package.

To immediately mitigate this vulnerability, use a cryptographically secure random number generator for generating the random strings. Golang’s library crypto/rand is designed for secure random number generation.

In addition to that fix, we recommend considering the following long-term recommendations:

More information about our public disclosure:

st3fan commented 1 year ago

@greenpau let me know if you accept contributions for this issue. I was reading the util code in go-authcrunch and I think it is relatively simple to convert it to use crypto/rand instead. I'm happy to give that a shot.

greenpau commented 1 year ago

@st3fan , please do! 😄 thank you for the offer!

gedw99 commented 1 year ago

Thos looks like a simple fix. Is anyone working on it ?

greenpau commented 1 year ago

@gedw99 , feel free to contribute!

greenpau commented 11 months ago

@ahpaleus , please see if the fix addresses your concerns.

greenpau commented 11 months ago

No activity. Closing.