Commit identity privacy audit
Self-contained procedure pack: a markdown procedure plus shell and Python helpers.
It talks to git, gh, and the host's public HTTP API only — no agent-specific
APIs and no runtime to install beyond gh and Python 3, so any agent (or a plain
terminal) can follow it end to end.
When to Use
Check whether a person's real email / name / identifiers leak through git commit metadata, prove the exposure, and fix it without overpromising. Use when the user asks "am I leaking my email on GitHub/Gitee/cnb.cool", "check my commits", "clean my commit author", or right after a history rewrite (to confirm the rewrite left no other flagged address behind).
Model you must reason with (three surfaces)
Identity in a commit comes from three independent places. Fixing one does not fix the others — always state which ones are covered:
| Surface | Controls it | How to detect |
|---|---|---|
Per-repo .git/config user.email | repo config | git -C <repo> config --get user.email |
Global ~/.gitconfig user.email | machine default | git config --global --get user.email (empty = commit fails rather than leaking) |
| Host web-UI commit-email picker | the host's "keep my email private" setting | settings page, or a web-made commit's committer |
The dangerous case is a web-UI commit whose committer is the host's bot
(GitHub <[email protected]>) but whose author email is a real address:
local git config never touched it, so machine-side checks report clean.
Core rules (always on)
- A push publishes identity permanently. Every pushed commit carries author and committer name+email in immutable history; forks and archive crawlers copy it within minutes. State this before recommending any fix.
- Never conclude "no leak" from a local scan. Local repos only show what was pushed from THIS machine. Name the unscanned surface: other machines, deleted repos, forks, gists, other hosts.
- An empty
user.emailis safe-by-failure, not safe-by-policy:git commiterrors out instead of leaking. Report it as a setup gap, not a leak. - Prefer the ID-based noreply
<id>+<login>@users.noreply.github.com(gh api user --jq '.id, .login'). Legacy<login>@users.noreply.github.comdetaches from the account if the login changes. - History rewrite is not future safety. A rewrite fixes one commit's author; it does not change the three surfaces above. Say this in the same breath as recommending the rewrite, never only after the user asks.
- Rewriting is gated on explicit user approval, with consequences named: SHA churn, broken clones/open PRs, old objects still addressable by direct SHA until the host GCs or support purges them, already-scraped copies irreversible. Offer delete-and-recreate as the thorough alternative plus its cost (stars/watch/issues/links).
- Prove exposure before calling it a leak: an unauthenticated read returns the address (see Verification). "It is in the history" is weaker than "an anonymous user can read it right now".
- Report shape: conclusion first (leak yes/no, how many), then a table, then an options table with the recommended option first. Answer in the user's language.
Branch points (decide explicitly, in this order)
Eight forks change everything downstream. Never skip one silently — state which branch was taken in the report.
| # | Fork | Branch | Action |
|---|---|---|---|
| G1 | Host access | gh installed + authed | scan all repos incl. private (repo scope) |
account exists, gh missing | ask before installing; if refused, public API only (60 req/h) and the report says "private not covered" | ||
| no account / no consent | local-only recon; first line of the report says "account surface not covered" | ||
| G2 | Scan depth | repo ≤100 commits | --paginate full history |
| large repo / rate-limit risk | drop --paginate, last 100 only, report says "partial" | ||
| offline | git clone --bare --filter=blob:none + git log --all | ||
| G3 | Classifier result | all safe_* | skip rewrite, go to G5 (harden future only) |
any flag_personal / flag_school | prove with the anonymous curl, then G4 | ||
flag_other_domain / unknown | ask whether the address is the user's before calling it a leak | ||
| G4 | Which surface leaked | local git config | fix global or repo-level user.email |
web-UI commit (committer GitHub <[email protected]>) | local config is irrelevant; only the two account toggles + the web email picker matter | ||
| other machine / fork / deleted repo | not recoverable; list as an uncontrolled surface | ||
| G5 | Identity scope | GitHub only | global ID-form noreply |
| also pushes to cnb.cool / Gitee / GitLab | per-repo override, or global with the side effect stated | ||
| G6 | History cleanup (needs explicit yes) | few commits, 0 forks | git filter-repo + force-push (cheapest) |
| many references, must be gone now | delete and recreate the repo (loses stars/watch/issues/links) | ||
| user refuses destructive steps | keep history, harden only | ||
| any branch | git bundle backup first; compare tree SHA after the push | ||
| G7 | Orphaned object | old SHA still HTTP 200 | draft a [email protected] email — do NOT force the Private Information Removal form (its premise is third-party posting; honest answers route to DMCA, dishonest ones are a lie) |
| repo recreated | nothing left; skip | ||
| residual risk accepted | record "not handled" plus the reason | ||
| G8 | Other hosts | GitHub only | done |
| cnb.cool / Gitee present | scan each host separately; noreply addresses are per-host |
Two rules hold across every branch: a clean local scan proves nothing about the account, and a config change never cleans history.
Procedure
1. Pin the host identity
gh auth status # scope needs repo for private repos
gh api user --jq '.login, .id, (.email // "null")'
email: null means the public profile hides the address — it says nothing
about commit metadata. Never treat it as a clean bill.
2. Local scan (this machine)
for r in <repo dirs>; do
echo "== $r"; git -C "$r" remote -v; git -C "$r" rev-list --all --count
git -C "$r" config --get user.email
git -C "$r" log --all --format='%ae' | sort | uniq -c | sort -rn
done
A per-repo address is how a "clean" global config still leaks.
3. Remote scan (every repo of the account, private included)
scripts/scan_commit_emails.sh remote <out.tsv> — lists repos with
gh repo list --limit 400, pages every commit, emits TSV
repo, sha, author_login, author_name, author_email, committer_email.
For repos already on disk on any host:
scripts/scan_commit_emails.sh local <out.tsv> <repo dir> ...
4. Classify and report
python scripts/classify_commit_emails.py <out.tsv> -o reports/commit-email-audit.md
echo "exit=$?" # 0 = no flag_* email, 2 = at least one
Buckets: safe_noreply, safe_bot, safe_local, flag_personal,
flag_school, flag_other_domain, unknown. Personal providers and
.edu. domains always warrant a flag; @users.noreply.github.com,
noreply@<host>, @localhost do not. The report also lists commits whose
author login is -: those emails are unlinked, so they render verbatim.
5. Verify the flag is publicly readable
curl -s "https://api.github.com/repos/<owner>/<repo>/commits/<sha>" \
| grep -o '"email": *"[^"]*"' | head -4
curl -s -o /dev/null -w "HTTP %{http_code}\n" "https://github.com/<owner>/<repo>"
Email in the anonymous response + HTTP 200 = real exposure. Put both in the
report; that is the line that moves a user to act.
6. Host settings (not readable by API)
The two GitHub toggles sit at https://github.com/settings/emails: Keep my
email addresses private and Block command line pushes that expose my email.
No endpoint exposes them — ask the user to look and leave the field pending
rather than guessing.
7. Remediation
references/remediation.md has the config fix, the git-filter-repo recipe
(bundle backup before rewrite, tree-SHA equality check after force-push),
and the residual-risk table. Sequence: fix the future first (config +
settings), then propose history cleanup. After a force-push, re-verify the old SHA with an anonymous curl: HTTP 200
means it is still readable. GitHub offers no purge form that fits
self-exposure — the Private Information Removal intake is premised on a
third party posting your data (answering "yes, this is my own work" diverts to
the DMCA flow; answering "no" is a false statement), the privacy form
dead-ends at a mailto, and the repository support categories have no matching
topic. So write the user a ready-to-send email to [email protected] (repo
URL, full old SHA, what you rewrote, the still-200 URLs, the ask) instead of
driving a form to a false premise. External actions need sign-off first; state
that the residual only matters to someone who already holds the old SHA.
Pitfalls
- In a git worktree
.gitis a file, so.git/info/excludefails with "Not a directory". Resolve withEXC="$(git rev-parse --path-format=absolute --git-common-dir)/info/exclude". - Write audit outputs into a path excluded via
info/exclude, not.gitignore. The raw TSV holds the very addresses being audited; a local exclude keeps it out of the repo without touching tracked project config. gh api --jqruns its own jq — nojqbinary needed; keep filters inline instead of piping to a tool that may be missing.--paginatecosts one request per 100 commits. On a repo with thousands of commits, drop--paginatefor a fast last-100 pass and call the scan partial.- Empty repos return 409 on the commits endpoint. Use
set -uo pipefail(not-e) in the loop and count skips, or the first empty repo kills the whole scan. - Spot-check completeness per repo:
gh api "repos/<o>/<r>/commits?per_page=100" --jq 'length'must equalgrep -c "^<o>/<r><TAB>" <out.tsv>when that repo has ≤100 commits. - cnb.cool / Gitee leak the same way. A public cnb.cool repo answers an
unauthenticated
curl; do not narrow the audit to GitHub just because that is where the user pointed. - Do not re-paste collected addresses into chat; the file is the artifact, the message carries the count and the SHA.
Done means
- Every flagged email has a verified anonymous read (step 5) or is explicitly marked unverifiable.
- The report states which of the three surfaces is fixed and which is pending.
- Settings toggles are recorded as confirmed-by-user or pending, never assumed.
- Any history rewrite has an explicit approval line or was left untouched.