.git directory not blocked in .htaccess, allowing source code enumeration #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The
.htaccessfile only setsOptions -IndexesandDirectoryIndex index.php. It does not deny access to the.git/directory:Location
.htaccessRisk
If the application is deployed with the
.gitdirectory present on the web root (common in git-pull deployments), attackers can directly access.git/config,.git/HEAD,.git/refs/heads/master, and packed objects. Using standard git-dumping techniques (e.g.git-dumper), an attacker can reconstruct the entire source code, includingenv.php(which contains database credentials and configuration), even if the file is in.gitignoreand was committed by mistake.Suggested fix direction
Add the following to
.htaccess:Or in Apache directory config:
Additionally, ensure
.gitis never placed under the web-accessible root in production.Severity
moderate
Found by
Automated audit by Claude Code