{
    "content": "<h1>Exposure of <a href=\"..\/GIT-CONFIG\/\">.git\/config<\/a> in Public Directories<\/h1><p>The <a href=\"..\/GIT-CONFIG\/\">.git\/config<\/a> file is a local configuration file for the <a href=\"..\/GIT\/\">Git<\/a> version control system. It stores metadata about a repository, such as the <a href=\"..\/REMOTE-URL\/\">Remote URL<\/a>, fetching rules, and local branch settings. If this file is stored within a <a href=\"..\/PUBLIC-DIRECTORY\/\">Public Directory<\/a>—often referred to as the <a href=\"..\/WEB-ROOT\/\">Web Root<\/a>—and is not properly protected by <a href=\"..\/SERVER-CONFIGURATION\/\">Server Configuration<\/a>, it becomes a major <a href=\"..\/INFORMATION-LEAK\/\">Information Leak<\/a>.<\/p><p>Attackers frequently use tools like <a href=\"https:\/\/github.com\/internetwache\/GitTools\">GitTools<\/a> to exploit this misconfiguration. By accessing <a href=\"..\/PUBLIC-GIT-CONFIG\/\">public\/.git\/config<\/a>, a malicious actor can discover the location of the <a href=\"..\/UPSTREAM-REPOSITORY\/\">Upstream Repository<\/a>. If the <a href=\"..\/GIT-METADATA\/\">Git Metadata<\/a> is fully accessible, the entire <a href=\"..\/SOURCE-CODE\/\">Source Code<\/a> history can be reconstructed, exposing <a href=\"..\/API-KEYS\/\">API Keys<\/a>, database credentials, and proprietary logic. This is a common issue discussed in <a href=\"https:\/\/cwe.mitre.org\/data\/definitions\/538.html\">CWE-538<\/a> regarding file and directory exposure.<\/p><p>Securing this involves moving the <a href=\"..\/GIT-DIRECTORY\/\">.git Directory<\/a> outside of the <a href=\"..\/DOCROOT\/\">Docroot<\/a> or using <a href=\"..\/ACCESS-CONTROL-LISTS\/\">Access Control Lists<\/a> (ACLs) to block web access. For instance, in <a href=\"..\/NGINX\/\">Nginx<\/a>, one would use a <code>location ~ \/\\.git<\/code> block to return a 403 Forbidden status. Further guidance on protecting sensitive files can be found on the <a href=\"https:\/\/owasp.org\/www-project-top-ten\/\">OWASP Top Ten<\/a> project page.<\/p><ul><li><a href=\"..\/DIRECTORY-TRAVERSAL\/\">DIRECTORY-TRAVERSAL<\/a><\/li><li><a href=\"..\/WEB-SERVER-HARDENING\/\">WEB-SERVER-HARDENING<\/a><\/li><li><a href=\"..\/SECRET-MANAGEMENT\/\">SECRET-MANAGEMENT<\/a><\/li><li><a href=\"..\/DEVSECOPS\/\">DEVSECOPS<\/a><\/li><\/ul>",
    "tags": [
        "git",
        "security",
        "vulnerability",
        "misconfiguration",
        "web-security",
        "devops",
        "infosec",
        "privacy",
        "leaks",
        "server-admin"
    ]
}