don't serve hidden files from Nginx
The web server was configured to serve hidden files, allowing anyone to download a file such as .gitignore. An attacker could use this to access sensitive hidden files that might be present in the future.
- Triaged in 14 days
- Fixed in 4 months
- Paid in 30 days
- Disclosed after 4 months
Hi Gratipay team,
I noticed that your nginx setting is not secure.
When you input https://grtp.co/.gitignore in your browser, it will download this hidden file. Even though this file does not contain some sensitive files, we still need to change nginx settings like bellow to forbid future hidden files being downloaded.
The following code would deny any request to hidden files
location ~* .*/\..* {
return 403;
}
The following code can block sensitive files using nginx
location ~ /(\.ht|\.git|_cron|_setup|_data|_tpl|_tmp|_log|_library|\.idea) {
deny all;
}
Hope you do your business well. Have a good day.
Rds jsshen
What the report shows
The target is Gratipay, and the researcher's finding is a web server configuration problem rather than an application flaw. The report opens by stating plainly that the nginx configuration is not secure.
The demonstration is a single request. Navigating to the following URL in a browser causes the server to hand back a hidden file:
https://grtp.co/.gitignore
Instead of refusing the request, nginx serves the file as a download. The researcher is careful about the significance of this particular file: it does not contain sensitive data, so the disclosure itself is minor. The point is the pattern. If nginx will serve .gitignore, it will serve whatever other dotfiles end up in the web root, and some of those can be far more damaging.
Root cause
The report attributes the behaviour to an insecure nginx configuration and asks for settings that forbid hidden files. Dotfiles are ordinary files on disk, so a configuration without a deny rule can return them. Without a deny rule, a request for /.gitignore resolves to a real file on disk and is returned.
The researcher frames this as a settings problem to be corrected rather than a single file to be deleted.
Impact
In this instance the exposed file was .gitignore, which the researcher says holds nothing sensitive. The researcher asks for settings that forbid future hidden files from being downloaded. Version control metadata, editor and IDE directories, environment files and deployment scripts are the kinds of artefacts that commonly sit alongside application code, and a server that serves one dotfile will serve those too. The report does not claim any of them were reachable here.
How this kind of bug works
Web servers map a URL path onto the filesystem under a document root. Static file serving is deliberately dumb: if the resolved path exists and the server is permitted to read it, the file is returned. Frameworks and application routers never see the request, so authentication, authorisation and input validation in the application are all bypassed.
Dotfiles and dot-directories are a special case because they are usually not meant for public consumption but are frequently present in deployed code. A .git directory left in a web root can allow reconstruction of source code; .env files often carry credentials; .htaccess, .htpasswd, backup files and editor swap files can leak configuration or source. The bug class is therefore less about any one file and more about a missing default-deny for a whole category of paths.
The researcher proposes a server-level location rule that returns 403 for paths containing a dot-prefixed segment. A second rule blocks a list of known sensitive names and directories. Deployment hygiene matters too: build artefacts and version control metadata should never be copied into the document root in the first place.
How to test for it
- Identify the web server and its document root behaviour. Response headers, error page styling and the way unknown paths are handled often reveal nginx, Apache or a framework dev server.
- Request well-known dotfiles directly:
.git/config,.git/HEAD,.gitignore,.env,.htaccess,.htpasswd,.svn/entries,.DS_Store,.idea/workspace.xml. Also try common backup and swap variants of known files. - Try dot-directories as well as dotfiles. A directory listing or a readable file inside
.gitis a stronger finding than a single ignored file. - Watch the status code and body. A 200 with file content is a positive result. A 403 or 404 is a negative. A 200 that returns the application's HTML shell is a soft 404 and not a finding.
- Check whether the same path is reachable under alternate roots, subdomains and static asset hosts, since configurations often differ per virtual host.
Common false positives: custom error pages that return 200 for everything, single-page applications that route all paths to index.html, and CDNs or WAFs that rewrite responses. Confirm the body is genuinely the file you asked for before reporting. Also avoid reporting a dotfile whose contents are already public, such as a .gitignore copied from an open-source repository, unless you can show a broader exposure.
How it is fixed
The researcher proposed two nginx rules. The first denies every request whose path contains a dot-prefixed segment:
location ~* .*/\..* {
return 403;
}
The second blocks a list of known sensitive names and directories:
location ~ /(\.ht|\.git|_cron|_setup|_data|_tpl|_tmp|_log|_library|\.idea) {
deny all;
}
Beyond these rules, the standard fixes are to remove version control metadata and other development artefacts from the deployed document root, to keep secrets outside the web root entirely, and to review the server configuration whenever new static directories are added.
Hunting notes
This bug class hides wherever static files are served from a directory that also contains development artefacts: application roots, upload directories, documentation folders and anything deployed by copying a working tree. Recon signals include nginx or Apache banners, static asset hosts that serve files directly, and repositories whose public source suggests a conventional layout. Directory brute-forcing with a wordlist of dotfiles and dot-directories is cheap and effective.
If the file is benign, say so and frame the finding as a configuration gap that will expose future files, as this report does.
What happened, in plain words
Gratipay is a website, and like most websites it is run by a web server program called nginx. A web server is the piece of software that sits in front of a site and hands files to whoever asks for them: when your browser requests a page, nginx finds the matching file on the computer's disk and sends it back. The researcher, jsshen, found that the nginx configuration was not secure and served a hidden file.
The demonstration is a single request. Typing this address into a browser makes the server hand back a hidden file:
https://grtp.co/.gitignore
A file whose name starts with a dot, like .gitignore, is called a dotfile. On Linux and similar systems, dotfiles are treated as hidden: they do not show up in a normal directory listing, and they are usually housekeeping files rather than content meant for visitors. The .gitignore file is a small text file that tells a version control tool called Git which files to ignore. It is not a secret in itself, and the researcher says so plainly: this particular file contains nothing sensitive. The problem is the pattern. If nginx will serve .gitignore, it will serve any other dotfile that ends up in the same folder, and some of those can be far more damaging.
The report was filed as an Information Disclosure issue, meaning the bug is that information the site did not intend to share can be read by outsiders.
Why it happens
A web server has a folder on disk called the document root. Every URL is translated into a path inside that folder: a request for /about.html becomes a request for the file about.html in the document root. This is deliberately simple. If the file exists and the server is allowed to read it, the server sends it back. The application code, with all its login checks and permission rules, is never consulted, because the request never reaches it.
Dotfiles are ordinary files as far as nginx is concerned. Unless the configuration refuses them, a request for /.gitignore points at a real file on disk and the file is downloaded. The researcher framed the issue as a settings problem to be corrected rather than a single file to be deleted.
What could go wrong
In this case the exposed file was harmless. The researcher asks for settings that forbid future hidden files from being downloaded. Version control metadata, editor and IDE folders, environment files and deployment scripts are the kinds of things that commonly sit next to application code, and a server that serves one dotfile will serve those too. The report does not claim any of them were reachable here.
In general, how this kind of bug works
This class of bug is about a server handing out files that were never meant for the public. It is worth knowing why dotfiles matter so much:
- A
.gitfolder left in a web root can let someone reconstruct the source code of the site. .envfiles often hold credentials such as database passwords..htaccessand.htpasswdcan leak configuration or password hashes.- Backup files and editor swap files can contain copies of source code.
The lesson is less about any single file and more about a missing default: the server should refuse a whole category of paths unless there is a reason to allow them.
The researcher proposes a server-level rule that returns 403 for paths containing a dot-prefixed segment. A second rule blocks a list of known sensitive names and directories. Good deployment habits matter too: build artefacts and version control metadata should never be copied into the document root in the first place.
In general, how to test for it
- Work out which web server is running and how it treats unknown paths. Response headers, the look of error pages and the way missing pages are handled often reveal nginx, Apache or a development server.
- Request well-known dotfiles directly:
.git/config,.git/HEAD,.gitignore,.env,.htaccess,.htpasswd,.svn/entries,.DS_Store,.idea/workspace.xml. Also try common backup and swap variants of known files. - Try dot-directories as well as dotfiles. A readable file inside
.gitis a stronger finding than a single ignored file. - Watch the status code and the body. A 200 with file content is a positive result. A 403 or 404 is a negative. A 200 that returns the site's normal HTML page is a soft 404, meaning the server says "found" but really just shows the usual page, and that is not a finding.
- Check whether the same path is reachable under other domains, subdomains and static asset hosts, because configurations often differ from one virtual host to the next.
Common false positives: custom error pages that return 200 for everything, single-page applications that route every path to index.html, and content delivery networks or web application firewalls that rewrite responses. Confirm the body really is the file you asked for before reporting. Also avoid reporting a dotfile whose contents are already public, such as a .gitignore copied from an open-source repository, unless you can show a broader exposure.
In general, how it is fixed
The researcher proposed two nginx rules. The first denies every request whose path contains a dot-prefixed segment:
location ~* .*/\..* {
return 403;
}
Line by line: location starts a rule that matches request paths. ~* means the match is a regular expression and is case-insensitive. .*/\..* describes a path that contains a slash followed by a literal dot (the backslash makes the dot literal rather than "any character") and then anything. return 403 sends the forbidden status instead of the file. In short: anything hidden gets refused.
The second blocks a list of known sensitive names and directories:
location ~ /(\.ht|\.git|_cron|_setup|_data|_tpl|_tmp|_log|_library|\.idea) {
deny all;
}
Here the regular expression lists specific names: .ht (covering .htaccess and .htpasswd), .git, and a set of underscore-prefixed folders such as _cron, _setup, _data, _tpl, _tmp, _log and _library, plus the .idea editor folder. The vertical bars mean "or". deny all refuses every request that matches. This is a narrower safety net for names that are known to be risky.
Beyond these rules, the standard fixes are to remove version control metadata and other development artefacts from the deployed document root, to keep secrets outside the web root entirely, and to review the server configuration whenever new static folders are added.
In general, where to look for it
This bug class hides wherever static files are served from a folder that also contains development artefacts: application roots, upload folders, documentation folders and anything deployed by copying a working tree. Signals worth noticing include nginx or Apache banners, static asset hosts that serve files directly, and public source code that suggests a conventional layout. Trying a wordlist of dotfiles and dot-directories is cheap and effective.
If the file is benign, say so and frame the finding as a configuration gap that will expose future files, as this report does.
Glossary
- nginx: a popular web server program that receives browser requests and returns files or passes them to an application.
- Web server: software that listens for requests from browsers and sends back the requested content.
- Document root: the folder on disk from which a web server serves files; URLs map onto paths inside it.
- Dotfile: a file whose name begins with a dot, hidden from normal directory listings and usually used for configuration or housekeeping.
.gitignore: a text file that tells the Git version control tool which files to ignore.- Git: a version control tool that tracks changes to source code.
- Request: a message a browser sends to a server asking for a page or file.
- Response: the server's reply, including a status code and usually a body.
- Status code: a three-digit number describing the outcome, such as 200 (OK), 403 (forbidden) or 404 (not found).
- 200: the status meaning the request succeeded and the content follows.
- 403: the status meaning the server understood the request but refuses to serve it.
- 404: the status meaning the requested resource does not exist.
- Soft 404: a response that returns 200 but actually shows a generic page instead of the requested file.
- Information Disclosure: a vulnerability class where information the site did not intend to share can be read by outsiders.
- Severity: a rating of how serious a bug is, here low.
- Bounty: a payment made to a researcher for reporting a valid bug.
- Virtual host: a configuration that lets one server answer for several domain names, each with its own settings.
- Content delivery network (CDN): a network of servers that caches and serves content close to users.
- Web application firewall (WAF): a filter that inspects traffic and can block or rewrite suspicious requests.
- Regular expression: a pattern language for matching text, used here to describe which paths a rule applies to.
- False positive: a result that looks like a bug but is not one.