Ultimate Guide To Cache Hit Rate Optimization
Want faster website performance and lower costs? Start ...




An exposed .git directory is the cheapest entry point on your attack surface. Three unauthenticated GET requests, no exploit, no payload, and you have the complete history of every file the project has ever contained.
That framing matters because most teams file this under "misconfiguration" and move on. It is not a misconfiguration in the ordinary sense, where you fix the setting and the problem goes away. A .git directory is a content-addressed, append-only database. It is a receipt. Every version of every file you ever committed is still in there, named by the SHA-1 hash of its own contents, and it stays reachable as long as those objects exist on disk.
A garage door left open is a misconfiguration. You close it and the contents are private again. An exposed .git directory is closer to a filing cabinet that photographed every draft you ever wrote and left the negatives in a public lobby. Closing the lobby door does not unphotograph the drafts.
Security work is priced in attacker effort, and this is the cheapest thing on the menu. Compare four ways into a web application:
.git directory needs a browser. Or curl. Or a tool that already exists and is documented in a five-minute tutorial.That last one is why the pattern recurs. There is no reconnaissance phase, no fingerprinting, no exploit chain. The path is fixed and public knowledge, and the response either contains Git metadata or it does not. A scanner can check millions of hosts for this because checking is trivial.
The reason it is catastrophic rather than merely embarrassing is what sits inside. Application source code, on its own, is often not the prize — well-built software does not become vulnerable just because someone read it. The prize is the configuration that travelled with it: connection strings, API tokens, private keys, and deployment credentials that were typed into a file once and then committed.
The instinct after discovering a committed credential is to remove it and push. That instinct fails, and the reason is structural rather than procedural.
Git does not store files and folders. It stores a database of objects, each identified by the SHA-1 hash of its contents, and there are three types that matter here:
| Object | What it is | Why it defeats a "delete and push" fix |
|---|---|---|
| Blob | A file's contents, with no filename attached | The old version of your config file is a distinct blob with its own hash. It is still in the object database. |
| Tree | A directory listing, mapping filenames to other trees or blobs | Each commit points to its own tree. An old tree still maps your config filename to the old blob. |
| Commit | A snapshot pointer: metadata plus a link to the previous commit | The commit that introduced the secret is reachable from its own parent, forever, unless objects are deliberately expired. |
So when you delete a hardcoded credential from the current version of a file and commit the change, you have appended a snapshot in which the file is absent. You have not touched the blob that contains the credential, or the tree that references it, or the commit that introduced it. Anyone reading the repository history can walk backwards from the current state and retrieve all three.
This is not an obscure corner. It is the normal case, and it is where the highest-impact findings come from. Attack-surface research published by Intruder in August 2026, which scanned 3.5 million live hosts, describes walking the entire commit history rather than only the current state — "a common mistake, and frequently where the most impactful leaks are found." A credential removed in a later commit is not a mitigated credential.
Three things make it worse:
.git folder sitting in your web root.Git does eventually collect unreachable objects, but the defaults are far more forgiving than people assume. Three parameters define the recovery window, and the numbers are worth knowing because they are what an investigator is racing against:
| Setting | Default | What it governs |
|---|---|---|
| gc.reflogExpire | 90 days | How long the branch reflog retains entries for reachable commits |
| gc.reflogExpireUnreachable | 30 days | How long reflog entries for commits that are no longer reachable are retained |
| gc.pruneExpire | 2 weeks | How long an unreachable object survives before garbage collection may delete it |
The security reading of that table is the opposite of the developer reading. A developer sees ninety days of protection against their own mistakes. An attacker sees ninety days in which a credential that was "removed" is still retrievable from a server they have already read.
The common defence is to assume the exposure only matters if directory listing is enabled. It almost never is, and it does not matter.
Git stores its own roadmap. The tools built for this problem work by trying a fixed sequence of paths that Git necessarily creates, rather than browsing a folder. The published description of how one such scanner works lists the sequence plainly: HEAD, which points to the currently checked-out branch; packed-refs, which stores branch and tag pointers compactly once a repository accumulates enough of them; guessed branch names such as main, master and develop; and reflogs, which retain commit hashes for commits that no branch currently references.
That last entry is the one that turns a tidy repository into an untidy one. A reflog is Git's local record of where branches have pointed over time, and it survives the branch itself. A commit on a branch that was deleted, or on a branch whose history was rewritten to remove a secret, can still be reachable through the reflog — which is exactly why the 90 and 30 day figures above matter.
Once the scanner has any starting hash, the rest is arithmetic. It fetches a commit, reads the parent hash out of it, queues that one, and repeats. Dissimilar commits share most of their objects, and because objects are addressed by content hash, an unchanged file resolves to the same hash in every commit and is fetched once regardless of how many commits or branches point at it. The cost of reconstructing an entire project is far lower than the cost of reading it one file at a time.
If the exposure stops at source code, the damage is bounded by how much the code reveals. The damage escalates in one specific file.
.git/config holds repository configuration, including the definitions of remote repositories. Credentials habitually end up inside those remote URLs, in three recurring patterns: basic authentication embedded directly in a URL, automation accounts created for CI/CD and then reused across environments, and access tokens that were meant to be short-lived and were never rotated.
This is the line between exposed metadata and direct unauthorised access. Reading a repository tells an attacker what your code does. Reading .git/config tells them how to reach the systems it talks to, and sometimes hands them the key.
Current research puts rough proportions on it. An internet-wide study published in February 2026 counted 4,964,815 IP addresses serving publicly accessible .git structures, with 252,733 of them — about 5.09% — carrying deployment credentials inside .git/config. Treat those as the researchers' own counts: the study is a single-vendor figure and did not publish its scan dates or verification method. The order of magnitude is what matters, and it is corroborated by independent scanning.
The scale stopped being anecdotal this year. Four separate efforts, from four organisations, using four different methods, landed on the same conclusion.
| Source and date | Scope | Finding |
|---|---|---|
| Intruder, August 2026 | 3.5 million live hosts, filtered from 40 million candidate subdomains | 28,000 exposed repositories; 400+ AWS access keys, 107 Stripe secret keys, 123 OpenAI keys, 80 Telegram tokens, 17 GitHub personal access tokens. Many credentials were still active at validation. |
| Mysterium VPN, February 2026 | Internet-wide scan of servers exposing Git metadata | 4,964,815 IP addresses; 252,733 (about 5.09%) with credentials in .git/config; 34.70% of the exposure concentrated in the United States. |
| GitGuardian, 10 November 2026 | Public GitHub repositories carrying Claude Code artefacts | 23,276 repositories, 31,088 plaintext secrets, of which 5,343 (17%) were still valid at detection. |
| Apiiro, 5 November 2026 | 104,185 public .claude/settings.local.json files |
1,122 files contained live credentials — database passwords, API tokens, private keys — across 2,539 real credentials and 63 organisations. |
The two November findings deserve attention for a reason beyond their size. They are both cases where the credential reached the repository through a tool, not through a developer's decision to paste a password into a file.
When an agentic coding tool asks for permission to run a shell command and the answer is "yes, and don't ask again", that approval is recorded in a project-local settings file. If the command contained a credential, the credential is now in the file, and the file is in the project, and the project is in Git. No one made a mistake in the sense of forgetting to be careful. The workflow did what it was told.
This is the same pattern as the older, less exotic version: a deployment script that embeds a token in a remote URL because that was the path of least resistance on the day it was written. The mechanism differs; the receipt is identical.
Secret scanning is necessary and insufficient, and there is a specific number that shows why.
Among the 1,122 Apiiro-identified files containing live credentials, 215 were missed by gitleaks and TruffleHog — two of the most widely deployed open-source detectors. That is roughly one in five, from tools that were pointed at exactly the file that contained the problem.
Detection rules match shapes. A modern AWS key, a Stripe key, a GitHub token: these have signature formats and entropy that detectors find reliably. A database password in a connection string does not. Neither does an internal service account password, a symmetric key, or a custom token format your company invented. Nor does a credential that appears in a URL as a reusable automation account — it looks like configuration, because it is configuration.
And scanning the working tree misses the case this article is about. A detector that reads the current state of a file finds nothing if the secret was removed three commits ago. Only history-aware scanning answers the question the exposure actually poses.
Blocking the path at the web server is the correct first action, and it is genuinely one line. It is also where a specific, predictable failure lives.
The direct approach is a location block that denies anything beginning with a dot. The problem is that ACME's HTTP-01 challenge — the mechanism Let's Encrypt and most certificate authorities use to prove you control a domain — serves its validation token from a dot-directory. A naive deny rule takes down certificate renewal at the same moment it closes the exposure.
This is not a rare collision. It is the standard shape of the rule, and it fails quietly: the site keeps working, and the problem surfaces weeks later when the certificate fails to renew. The mitigation is to give the challenge path an exception that outranks the deny rule — in nginx, a prefix match carrying the ^~ modifier, so the longest prefix match short-circuits regular-expression evaluation before the dotfile rule can apply.
Failures of this kind are well covered elsewhere. A 403 that is not actually a permissions problem has six common causes, and a certificate that renews correctly but is never deployed fails in a different way again — both are documented in the posts linked at the end of this article. The point here is narrower: the fix for an exposed .git directory has a footgun, and the footgun costs you the thing the exposure made you think about.
Order matters because some of these actions are cheap and reversible, and one of them is expensive and unavoidable. Working from cheapest to most disruptive:
| # | Action | What it actually fixes | Cost |
|---|---|---|---|
| 1 | Deny dotfile paths at the web server, with an explicit exception for the ACME challenge path | New reads of .git, .env, .svn and every other dot-path in the web root |
Minutes; verify certificate renewal afterwards |
| 2 | Exclude version-control directories from build and deploy artefacts | The root cause. The directory never reaches the web root, so the rule above becomes a second layer rather than the only one | One pipeline change, then it holds |
| 3 | Scan the full history, not the working tree | Whether a credential was ever committed, regardless of whether it is still in the current file | Hours of CI configuration |
| 4 | Rotate every credential that could have been in the history | The exposure itself. Nothing else does | Real work, and it is the only step that is not optional |
| 5 | Check access logs for prior enumeration | Whether you are responding to an exposure or a compromise | Minutes, if you retained the logs |
Two details are easy to get wrong. First, deleting the repository or the .git directory from the server stops future reads and does nothing about past ones, so it does not change whether step 4 is necessary. Second, the indicator to look for in step 5 is a sequence rather than a single request: requests to .git/HEAD, .git/config and .git/index close together, followed by bulk requests under .git/objects/ from the same client. A lone 404 for a dotfile is background noise on any public host. That pattern is not.
Step 1 is one line of configuration, which is precisely why it gets applied and never verified. The rule is usually tested with a request to a URL that is not in the deny path, or by reloading the config and reading the absence of an error as success.
What actually needs proving is three separate things, and only one of them is the obvious one. The deny rule has to return a denial for real dot-paths. The exception has to leave ACME validation reachable, which means testing a request to a challenge path and confirming it is not swallowed by the deny rule. And the renewal that depends on that path has to still complete — which cannot be checked by reading a config file at all, because the failure appears at the certificate authority, weeks later.
That is a set of tests that belongs on a real server with a real web server configuration, not in a container that has been trimmed to the application. The behaviour being verified is the interaction between a server rule, a rate-limited external validation service, and a certificate store — and the ordering of nginx location matching is exactly the kind of thing that behaves differently from how it reads.
This is the narrow case for a short-lived trial environment rather than a permanent one: the work is a configuration change you intend to verify once, on the same web server stack you run in production, before it reaches production. A three-day or seven-day instance is enough to test the deny rule, the exception, and a certificate renewal cycle against a real domain, and then you discard it. The alternative — applying the rule in production and discovering the certificate problem six weeks later — is the more expensive way to run the same test.
SurferCloud's trial programme covers exactly that shape of work: a real environment, at 17-plus global data centres, with the standard platform protections — intrusion detection, vulnerability patching, DDoS protection and network isolation — present so that a verification run is not testing against a configuration you would never deploy.
| Plan | Bandwidth | Traffic | 3-day | 7-day |
|---|---|---|---|---|
| 2C 2G | 5/10 Mbps | Unmetered | $1.9 (list $5.63) | $3.9 (list $13.16) |
| 2C 4G | 10/20 Mbps | Unmetered | $4.9 (list $12.95) | $6.9 (list $30.24) |
| 4C 8G | 20/50 Mbps | Unmetered | $5.9 (list $29.74) | $10.9 (list $69.42) |
| 8C 16G | 50/100 Mbps | Unmetered | $14.9 (list $76.07) | $24.9 (list $177.52) |
The terms are worth reading before you plan around them, because two of them shape how you use the environment. The offer is limited to one purchase per user, one unit per purchase, and it does not support changing region or availability zone after ordering, nor scaling the configuration up or down. So the plan you pick is the plan you are testing on for the duration — pick the size that matches the web server you actually run, not the smallest one available.
One node-specific detail: São Paulo and Dubai come with a 20 GB default system disk, while every other node comes with 40 GB. The disk can be expanded up to 500 GB after ordering, and additional data disks can be attached. All plans use data-centre IPs with no replacement option, and port 25 is blocked by default. Default usernames vary by image — administrator on Windows, root on CentOS, Debian and RedHat, ubuntu on Ubuntu.
If directory listing is disabled, is .git still exposed? Yes. Directory listing controls whether a folder can be browsed; it does not control whether a specific file can be fetched. Git's own metadata files have fixed, well-known paths, and scanning tools try them directly rather than browsing.
Does force-pushing a cleaned history fix it? Not on its own. It does not recall objects that were already fetched, it does not clean the copy in your own web root, and unreachable objects persist until they are explicitly expired and pruned. Treat the credential as compromised and rotate it.
We removed the key from the code and the scanner is green. Are we done? Only if the scanner reads history. A working-tree scan cannot see a secret that was removed in an earlier commit, and the earlier commit is where the exposure lives.
Is source code exposure by itself a breach? Not necessarily. Well-built software does not become exploitable because someone read it. The exposure becomes a breach when the history contains credentials, keys or connection strings — and roughly one in twenty exposed configurations contains exactly that.
What is the single highest-value check we can run today? Fetch /.git/config from every hostname in your inventory and see what comes back. It is a one-line request per host, it needs no tooling, and the answer tells you whether you have a configuration problem or an active credential incident.
An exposed .git directory is not a door that was left open. It is a published archive of everything your project has ever contained, indexed by content hash, readable by anyone with a browser, and it survives the deletion of the file that made it dangerous.
The defensive move that feels like the fix — removing the secret and committing — appends a note to the archive. The move that is actually the fix is a web server rule, a build pipeline change, and a rotation. Two of those you do once. The third you do because the exposure already happened, and no amount of configuration rewrites a read that is already in someone's copy.
Related reading on this blog: HTTP 403 Forbidden in production: six causes that are not permissions covers why a denial rule can appear to work while something else is blocking the request, and a renewed certificate is not a deployed one covers the renewal-vs-deployment gap that the ACME exception above feeds into. If the credentials you are protecting are the ones an autonomous process holds rather than a human, the credential list is the security boundary is the companion piece. Two more that bracket the same problem from the attacker's side: certificate transparency logs are a permanent public list of your subdomains — which is how the hosts in that 3.5-million scan were selected in the first place — and auditing the 443 channel you cannot read, which is what a recovered repository credential can open.
To run the verification on a real environment: the 3-day and 7-day trial plans start at $1.9.
Want faster website performance and lower costs? Start ...
Why would someone prefer or select SurferCloud instead ...
When enterprises scale, hosting costs often become a si...