CVE-2024-58135: Mojolicious versions from 7.28 through 9.39 for Perl may generate weak HMAC session secrets
Breno Oliveira 03 May 2025 10:15 UTC
========================================================================
CVE-2024-58135 CPAN Security Group
========================================================================
CVE ID: CVE-2024-58135
Distribution: Mojolicious
Versions: from 7.28 through 9.39
MetaCPAN: https://metacpan.org/dist/Mojolicious
VCS Repo: https://github.com/mojolicious/mojo
Mojolicious versions from 7.28 through 9.39 for Perl may generate weak
HMAC session secrets
Description
-----------
Mojolicious versions from 7.28 through 9.39 for Perl may generate weak
HMAC session secrets.
When creating a default app with the "mojo generate app" tool, a weak
secret is written to the application's configuration file using the
insecure rand() function, and used for authenticating and protecting
the integrity of the application's sessions. This may allow an attacker
to brute force the application's session keys.
Problem types
-------------
CWE-338 Use of Cryptographically Weak Pseudo-Random Number Generator
(PRNG)
Workarounds
-----------
Ensure that your secret, stored in the application's configuration
file, is at least 128 bit of cryptographically secure random data. For
example, to generate a 256 bit secret, one could use the output
generated by the "openssl rand -base64 32" command.
As of version 9.39 of Mojolicious, if a CryptX distribution of version
0.080 or later is available in the include path before calling the
"mojo generate app" tool, then a secure 1024 bit long secret will be
generated.
References
----------
https://perldoc.perl.org/functions/rand
https://metacpan.org/release/SRI/Mojolicious-9.39/source/lib/Mojo/Util.pm#L181
https://metacpan.org/release/SRI/Mojolicious-9.38/source/lib/Mojolicious/Command/Author/generate/app.pm#L202
https://github.com/mojolicious/mojo/pull/2200
https://metacpan.org/release/SRI/Mojolicious-7.28/source/lib/Mojolicious/Command/generate/app.pm#L220
https://security.metacpan.org/docs/guides/random-data-for-security.html
https://github.com/hashcat/hashcat/pull/4090