loading

Blocking .git Requests: Did It Really Help?

In a previous post, I found that 16.7% of server requests were targeting the .git folder, and out of those, 4,917 requests were actually serving files. So, I blocked them using Apache settings. I then tracked the logs for another four days after implementing the block. Comparing the four days before the block to the four days after, the number of IPs hitting .git only dropped slightly from 178 to 175, but the total number of requests plummeted from 27,997 down to 589—a 97.9% reduction. This means the scanners themselves haven't gone away; instead, the requests each individual scanner sends dropped from 157 to just 3.4. Essentially, once they hit a 403 Forbidden error on their first attempt, they stopped trying.

Comparing the Four Days Before vs. After Blocking

I compared the data by taking a 96-hour window both before and after the time I applied the settings (September 12th at 3:25 PM server time). I only counted the lines in the combined access log format.

Metric 4 Days Before Block 4 Days After Block Change
Total Requests 336,357 689,077 Increased due to traffic from other site bots
.git Requests 27,997 (8.3%) 589 (0.09%) −97.9%
200 OK Responses for .git 415 0 0 leaks
.git Data Transferred 14.0MB 115KB −99.2%
IPs Requesting .git 178 175 Almost the same
.git Requests Per IP 157.3 3.4 −97.9%
Total 404 Errors 61,339 38,821 −36.7%
Total 403 Errors 728 4,798 6.6x increase
Git request reduction chart
The number of IP addresses making requests stayed the same at 175 to 178, but the number of requests dropped by 97.9%, and the number of 200 responses became zero.

The reason the total requests doubled was due to four IP addresses in the 74.7.227.x range on September 16th scraping about 230,000 posts from a different bulletin board on the same server, which has nothing to do with .git. So, you should look at the raw numbers, not the percentages.

The Number of Scanners Stayed the Same, Only Requests Decreased

Before the block, out of 178 IPs requesting .git, four IPs sent over 1,000 requests, accounting for 27,261 requests (97.4%). After the block, there were no IPs sending over 1,000 requests, and the IP that sent the most had only 51 requests.

.git Requests Per IP Number of IPs Before Block Number of IPs After Block
1 55 69
2–5 85 76
6–20 31 27
21–100 2 3
101–1,000 1 0
Over 1,000 4 0

IP addresses sending 1 to 20 requests before and after the block look pretty similar. These are just reconnaissance scanners that poke a few files like /.git/config and /.git/HEAD and then move on. Whether they got a 200 or a 403, the number of requests stayed the same. What disappeared were the ones sending over 1,000 requests. Before the block, 80.2% of the 27,997 requests to .git were for object files under .git/objects/. This second phase only started after config and HEAD were successfully opened with a 200 status. By blocking the first phase with a 403, that second phase vanished. After the block, there were zero requests to .git/objects/.

How the Same IPs Changed Before and After Blocking

We found 16 IPs that appeared in both time periods. One, 45.148.10.120, which sent 10,231 requests before the block, only sent 5 requests after the block and then stopped. The other 15 IPs sent 20 requests or fewer in both periods, and their activity either stayed the same or decreased. It seems these scanners aren't dropping the server from their list; instead, they just keep coming back to request the first file, get a 403, and then leave. After the block, the User Agent (UA) strings for .git requests shifted. The Firefox/78 string, which made up 85.2% of requests before the block, disappeared, and Windows browser UA strings now account for nearly half.

Requests Following the Initial .git Hit Before Block (Number of IPs) After Block (Number of IPs)
Another .git path 63 40
No further requests (that request was the last) 31 30
/.env related paths 30 59
/ (Home directory) 20 17
/graphql 18 Outside the top 8

After the block, IPs that received a 403 from .git started hitting .env next more often. This suggests the scanners are running .git and .env as part of a bundled attack, and if one fails, they keep trying the other.

Blocking .env Only Stopped 22% of Requests

Even though I included .env in my security settings, the logs show that requests for .env actually increased from 13,013 before the block to 16,986 after. Only 3,799 requests (22.4%) resulted in a 403 error. The remaining 12,555 requests (73.9%) were still 404s. The reason for this lies in the request paths.

Request Path Response Code Size Time Reason
/.env, /.env.bak 403 199B 16ms FilesMatch rule caught it
/laravel/.env, /api/.env 404 55,096B 68ms No directory, triggered WordPress 404 page
/backend/.env from other sites 404 196B — No directory, triggered Apache 404

When a request is made directly to .env in the root, it gets a 403 because of the file name rules. However, scanners are hitting dozens of subdirectories like /laravel/.env, /backend/.env, and /admin/.env. If those directories don't exist, Apache serves a 404 without even checking the file name rules. On a WordPress site, if the path isn't found, it passes the request to index.php, resulting in a 55KB 404 page. Over the four days after blocking, we saw 1,697 of these WordPress-rendered .env 404s. This isn't much different from the 2,116 we saw before blocking. Unlike .git, which stops at the first file, .env keeps trying subsequent paths, so blocking by URL pattern is more effective than by file name. We'll decide later if we should move this to LocationMatch.

What's Left in the Error Logs

When a 403 error occurs, Apache's error log records a line that says "client denied by server configuration." After the block, this line accumulated 5,070 times up until the morning of September 17th. When broken down by document root, this single WordPress multi-site generated 724 hits, while other sites generated between 97 and 731 hits each. This means the attack isn't targeting one specific site, but all the hostnames on the server. Just like when we saw that fail2ban jams were at zero for 161 days (referencing this article), counting these lines is more useful than counting IP blocks. The "Primary script unknown" errors, which are looking for non-existent PHP files, are accumulating at similar rates before and after the block, so they aren't related to this configuration.

Summary of Findings

  • Blocking requests to .git didn't stop the scanners; it just eliminated the second phase of their attack. If the first file returns a 403 error, the 20,000 subsequent object files won't follow.
  • The number of scanning IPs remains the same. They keep hitting the site daily, so they test the initial file before moving on. This costs about 3 to 4 requests per IP, and since the response is only 199 bytes, it's negligible.
  • For .env, 74% are still resulting in 404 errors due to subdirectory paths. Out of those, 1,697 requests actually triggered WordPress to serve a 55KB page. File naming conventions alone aren't enough.

How I Measured This

I parsed five sets of access logs, similar to the one in my previous post, using Python. I focused on the 96 hours surrounding the time I applied the settings: 3:25 PM on September 12, 2026 (server time, KST). The first window covered September 8th at 3:25 PM, and the second window covered up to September 16th at 3:25 PM. I defined a .git request as one containing /.git in the path, and a .env request as one containing /.env. I identified WordPress-rendered 404s by checking for a response size of 1KB or larger. To track the sequence of requests per IP, I listed all lines for a single IP chronologically and looked at the line immediately following the first .git request. The response size and timing were measured directly against kilho.org using curl --resolve from the server. For error logs, I counted lines containing client denied across the two log files before and after the September 13th rotation, and then categorized them by the document root in the path.