[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"fix-exposed-git-folder":3},{"id":4,"slug":5,"title":6,"description":7,"bucket":8,"severity":9,"status":10,"publishedAt":11,"summary":12,"affectedCheck":13,"fixSteps":14,"agenticPrompt":15,"references":16},"fix-exposed-git-folder","exposed-git-folder","Your .git folder is exposed to the internet","A published .git directory lets anyone reconstruct your entire source code and read every secret your repository has ever contained. Check it in one request and fix it today.","LONG_STANDING_VULNERABILITY","high","published","2026-11-23T09:05:00.000Z","\u003Cp>Deploying by running \u003Ccode>git pull\u003C\u002Fcode> on the server is convenient, and it leaves a \u003Ccode>.git\u003C\u002Fcode> directory next to your application. If that directory is inside the folder your web server publishes, it is readable over HTTP.\u003C\u002Fp>\n\u003Cp>That matters more than it first appears. \u003Ccode>.git\u003C\u002Fcode> does not just describe the current files, it contains the repository's object database. With it, your full source code can be reconstructed, along with every version of every file that was ever committed.\u003C\u002Fp>\n\u003Cp>So this exposes two things at once: your source code, including any server side logic you assumed was private, and your history. Credentials that were committed once and removed later are still in there, and they are still valid unless somebody rotated them.\u003C\u002Fp>","\u003Cp>Ask your own site for the repository's config file:\u003C\u002Fp>\n\u003Cpre>https:\u002F\u002Fyour-domain.com\u002F.git\u002Fconfig\u003C\u002Fpre>\n\u003Cp>If you get back a text file containing \u003Ccode>[core]\u003C\u002Fcode> and a \u003Ccode>[remote \"origin\"]\u003C\u002Fcode> section, the directory is exposed. A \u003Ccode>404\u003C\u002Fcode> or \u003Ccode>403\u003C\u002Fcode> is the correct answer.\u003C\u002Fp>\n\u003Cp>Also try \u003Ccode>\u002F.git\u002FHEAD\u003C\u002Fcode>. A response of \u003Ccode>ref: refs\u002Fheads\u002Fmain\u003C\u002Fcode> confirms the same problem. Some servers block the directory index while still serving the files inside it, so test a file and not just \u003Ccode>\u002F.git\u002F\u003C\u002Fcode>.\u003C\u002Fp>","\u003Ch3>1. Stop serving the directory\u003C\u002Fh3>\n\u003Cp>Block it at the web server. For nginx, denying all dotfiles covers this and \u003Ccode>.env\u003C\u002Fcode> at the same time:\u003C\u002Fp>\n\u003Cpre>location ~ \u002F\\. {\n  deny all;\n  return 404;\n}\u003C\u002Fpre>\n\u003Cp>For Apache:\u003C\u002Fp>\n\u003Cpre>&lt;DirectoryMatch \"\u002F\\.git\"&gt;\n  Require all denied\n&lt;\u002FDirectoryMatch&gt;\u003C\u002Fpre>\n\u003Ch3>2. Audit the history for secrets\u003C\u002Fh3>\n\u003Cp>Assume the repository was downloaded. Search the history for credentials that were committed and later removed, and rotate every one you find. They are still live keys.\u003C\u002Fp>\n\u003Ch3>3. Change how you deploy\u003C\u002Fh3>\n\u003Cp>Pulling a git repository into the web root is the root cause. Build elsewhere and publish only the build output, or deploy an artifact, or point the document root at a subdirectory such as \u003Ccode>public\u002F\u003C\u002Fcode> so the repository sits above it.\u003C\u002Fp>\n\u003Ch3>4. Point the document root at the right place\u003C\u002Fh3>\n\u003Cp>Most frameworks expect the server to publish a single subdirectory. Serving the project root is what exposes \u003Ccode>.git\u003C\u002Fcode>, \u003Ccode>.env\u003C\u002Fcode>, lockfiles and configuration all at once. Fixing the document root fixes a whole class of problems.\u003C\u002Fp>","You are helping me fix a security misconfiguration on a website I own and operate.\n\nProblem: my .git directory is reachable over HTTP, which exposes my source code and the full commit history, including any secrets ever committed.\n\nWork through the following in order, and confirm with me before any destructive or irreversible step.\n\n1. Identify the stack, the deploy method and the directory the web server publishes. Tell me whether the repository root is being served directly, and how you concluded that.\n2. Explain how this project is deployed. If deployment works by running git pull on the server, say so clearly, because that is the root cause.\n3. Add a web server rule that denies all requests for paths beginning with a dot, covering both .git and .env. Detect whether this project uses nginx, Apache, Caddy, or a managed host, and write the rule for that one only.\n4. Propose the smallest change that stops the repository being inside the published directory: either repoint the document root at the framework's public directory, or switch to publishing build output or a deployment artifact. Show me the change, do not apply it to production yourself.\n5. Scan the git history for committed secrets and report them BY NAME AND LOCATION ONLY. Never print a secret value. Useful starting points: git log --all --full-history for files such as .env, config files, private keys, .pem, .p12, id_rsa, and service account JSON.\n6. From that scan, produce a rotation checklist naming each credential, the provider it belongs to, and where it gets rotated. I will do the rotating.\n7. Tell me whether the exposed history contains anything beyond credentials that I should treat as disclosed, for example internal hostnames, customer data in fixtures, or private business logic.\n\nFinish with a summary of the changes you made, and an ordered list of what I must do by hand.",[17],{"label":18,"href":19},"OWASP Top 10: Security Misconfiguration","https:\u002F\u002Fowasp.org\u002FTop10\u002FA05_2021-Security_Misconfiguration\u002F",1795449486769]