Skip to content

Security1 publisher3 min readPublished

GitHub's guidance on leaked secrets puts rotation ahead of rewriting history

GitHub's page on removing sensitive data tells teams to revoke and rotate first, and says the extra work of rewriting history often is not warranted when clones, forks and cached SHA-1 views keep the old commit anyway.

The Watch · Security desk

Illustration accompanying GitHub's guidance on leaked secrets puts rotation ahead of rewriting history

What happened

  • GitHub's documentation on removing sensitive data instructs teams to revoke or rotate the secret as the first step when the leaked data is a password, token or credential.
  • The page says revocation on its own may be sufficient to solve the problem, and that the extra steps of rewriting history to remove the secret may not be warranted.
  • It flags recontamination as a high risk: a developer holding a clone from before the rewrite runs git pull and then git push, and the sensitive data returns to the repository.

Compiled by The WatchSomething wrong?How this is made

Why it matters

  • decision The on-shift choice becomes whether a rewrite is worth the coordination it takes, with revocation as the close and the rewrite as the exception that needs a reason.
  • cost The cost of the rewrite falls on teams that did not leak anything: automation keyed to commit hashes, branch protection lifted for the force push, review threads on open pull requests.
  • exposure Everyone who cloned or forked before the cleanup becomes the residual exposure, and closing it depends on each of those holders acting rather than the repository owner.
  • capability A rewrite gives every clone holder a divergence to compare against, and the comparison points straight at the commit holding the credential.

Rotation closes access. Once the token is revoked, the string sitting in the commit object opens nothing, and GitHub's page says revoking or rotating "may be sufficient to solve your problem" [2].

It takes only ordinary work to undo a rewrite: a developer with a clone from before it runs git pull, then git push, and the commits are back [4]. To avoid that, the developer has to discard the clone and re-clone, or walk the local copy through the cleanup steps first [5]. The page describes careful coordination with collaborators as a requirement for executing a rewrite at all [16].

Most of the remaining side effects land on people who did not leak anything: branch protections that block force pushes have to be turned off, at least temporarily [7]. Commit hashes change from the leaking commit forward, so tooling keyed to stable hashes breaks [6]. Closed pull requests lose their diff view, and not only the one that carried the secret: any PR built on later history loses it too, even when it modified no affected file [8]. On open PRs, comments anchored to the old diff may be invalidated and lost, so GitHub recommends merging or closing every open pull request before the removal [9]. If colleagues keep updating branches that contain the data while the cleanup runs, you either redo the cleanup or discard their work [13].

git-filter-repo strips commit and tag signatures, including on commits that pre-date the data being removed [10]. The page notes a workaround through the --refs option and the condition attached to it: you have to specify every ref that has the sensitive data in its history and that includes the introducing commits [11].

Order of operations matters more than tool choice here: Git's commit identifiers were built with cryptographic checks so that tampering on a server would be noticed, and the page states the consequence for data removal plainly, that users with an existing clone notice the divergence and can use it to find, quickly and easily, the data you removed from the central repository [12]. A rewrite done before revocation tells every clone holder where to look while the credential still works.

Count the bullets and the ratio is eight documented side effects against four high-level steps for doing the rewrite properly [15]. The third of those steps is coordinating with colleagues to clean up other clones that exist [14]. A force push reaches the central repository and stops there, and the page says the commits may remain accessible in clones and forks and directly via their SHA-1 hashes in cached views [3]. GitHub does not say how often revocation alone ends the incident; it says the secret case is the common one [1].

What to watch

  • Whether GitHub carries the same rotate-first ordering into its secret scanning and push protection remediation flows.
  • Whether the page adds concrete guidance for forks and cached SHA-1 views beyond coordinating with colleagues.
  • Whether auditors and compliance frameworks accept revocation alone as closure for a committed credential.
Loading claim ledger
Loading source directory links
Loading share composer
Loading topic controls
Loading related stories