repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
git.mdMarkdown153 lines11.2 KiBsource raw download

title: "Git" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-web/git.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/git.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Git#

To dump a .git folder from a URL use https://github.com/arthaud/git-dumper

Use https://www.gitkraken.com/ to inspect the content

If a .git directory is found in a web application you can download all the content using wget -r http://web.com/.git. Then, you can see the changes made by using git diff.

The tools: Git-Money, DVCS-Pillage and GitTools can be used to retrieve the content of a git directory.

The tool https://github.com/cve-search/git-vuln-finder can be used to search for CVEs and security vulnerability messages inside commits messages.

The tool Gitrob searches for sensitive data in an organization's repositories and in repositories associated with its employees.

Repo security scanner is a command line-based tool that was written with a single goal: to help you discover GitHub secrets that developers accidentally made by pushing sensitive data. And like the others, it will help you find passwords, private keys, usernames, tokens and more.

Here you can find a study of GitHub dorks: https://securitytrails.com/blog/github-dorks

Faster /.git dumping & dirlisting bypass (2024–2026)#

Quick post-dump triage#

cd dumpdir
# reconstruct working tree
git checkout -- .
# show branch/commit map
git log --graph --oneline --decorate --all
# list suspicious config/remotes/hooks
git config -l
ls .git/hooks

Secret/credential hunting (current tooling)#

Server-side Git integrations as an attack surface#

If the application clones attacker-controlled repositories and later runs git operations from a web/API action (status, diff, checkout, pull, merge, commit, dependency sync, package install, branch switch...), treat Git itself as part of the server-side attack surface.[3]

Git config / hook abuse when the backend uses the native Git CLI#

If you can write or append to .git/config, several directives can turn a low-impact file write into server-side command execution during later Git actions:[3]

Directive Common trigger Abuse
core.fsmonitor git status, git diff Executes an external helper on common working-tree operations
core.sshCommand / core.gitProxy git fetch, git push, git clone Replaces the transport command
credential.helper Authenticated Git operations Runs a shell helper for credential lookup/storage
filter.<name>.clean / filter.<name>.smudge git add, git checkout, git clone Executes external clean/smudge filters
diff.external git diff Executes an external diff tool
core.hooksPath commit / checkout / merge / push Redirects hook execution to an attacker-controlled directory

hooksPath overwrite via path traversal#

Modern web apps sometimes regenerate .git/config from user-controlled repo names, dependency names, refs, or workspace identifiers. If one value lands inside core.hooksPath and another one controls where the generated config is written, you can chain both into RCE:[3][6]

Buried bare repositories & repo-detection abuse#

Git discovers repositories by walking upward and looking for HEAD, config, objects/, and refs/. Therefore, an attacker can bury a bare repository inside a normal repository subdirectory and wait until the service runs Git from there.[3][5]

  1. Create a nested bare repo.
  2. Change bare = true to bare = false.
  3. Add core.worktree and an execution directive such as core.fsmonitor.
  4. If the service later cds into that folder and runs git status / git diff, Git loads the buried config and executes your helper.

Also check whether deleting/corrupting .git/HEAD could make Git stop recognizing the intended repository and fall through to a planted bare repo in the same or parent directory.

Git argument injection and unsafe shell construction#

When untrusted filenames, branch names, refs, or paths are passed to Git without --, values starting with - / -- may be parsed as options instead of positional arguments.[4]

# Vulnerable
 git checkout $branch
 git rm $path

# Safer
 git checkout -- "$branch"
 git rm -- "$path"

Interesting primitives to test:[3]

Git stores symlinks as blob targets. If checkout materializes real symlinks and the web UI/API follows symlinks, a repository-scoped file read/write primitive can become filesystem escape:[3]

repo/
  link -> ../../../etc/

Then repo/link/passwd may resolve to /etc/passwd, and writes through that path may escape the repository boundary too.[3]

Extra pivot points:[3]

Quick checklist when you find a Git-backed file primitive#

References#