Exposed backups
| Class | Security misconfiguration |
|---|---|
| Also known as | Old, backup and unreferenced files (OWASP testing guide) |
| CWE | CWE-530: Exposure of Backup File to an Unauthorized Control Sphere |
| OWASP Top 10 | A02:2025 Security Misconfiguration |
| Typical severity | High |
| Affects | Web servers that serve every file in a folder, and cloud storage reachable by a public link |
A web server hands out whatever sits in the folder it serves, and cloud storage open without sign-in does the same for its files. An exposed backup is a backup file left in one of those places, where anyone who asks for it can download it.1 Read access to the file was never restricted,2 and the cause is usually a setting, such as open cloud storage permissions or a directory listing left on.3
Description
Backup copies on a web server usually come from one of four places: a file copied to a new name such as file.old, the automatic copy an editor writes while a file is open (Emacs saves file~), a folder packed into a .tar, .zip or .gz archive and left in place, and snapshots that the file system takes on its own schedule, which can appear under paths such as /.snapshot/monthly.1/.4 The renaming can be done by the web server itself as well as by an administrator, often with an extension such as .BAK or .~bk.1 A database dump written to the web root belongs to the same class.
The second location is cloud storage. Sharing permissions open to the whole internet are a known cause of data exposure, and storage permissions such as those on S3 buckets need regular review.3 A backup uploaded to a bucket that serves files publicly, or shared through a signed link with too wide a scope, is exposed in the same way as a file in the web root. Public cloud storage bucket covers the bucket settings in detail.
Mechanism
A web server decides how to handle a request from the file's extension. A file named config.php is passed to the PHP interpreter, and the visitor receives only its output. A copy named config.php.bak has an extension the server does not map to PHP, so the server returns its contents as a plain file. The same holds for login.asp and login.asp.old: the first runs, the second comes back as text.4 The source code reaches the browser together with any database password written in it.
GET /config.php HTTP/1.1 -> output of the script
GET /config.php.bak HTTP/1.1 -> the script's source codeAn attacker does not need a link to the file. Automated tools request common names in turn, and for each known file try the extensions ~, bak, old, orig, tmp, swp and others before, after and in place of the real extension.4 A Disallow: /backup line in robots.txt or an open directory listing points them to the files directly.
Impact
The attacker gets everything the file contains. A copied script shows the database calls, the parameters the application accepts and the structure of the site.1 A full archive can hold every file of the application, including files outside the web root, so the attacker can read the whole code base and search it for flaws offline. An old copy may also still contain a vulnerability that the current version fixed.4 A database dump contains the stored records themselves.
Notable incidents
On 20 July 2020 a Microsoft AI research team published a storage URL in the public GitHub repository robust-models-transfer so that readers could download image recognition models.5 The URL carried a Shared Access Signature (SAS) token for an internal Azure storage account.6 Wiz Research found that the token covered the entire account with "full control" permissions, and that its expiry had been moved to 6 October 2051. The account held 38 TB of further data, including a disk backup of two employees' workstations with passwords, private keys and over 30,000 internal Teams messages.5 Wiz reported the token on 22 June 2023 and Microsoft revoked it on 24 June. Microsoft stated that no customer data was exposed and that Azure Storage itself had no vulnerability. Its own repository rescan had flagged the URL earlier, but the finding was marked as a false positive.6
Detection
On the server, list the files in the web root whose names end in a backup extension or contain an archive or dump format, and repeat the search as a scheduled background job.4
find /var/www -type f \( -name "*.bak" -o -name "*.old" -o -name "*.orig" \
-o -name "*~" -o -name "*.swp" -o -name "*.sql" -o -name "*.zip" -o -name "*.tar.gz" \)From outside, request the site's own file names with backup extensions added. A 200 response suggests the file exists, unless the server answers missing pages with 200 and a custom page.4
Prevention
Write backups and dumps to a folder outside the web root or to private storage, and delete archives after the transfer. Avoid editing files in place on a production server, because editors leave copies behind.4
nginx
A location block with the ~* modifier matches a regular expression without regard to case, and nginx uses the first matching expression in the order they appear in the file.7 deny all refuses every client.8 Place the block before other regular-expression locations, such as the one that passes .php files on:
location ~* \.(bak|old|orig|swp|tmp|sql|tar|gz|zip)$ {
deny all;
}
location ~ ~$ {
deny all;
}Directory listing is off by default (autoindex off); keep it off.9
Amazon S3
New buckets and objects do not allow public access, but bucket policies and object permissions can be changed to allow it. Block Public Access settings override those changes and work best when set for the whole account.10 For one bucket:
aws s3api put-public-access-block \
--bucket amzn-s3-demo-bucket \
--public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"After the 2023 incident, Microsoft's advice for signed links was to limit each one to the smallest set of files and an expiry of one hour or less.6 Wiz suggested keeping data meant for sharing in a storage account of its own.5
Prompt for a coding agent
Search this project and its deployment for backup and dump files inside any folder the web server or hosting platform serves: names ending in .bak, .old, .orig, .swp, .tmp or ~, and .sql, .zip, .tar or .gz files. List each one with its path. Check every script that writes a backup or database dump and change its output folder to one outside the served folder. If the project has an nginx configuration, add a location block that denies requests for those extensions, placed before the other regular-expression locations. Do not delete any file; list what you found and what you changed.
In SecFlash
SecFlash reports a backup or old copy of a file served from the site as SF-SEC-618 on the Security page. On the Exposure page it reports a readable configuration backup as SF-EXP-308, backup archives as SF-EXP-412, database dumps as SF-EXP-413 and other backup, log or settings files as SF-EXP-411. A directory listing that can reveal such files is reported as SF-SEC-615.
See also
- Exposed sensitive files
- Public cloud storage bucket
- Database dumping
- Backup and restore
- Path traversal
- Category: Security misconfiguration
References
- a b c "CWE-530: Exposure of Backup File to an Unauthorized Control Sphere". Common Weakness Enumeration. MITRE.
- back "A01:2025 Broken Access Control". OWASP Top 10:2025. OWASP Foundation.
- a b "A02:2025 Security Misconfiguration". OWASP Top 10:2025. OWASP Foundation.
- a b c d e f g OWASP (2020). "Review Old Backup and Unreferenced Files for Sensitive Information (WSTG-CONF-04)". OWASP Web Security Testing Guide v4.2.
- a b c Wiz Research (September 2023). "38TB of data accidentally exposed by Microsoft AI researchers". Wiz Blog.
- a b c Microsoft Security Response Center (18 September 2023). "Microsoft mitigated exposure of internal information in a storage account due to overly-permissive SAS token". MSRC Blog.
- back "Module ngx_http_core_module: location". nginx documentation.
- back "Module ngx_http_access_module". nginx documentation.
- back "Module ngx_http_autoindex_module". nginx documentation.
- back Amazon Web Services. "Blocking public access to your Amazon S3 storage". Amazon S3 User Guide.
External links
- CWE-552: Files or Directories Accessible to External Parties, Common Weakness Enumeration