Security teams should treat deleted and private commits as part of the secret exposure surface, not as erased history. The practical approach is to enumerate reachable commit objects, scan them for credentials, and preserve restartable state so long searches can resume. Because GitHub rate limits apply, the process is slower than normal repo scanning and needs controlled batching and valid repository access tokens.
Why deleted and private commits still matter for secret exposure
Deleted commits are not a safe assumption boundary, because the objects can remain reachable through refs, forks, backups, mirrors, reflogs, caches, or earlier clones. Private commits are also part of the attack surface if the scanning scope includes internal repositories, access-controlled forks, or historical states that may still be exposed to authorised users or service tokens. Teams should therefore define the scan target as git object history, not just the current branch tip.
That matters because secret exposure is often a history problem, not a current-file problem. A leak can sit in a commit that no longer appears in the default view, yet still be recoverable wherever the object remains accessible. A practical programme also needs to consider whether the repository has been rewritten, because rewrite operations change what can be enumerated and what evidence still exists for investigation.
Many teams under-scan because they rely on single-pass repository checks. A more reliable approach is to enumerate reachable commit objects, then scan the full object set for credentials, tokens, and key material that may only appear in older snapshots or private history. That is the same underlying problem addressed in Guide to the Secret Sprawl Challenge, where secrets sprawl is treated as an exposure problem across code, pipelines, and history.
How to scan hidden commit history without losing coverage
Start by building a complete object inventory for the repositories you are allowed to assess, then traverse commit reachability rather than assuming branch heads are sufficient. The scan should operate over all reachable commits, trees, and blobs in the scope you can legitimately access, because secrets may persist in objects that are no longer part of the visible working set.
For GitHub specifically, the operational constraint is that history enumeration can be slow and rate-limited. Controlled batching is therefore not a convenience, it is part of the detection design. Preserve restartable state, checkpoint progress, and avoid rescanning already-processed objects so long-running jobs can resume after throttling, token expiry, or interruption.
Use a scanner that can recognise both exact secret formats and higher-noise patterns such as private keys, cloud credentials, and bearer tokens, then validate findings before escalation. A useful supporting reference is the Secrets Scanning Buyer's Guide, which frames the tool-selection questions teams should ask when they need repeatable detection over large or messy history.
When the goal is GitHub history specifically, the GitHub and GitHub Actions Security Guide is useful for understanding the surrounding platform controls that often determine whether secrets are introduced, exposed, or later reused in automation.
What to do when you cannot scan everything at once
If full-history scanning is too expensive to run in one pass, split the job by repository, branch, commit range, or object batch, but keep the checkpoints durable. The risk in partial scans is not just missing a few commits, it is building false confidence that the history is clean when only the easy or recent objects were checked. Prioritise repositories with active forks, legacy automation, or past secret incidents first, because they are more likely to contain repeated leakage.
Private history also needs access governance. If the scanner uses a repository token, that token itself becomes part of the exposure surface and should be narrowly scoped, monitored, and rotated when the job model changes. Where secrets are already suspected, teams should treat the scan as both detection and incident support, meaning they preserve evidence, note object IDs, and map findings back to the minimum set of commit paths needed for remediation.
For teams that need a broader exposure-management lens, the Attack Surface Management Guide helps connect hidden repository content to the wider problem of untracked exposure across systems, assets, and forgotten interfaces.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
CIS Controls v8, NIST SP 800-53 Rev 5 and OWASP ASVS set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| CIS Controls v8 | CIS-16 — Application Software Security | History scanning and secret leakage are code-adjacent exposure risks. |
| Recommendation — Scan repository history for secrets and block exposed credentials before release. | ||
| NIST SP 800-53 Rev 5 | AU-6 — Audit Review, Analysis, and Reporting | Commit-history scanning depends on reviewing and analyzing repository events and objects. |
| Recommendation — Analyze repository history and alert on exposed credentials found in commit objects. | ||
| OWASP ASVS | V14 — Data Protection | Secret discovery in git history is directly about protecting sensitive material from exposure. |
| Recommendation — Verify that sensitive data is not retained in accessible repository history. | ||
Practitioner Guidance
What to prioritise: Scan reachable git objects first, then extend to private branches, forks, and historical ranges where your access allows it. If the objective is secret hunting, branch-tip scanning alone is too narrow to trust.
What to verify: Confirm the scanner can resume from checkpoints, records processed object IDs, and handles GitHub throttling without dropping state. Also verify that the access token used for scanning has only the repository scope required for the job.
Common mistake: Treating deleted commits as deleted evidence. In practice, you should assume the secret may still exist in an accessible object somewhere in the repository ecosystem until you have enumerated and scanned it.
Practitioner takeaway: Hidden history should be scanned as a first-class exposure surface, and the quality of the programme depends as much on resumable enumeration and scope control as on the secret detector itself.
Related resources from NHI Mgmt Group
- Hidden Attack Surface
- How should security teams scan API workspaces for leaked secrets without missing the places people actually store them?
- How should security teams scan Azure Blob Storage for secrets without missing embedded files and archives?
- How should security teams reduce attack surface for private applications without relying on perimeter controls?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 19, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org