1. Home
  2. Web App Vulnerabilities
  3. How to remediate – SQL Dump Files Disclosed via Web Server

How to remediate – SQL Dump Files Disclosed via Web Server

1. Introduction

The SQL Dump Files Disclosed via Web Server vulnerability means that database backup files are publicly available on a web server. This allows anyone to access sensitive data contained within these backups, potentially including usernames, passwords, and other confidential information. Affected systems typically include web servers running PHP, Apache, or IIS hosting applications connected to databases like MySQL, PostgreSQL, or SQL Server. A successful exploit could lead to the compromise of confidentiality, integrity, and availability of database contents.

2. Technical Explanation

The root cause is often insufficient access controls on files containing SQL dump data. These files are inadvertently left accessible via the web server’s document root without proper authentication or authorisation. An attacker can directly request these files from a web browser, downloading the database contents. There isn’t a specific CVE associated with this general issue as it represents a misconfiguration rather than a software flaw.

  • Root cause: Missing or incorrect file permissions on SQL dump files within the web server’s accessible directories.
  • Exploit mechanism: An attacker uses a web browser to request the URL of the publicly exposed SQL dump file, for example http://example.com/database_backup.sql.
  • Scope: Web servers (Apache, Nginx, IIS) hosting applications using databases such as MySQL, PostgreSQL, Microsoft SQL Server, and Oracle are affected.

3. Detection and Assessment

Confirming vulnerability involves checking for publicly accessible database dump files. A quick check is to browse the web server’s file system via a web browser. A thorough method is to use a web application scanner.

  • Quick checks: Use a web browser to attempt access common backup filenames like /database_backup.sql, /db_dump.sql or similar in the root directory of your website.
  • Scanning: Nessus plugin ID 10428 can identify publicly accessible SQL dump files (example only).
  • Logs and evidence: Web server access logs may show requests for database backup filenames from external IP addresses. Look for file extensions like .sql, .dump, .bak in the logs.
curl -I http://example.com/database_backup.sql

4. Solution / Remediation Steps

Fixing this issue requires restricting access to SQL dump files and ensuring they do not contain sensitive data.

4.1 Preparation

  • Dependencies: Access to the web server’s file system and configuration files is needed. Roll back by restoring the previous backups or reverting configuration changes.
  • Change window: Schedule a maintenance window for minimal disruption. Approval from IT security may be required.

4.2 Implementation

  1. Step 1: Move SQL dump files outside of the web server’s document root to a secure location with restricted access.
  2. Step 2: Configure the web server to deny direct access to any files with .sql, .dump or .bak extensions.
  3. Step 3: If database dumps are required for testing, ensure they are anonymised and only accessible by authorised personnel.

4.3 Config or Code Example

Before

# Apache .htaccess file (example)
<FilesMatch ".(sql|dump)$">
  Allow from all

After

# Apache .htaccess file (example)
<FilesMatch ".(sql|dump)$">
  Require valid-user

4.4 Security Practices Relevant to This Vulnerability

Several security practices can prevent this issue.

  • Practice 1: Least privilege – restrict access to sensitive files and directories to only those who need it.
  • Practice 2: Secure defaults – configure web servers with restrictive default permissions, preventing public access to configuration and data files.

4.5 Automation (Optional)

If suitable, provide a small script or infrastructure code that applies the fix at scale. Only include if safe and directly relevant.

# Example Bash script to deny access to .sql files in Apache config
sed -i 's/Allow from all/Require valid-user/' /etc/apache2/sites-available/*.conf

5. Verification / Validation

Confirming the fix involves checking that SQL dump files are no longer accessible via a web browser.

  • Post-fix check: Attempt to access the previously exposed database dump file using a web browser. Expect a 403 Forbidden error or similar authentication prompt.
  • Re-test: Repeat the quick check from Section 3, ensuring that attempts to access backup filenames now result in an error.
  • Monitoring: Monitor web server logs for any failed requests attempting to access .sql or .dump files (example only).
curl -I http://example.com/database_backup.sql

6. Preventive Measures and Monitoring

Preventing this issue requires ongoing security measures.

  • Baselines: Update your web server security baseline to include restrictive file permissions and access controls.
  • Pipelines: Implement static code analysis (SAST) tools in your CI/CD pipeline to identify potential vulnerabilities related to sensitive data exposure.
  • Asset and patch process: Regularly review web server configurations for misconfigurations and apply necessary patches promptly.

7. Risks, Side Effects, and Roll Back

Applying the fix may cause temporary service disruption if incorrectly configured.

  • Risk or side effect 2: Web server restart may be required, causing brief downtime. Mitigation: Schedule during a maintenance window.
  • Roll back: Restore the previous web server configuration files and database backup if necessary. Revert any changes made to .htaccess files or other access control settings.

8. References and Resources

  • Vendor advisory or bulletin: Check your web server vendor’s security documentation for best practices on file access control.
  • NVD or CVE entry: This is a configuration issue, so there isn’t a specific NVD/CVE entry.
  • Product or platform documentation relevant to the fix: Apache HTTP Server documentation on .htaccess files: https://httpd.apache.org/docs/2.4/howto/access.html
Updated on December 27, 2025

Was this article helpful?

Related Articles