Arviser

Exposed .git/config (nuclei git-config): is it real, how to fix it, what to tell the customer

Facts

Scanner finding
KB-F-0004 · Web and API, Software supply chain
Also known as
Git Configuration - Detect, Hidden File Found
Tool IDs
nuclei git-config "Git Configuration - Detect" (medium, CVSS 5.3, CWE-200); ZAP 40035 "Hidden File Found" (active, Medium, CWE-538). Related nuclei templates: git-logs-exposure, git-credentials-disclosure, git-exposure
Lab
scanner-findings, last run 2026-11-26 (run 8): nginx 1.30.8, Apache httpd 2.4.71, nuclei 3.11.1, images pinned by digest
Test
tests/git-exposure.sh base-url, fails on the vulnerable target, passes after the fix, reports catch-all servers as not exposed
Next review
2027-05-28

Short answer

nuclei git-config means https://yoursite/.git/config returned 200 with a [core] or [credentials] section and no HTML; ZAP 40035 looks for [core] only. If true, your Git repository is in the web root and can usually be downloaded, and nuclei has already printed any user:token@ from the remote URL. Check /.git/HEAD, /.git/config and a random /.git/ path: only a server that returns the same body for all three is a false positive. Fix: deny /.git/ at the web server, deploy build output instead of a checkout, and rotate every credential the repository held.

1. What the scanner saw

The nuclei template sends one request, GET /.git/config, and reports a match when three conditions all hold: the body contains [credentials] or [core], the body contains neither <html nor <body, and the status is 200 (template at commit eb28249). Its extractors then pull out a username and password from a url = https://user:pass@... line, a basic-auth header and a pass = line. In our lab it printed lab-user:lab-token-not-real, the fake value we planted. If the customer's report shows an extracted value, that value is already in their files.

ZAP's active rule 40035 checks a list of hidden files, and its entry for .git/config requires [core] in the body (ZAP hidden files list). A ZAP baseline scan does not run it: our baseline scan of the vulnerable target did not report the repository.

The nuclei template git-exposure is a different check. It requests /.git/ and matches a 403 page that names /.git/. That means a forbidden folder exists, not that its files can be read. nuclei also has git-config-nginxoffbyslash for the nginx off-by-slash alias variant; we did not run it.

2. Is it real on your system?

curl -s -o /dev/null -w '%{http_code}\n' https://app.example.com/.git/HEAD
curl -s https://app.example.com/.git/HEAD
curl -s https://app.example.com/.git/config | head -5
curl -s -o /dev/null -w '%{http_code}\n' https://app.example.com/.git/no-such-file-12345

Real exposure looks like this in our lab: HEAD returns 200 with ref: refs/heads/main, config returns a [core] section, and the random path returns 404. A fixed server returns 404 (or 403) for all of them.

A false positive looks like this: HEAD, config and the random path all return 200 with the same body. Our two catch-all targets did that. One is a single-page app that answers every unknown path with index.html, the other a service that answers every path with service is running. nuclei reported neither: the HTML filter excludes the first, and the second has no [core]. If your scanner did report a catch-all, compare the bodies before you change anything.

A half fix is not a false positive. Our trap with an app fallback, .git/config deleted and .git/HEAD left in place, returned the app page for config and the random path, and ref: refs/heads/main for HEAD. nuclei git-config no longer reported it, since it requests only /.git/config. The rest of the repository was still there. Our test fails it because HEAD differs from the random path.

A block that covers only the files scanners ask for is not a fix either. Our trap with location ~ ^/\.git/(HEAD|config)$ { return 404; } answered 404 for those two and served .git/index, .git/logs/HEAD, .git/packed-refs and .git/description; an earlier version of our test passed it. Block the whole folder, as below, and check a few more files than the scanner did:

for p in HEAD config index logs/HEAD packed-refs description; do
  printf '%s ' "$p"; curl -s -o /dev/null -w '%{http_code}\n' "https://app.example.com/.git/$p"
done

One trap went the other way in our first run. The single-page-app target shared a web root with a real .git/ folder, and its fallback (try_files $uri $uri/ /index.html) served the real file first. An app fallback does not hide a repository that is on disk.

Also check where the request landed. A CDN or a second host behind the same name can serve an old deployment.

3. How serious it is for you

Our view: if the check above confirms it, treat it as an incident, not a hygiene item. nuclei rates it medium, which describes .git/config alone. When /.git/HEAD and the rest of the folder are readable, the source code and its history can usually be rebuilt from the files, and that history often contains old secrets that were "removed" in a later commit.

Git's own documentation says a configured URL "can contain plaintext credentials in the form <protocol>://<user>:<password>@<domain>/<path>", and offers transfer.credentialsInUrl to warn or refuse (git-config). A deploy that cloned with a token in the URL leaves that token in .git/config.

There is no accepted-risk version of a readable repository. The false positive is the only "no".

4. Fix it on your platform

Do three things, in this order:

  1. Block it at the web server (sections below). This takes minutes.

  2. Rotate every credential in .git/config and in the repository's history: deploy tokens, API keys, database passwords. For a GitHub personal access token, delete or regenerate it (Managing your personal access tokens); for a deploy key, replace it with a new key (Managing deploy keys). Then search the access logs for earlier requests to /.git/ (grep '/\.git/' access.log) to learn whether someone already fetched it.

  3. Stop deploying the working tree. Build into a separate folder (dist/, public/) and publish only that, or deploy with git archive or a container image that does not contain .git/. This is our recommendation, and it is what removes the cause.

nginx (lab-tested on 1.30.8)

location ~ /\.(?!well-known/) {
    return 404;
}

This denies every path segment that starts with a dot, except /.well-known/ which certificate issuers need. return 404 hides that the folder exists; deny all; (nginx access module) returns 403 instead. Put it before other location blocks that use regular expressions: nginx checks them in the order they appear and uses the first match (nginx location). Our fixed target returned 404 for /.git/HEAD and /.git/config.

The rule does not apply inside location ^~ or location = blocks, because nginx does not check regular expressions after such a match. In our lab, location ^~ /static/ { alias /srv/www/; } next to the rule served /static/.git/config. Repeat the rule inside each ^~ location that maps to a folder:

location ^~ /static/ {
    alias /srv/www/;
    location ~ /\.(?!well-known/) {
        return 404;
    }
}

With the nested rule our test passed on /static.

Apache httpd (lab-tested on 2.4.71)

The default httpd.conf denies only files starting with .ht (httpd.conf.in), so .git/ is served unless you block it. A line built from the RedirectMatch syntax, our own:

RedirectMatch 404 (?i)/\.git(/|$)

In our lab it returned 404 for /.git/HEAD and /.git/config, and the test passed; the same virtual host without the line failed. The (/|$) ending keeps /.github/ and .gitignore out of the match; the unanchored /\.git also blocks those, which is broader but safe. (?i) makes the match ignore case, which matters on Windows and macOS, where /.GIT/config reaches the same folder. Our lab runs on Linux, so it tested the line but not that case.

IIS (from documentation, not run by us)

Add .git to request filtering's hidden segments. IIS then returns 404 with substatus 404.8 (IIS hiddenSegments). Our own example in web.config, following the documented syntax:

<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <hiddenSegments>
          <add segment=".git" />
        </hiddenSegments>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

The documentation does not say whether the match is case-sensitive; test /.GIT/config too.

Express (from documentation, not run by us)

The default depends on the major version. In Express 5, express.static treats dot files and dot folders as missing: dotfiles defaults to "ignore", which answers 404 (Express 5 express.static). In Express 4 the default is undefined, which acts as ignore except that "files in a directory that begins with a dot are NOT ignored" (Express 4 express.static). So express.static(repoRoot) on Express 4 serves /.git/config. On either version, set dotfiles: "ignore" explicitly, and better, point express.static at a build folder, never at the repository root. We did not run an Express target for this finding.

Vercel and Netlify (from documentation, not run by us)

Vercel ignores .git and other version-control folders for uploads, and says this applies to deployments from the Vercel CLI (Vercel build features). We found no official Netlify page. A 2022 reply on Netlify's support forum by user coelmay says dot folders such as .git are ignored; we could not confirm that the author speaks for Netlify, so treat it as a forum report, not documentation. On both, a finding most likely points to a server outside the platform, so check which host answered.

5. What to tell the customer

Example wording, adapt to what is true. Do not send the extracted credential back in the reply.

Confirmed and fixed:

Thank you for the report. It was correct: /.git/ was readable on app.example.com. We blocked it on , rotated the credentials it contained, and checked our access logs for earlier requests to that path (). We now deploy build output only, so the folder is no longer on the server. Attached: the 404 responses for /.git/HEAD and /.git/config after the change.

False positive:

We checked this finding. app.example.com answers every unknown path with the same page and status 200, so /.git/config returns our application page, not a Git file. /.git/HEAD, /.git/config and a random path under /.git/ all return the identical application page (output attached, ).

Evidence to attach: the four curl results from section 2, before and after.

6. Test: fails before the fix, passes after

Our script git-exposure.sh, run as sh git-exposure.sh base-url, fetches six files under /.git/ (HEAD, config, index, logs/HEAD, packed-refs, description) and a random /.git/ path.

7. What we ran

Run 8, 2026-11-26: nginx 1.30.8, Apache httpd 2.4.71, nuclei 3.11.1, images pinned by digest. Every test ran from a GNU and a BusyBox client with the same exit codes, and once more with one required tool removed from PATH, which gave "not tested" (exit 2) every time.

Target Setup Our test nuclei git-config
ngx-vuln fake .git/ in the web root, token in remote URL fail: HEAD, config, credential URL match, extracted lab-user:lab-token-not-real
ngx-fixed location ~ /\.(?!well-known/) { return 404; } pass, 404 no match
nginx trap 9443, SPA fallback, no .git/ try_files $uri $uri/ /index.html pass, catch-all no match
nginx trap 10443, plain-text catch-all return 200 "service is running" pass, catch-all no match
nginx trap 14443, SPA fallback, config deleted, HEAD left half fix fail: HEAD served no match (false negative)
nginx trap 15443, dot rule plus ^~ /static/ alias root / /static pass / fail match on /static
nginx trap 16443, rule repeated inside ^~ /static pass not scanned
apache 443, RedirectMatch 404 (?i)/\.git(/|$) pass not scanned
apache 8443, no rule fail not scanned
nginx trap 25443 location ~ ^/\.git/(HEAD|config)$ { return 404; } fail: index, logs/HEAD, packed-refs, description no match (false negative)
nginx trap 26443 same for HEAD, config, index, logs/HEAD fail: packed-refs, description not scanned
nginx trap 35443 SPA fallback, config deleted, detached HEAD hash with CRLF fail: HEAD not scanned
nginx trap 36443 location ~ /\.git { deny all; } pass, 403 everywhere not scanned
a port that never answers not tested (exit 2) not run

The run was done by Claude Opus 5.5 (agent) on an internal Docker network with no outside access. Expected results were written before each run and are in the lab's results folder, with the raw outputs, image digests and file hashes of run 8. Runs 2 to 8 were checked in four rounds by a separate AI agent; the fourth round compared run 8 with its expected results.

Sources

Primary records first. Record identifiers link from the facts box.

Scanner rules and tool documentation

Vendor documentation and statements

Our lab

Corrections

  • 2026-11-28: The "What we ran" line listed Express 5.3.0, which this finding did not run, and left out nuclei 3.11.1.

Report an error to contact@arviser.com.

How this page was made: Claude Opus 5.5, an AI model, built and ran the lab and wrote this page from the sources listed. Separate AI agents checked the claims and the lab tests in four rounds. Vadim Nareyko approved the family template and the sample pages on 26 November 2026, from a summary in Russian.

Text and data on this page: CC BY 4.0. Code in our lab: MIT. Quoted third-party material keeps its own terms.

Send written scope or question (Free)