Looking for the vulnerability index of Invicti's legacy products?
MySQL username disclosure - Vulnerability Database

MySQL username disclosure

Description

When a MySQL database connection fails, the server may return detailed error messages that include sensitive information such as the MySQL username and hostname used in the connection attempt. This information disclosure occurs when error reporting is enabled in production environments and the application does not properly handle database connection failures. While the vulnerability itself does not grant unauthorized access, it exposes internal system details that should remain confidential in production deployments.

Remediation

Implement the following measures to prevent MySQL username disclosure:

1. Disable detailed error messages in production: Configure PHP to suppress error output by setting the following in php.ini or application configuration:

display_errors = Off
log_errors = On
error_log = /path/to/secure/error.log

2. Implement custom error handling: Use try-catch blocks or custom error handlers to intercept database connection failures and display generic error messages:
try {
    $conn = new PDO($dsn, $username, $password);
} catch (PDOException $e) {
    // Log detailed error securely
    error_log($e->getMessage());
    // Display generic message to users
    die('Database connection error. Please contact support.');
}

3. Verify database connectivity: Ensure MySQL connection parameters are correct and the database service is accessible from the application server.

4. Review error logging: Confirm that detailed error information is logged to secure files accessible only to authorized administrators, not exposed to end users.

Related Vulnerabilities