MySQL Credential Harvesting from Application Configs
Application configuration files on the web server contain plaintext MySQL credentials used by the application to connect to the database. These credentials are separate from those stored in mysql.user — they are OS-level files readable through shell access or through MySQL's LOAD_FILE function when FILE privilege is present. The recovered credentials often have elevated database privileges compared to what the current MySQL session provides, and frequently reuse passwords across multiple services on the same host.
Read Config Files via LOAD_FILE
Target common CMS and framework configuration file locations. Start with the most widely deployed platforms:
define('DB_NAME', 'wordpress');
define('DB_USER', 'wpuser');
define('DB_PASSWORD', 'Sup3rS3cret!');
define('DB_HOST', 'localhost');
Search for Config Files via Shell Access
If shell access is available on the host, search the filesystem directly for configuration files containing MySQL credentials:
/var/www/html/wp-config.php /var/www/html/app/.env /var/www/backup/config.php
Read .env Files
Modern frameworks store database credentials in .env files which are often world-readable and contain all service credentials in one place:
/var/www/html/.env:DB_CONNECTION=mysql /var/www/html/.env:DB_HOST=127.0.0.1 /var/www/html/.env:DB_DATABASE=production /var/www/html/.env:DB_USERNAME=laraveluser /var/www/html/.env:DB_PASSWORD=LaravelProd2024!
Check MySQL Client Credential Files
Users who connect to MySQL frequently from the command line store credentials in .my.cnf files in their home directories to avoid typing passwords. These files contain plaintext credentials:
[client] user=root password=AdminPass123
Test Recovered Credentials
Test each recovered credential set against MySQL directly and against other services on the host:
References
-
MySQL — End-user password securitydev.mysql.com/doc/refman/8.0/en/password-security-user.html (opens in new tab)
.my.cnf credential file format and location reference
Was this helpful?
Your feedback helps improve this page.