CVE-2024-58135

5.3 MEDIUM

📋 TL;DR

Mojolicious applications created with 'mojo generate app' from version 7.28 use weak HMAC session cookie secrets generated via Perl's insecure rand() function. This allows attackers to brute-force session keys, potentially hijacking user sessions. All Mojolicious applications created with the default generator in affected versions are vulnerable.

💻 Affected Systems

Products:
  • Mojolicious
Versions: 7.28 and later
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications created with 'mojo generate app' command; manually configured applications or those using strong custom secrets are not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers brute-force session secrets, hijack all user sessions, impersonate users, and potentially gain administrative access to the application.

🟠

Likely Case

Attackers compromise individual user sessions, leading to unauthorized access to user accounts and sensitive data.

🟢

If Mitigated

With strong custom secrets or patched versions, session integrity remains protected with minimal impact.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation involves brute-forcing weak secrets, which is straightforward with tools like hashcat; no authentication required.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Check Mojolicious repository for latest patched version

Vendor Advisory: https://github.com/mojolicious/mojo/pull/2200

Restart Required: Yes

Instructions:

1. Update Mojolicious to a patched version. 2. Regenerate session secrets in configuration files. 3. Restart the application server.

🔧 Temporary Workarounds

Manually Set Strong Session Secret

all

Replace the weak secret in the application's configuration file with a cryptographically strong secret.

Edit config file (e.g., myapp.conf) and set 'secrets' to a strong random string, e.g., secrets => ['your_strong_secret_here']

🧯 If You Can't Patch

  • Implement additional session validation mechanisms, such as IP binding or short session timeouts.
  • Use a web application firewall (WAF) to detect and block brute-force attempts on session cookies.

🔍 How to Verify

Check if Vulnerable:

Check if the application was created with 'mojo generate app' in Mojolicious 7.28+ and uses the default generated secret in configuration.

Check Version:

perl -MMojolicious -e 'print Mojolicious->VERSION'

Verify Fix Applied:

Verify that the configuration file contains a strong, custom secret or that Mojolicious has been updated to a version with the fix.

📡 Detection & Monitoring

Log Indicators:

  • Unusual spikes in failed session validation attempts or repeated cookie submissions.

Network Indicators:

  • High volume of requests to session-related endpoints with varying cookie values.

SIEM Query:

source="web_logs" AND (uri="/session" OR cookie="*mojolicious*") AND status=401|403 | stats count by src_ip

🔗 References

📤 Share & Export