Deleting a credential from the current file is a code change, not proof that the exposure is closed. The old value may still authorize requests, while copies remain in Git history, pull-request references, forks, clones, CI logs, artifacts, images, releases, caches, and backups. Rewriting history can reduce disclosure, but it cannot make an already copied secret unknown again.

The acceptance decision therefore needs two separate tracks. The authorization track proves that the exposed value has lost the capability it once granted and that intended consumers use a replacement. The copy track maps where the value may still exist, removes copies where the owner can do so, and records retention or ownership limits elsewhere. Neither track substitutes for the other.

Treat the Credential as Compromised Before Editing Git

GitHub recommends revoking or rotating a committed password, token, or credential first; history rewriting may not be warranted after access is removed. GitLab likewise says that purging repository history does not fully resolve the leak because existing forks and clones retain the original value. This changes the order of work: contact the credential owner and provider, contain the capability, then decide how much copy cleanup is justified.

Do not wait for a penetration test to revoke a credible production secret. Also do not paste the value into a ticket, chat, report, or new scanner merely to prove that it exists. The incident record should use a provider-safe identifier or approved redacted metadata, repository location, first and last known exposure, owner, grants, and status. Store any evidence that still contains the value in a restricted incident location with a defined retention decision.

A scanner alert is an input, not the closure decision. GitHub separates fixing a secret-scanning alert from manually closing it and does not automatically close an alert merely because the value disappeared from the repository. The alert state, provider state, deployment state, and copy state can legitimately differ.

Identify the Owner, Capability, and Dependencies

Before rotation, build a small credential record without reproducing the secret:

  • owner and provider: the team and system able to revoke or replace it;
  • type and identity: access-key identifier, token ID, certificate serial number, database account, or another safe handle;
  • grants: resources, roles, environments, and operations the credential could authorize;
  • consumers: applications, jobs, integrations, developer tools, emergency procedures, and human users;
  • issued descendants: sessions, temporary tokens, cached credentials, or certificates that may outlive the parent change;
  • exposure window: the first reachable commit or artifact and the time effective revocation was confirmed.

This is where an agreed source-assisted assessment can add value. Pentest.red could trace the finding from the committed location to authorized application, API, build, and infrastructure paths, then give engineers a map of the credential’s reachable capabilities and dependencies. That diagnosis is narrower than a general source-code security audit: it answers what this particular secret could authorize and which owned consumers will break when it is withdrawn.

Never test the leaked credential against a third-party service merely because it appeared in an owned repository. Credential status in the provider control plane, a safe provider-side key identifier, owner-confirmed revocation record, or a safe test identity is preferable. Any live request requires explicit permission from the current account owner, compliance with provider policy, a named target, and a minimal non-destructive action.

Run the Authorization Track: Revoke, Replace, Roll Out

“Rotation” is not one universal operation. A long-lived key may be replaced and deactivated. A role session may require a separate provider control for already issued temporary credentials. An OAuth provider may revoke a token while other sessions follow different rules. Document the exact object and provider behavior rather than promising that changing one parent secret instantly invalidates every descendant.

AWS illustrates the difference. Its IAM access-key procedure creates a replacement, updates consumers, deactivates the old key, confirms applications work, and then deletes the old key. Its role-session procedure uses a separate deny policy for sessions issued before a chosen time and warns that the action affects legitimate users too. These are provider-specific examples, not a template for every token system. The ordinary rotation guide describes a planned key change. Its optional waiting or old-key reactivation steps must not be transferred to an exposed credential; the owner determines urgent containment under the incident plan.

For a leaked production credential, availability planning must not become an excuse to leave it active indefinitely. The owner chooses a safe emergency sequence: create a least-privilege replacement if the provider allows overlap, update consumers through the approved secret-delivery path, verify critical operations with the replacement, deactivate or revoke the exposed value, and address separately any already issued sessions. Record the provider’s effective time and propagation limit.

Two-track closure for a Git secret
  1. ClassifyIdentify the provider object, owner, grants, consumers, descendants, and exposure window
  2. ContainRevoke or deactivate the exposed capability and handle issued sessions under provider rules
  3. RestoreDeliver a least-privilege replacement and prove named consumers use it
  4. Bound copiesInventory Git refs, collaboration views, CI outputs, packages, images, caches, clones, and backups
  5. AcceptRetest the authorized scenario and record effective revocation plus unresolved copy limits

Run the Copy Track Across Git and the Build Chain

The copy track is an exposure inventory, not a promise of perfect erasure. Start with branches, tags, pull-request refs, archived or deleted branches, forks, local and automation clones, patches, issue or review text, and platform caches. Continue into CI logs, test reports, artifacts, package registries, container layers, release bundles, deployment manifests, support exports, chat notifications, caches, and backups.

GitHub documents that rewritten commits may remain in clones, forks, cached views, and pull-request references; copies outside central control require owner coordination. It also warns that a rewrite changes commit identifiers and that an old clone can reintroduce the secret. Put those side effects in the cleanup plan.

GitLab notes that masking CI variables is not foolproof: a value can still reach an artifact or remote system. Its incident guidance calls for checking log and artifact visibility and retention. A cleanup ticket should therefore name each evidence store, owner, action, and limit instead of saying “removed from Git.”

Scroll sideways to compare

SurfaceAuthorization actionCopy actionAcceptance evidenceRemaining limit
Provider credentialRevoke/deactivate the exposed object; address issued sessions separatelyDo not reproduce the value in recordsProvider event, safe identifier, effective time, grants removedProvider propagation and unobservable prior use
Application and jobsInstall the replacement through the approved secret pathRemove plaintext from configuration and build inputsNamed consumers succeed with replacement after old value is inactiveUndiscovered or offline consumers
Git refs and review viewsNone: Git deletion does not revoke accessClean agreed branches/tags/PR refs and coordinate platform support where justifiedRef inventory before/after, rewritten commit map, protected-change recordExternal forks, clones, cached or quoted copies
CI, artifacts, images, releasesRotate credentials used by pipelines and registriesExpire or rebuild affected outputs under their product rulesJob/artifact/image/release identifiers and retention settingsImmutable releases, replicas, downstream downloads
Backups and local copiesKeep the old capability revokedRestrict, expire, or sanitize copies where policy permitsOwner attestation and retention boundaryOffline media and third-party custody

Decide Whether History Rewriting Is Worth the Cost

A credible exposed credential requires an urgent revocation decision by its owner; history rewriting is a separate risk decision. It is more compelling when the material cannot be made harmless by rotation, when platform caches or review pages keep exposing sensitive content, or when policy requires removal from owned stores. It may add little security for a fully revoked replaceable token while creating substantial repository disruption.

If the owner chooses a rewrite, freeze or coordinate writes, enumerate all affected refs and alternate paths, preserve a protected incident record without the raw value, clean the authoritative repository, manage platform-specific cached references, and coordinate known clone and fork owners. Prevent recontamination before normal work resumes. A successful default-branch scan alone does not prove every historical ref was cleaned.

The result must state what could not be changed. An organization can confirm removal from its repository and owned artifacts; it cannot guarantee deletion from unknown clones, downstream downloads, third-party backups, screenshots, or prior logs. Because the credential is revoked, residual copies should no longer grant the original capability, but they still count as sensitive data until their handling decision is documented.

Choose Evidence for Revocation

Acceptance should prefer provider and deployment evidence over authenticating with the compromised string. Suitable evidence may include the provider object marked inactive or deleted, an audit event with an effective time, a separately authorized check using a safe test identity, and successful operation by named consumers using the replacement. Record propagation uncertainty and the distinction between a long-lived parent credential and sessions already issued from it.

If the owner explicitly authorizes a live negative check, keep it minimal and non-destructive, target only the owned provider account or test environment, and avoid displaying the value in tooling output. “Authentication denied” can support the result under those conditions, but it does not prove every copy was deleted or that no earlier use occurred. A denial caused by missing permissions, network blocking, or the wrong account does not establish revocation. Correlate the identified cause of denial with the provider object state; a successful replacement check establishes its availability, not old-key invalidity. If permission or a safe endpoint is unavailable, mark live validation blocked and rely on provider-side status with that limitation.

Review available audit records for suspicious use during the exposure window as a separate incident question. Lack of retained telemetry limits the conclusion; it does not prove the key was never used. Once effective, revocation stops access through the affected object, while compromise investigation addresses possible earlier actions.

Apply Both Tracks to a Hypothetical Incident

Consider a fictional team that finds a cloud access key in a private repository’s old release tag. The current branch no longer contains the value, but an earlier CI job produced a diagnostic bundle and a container image during the same period. The key owner confirms its identifier and permissions; the raw value is not copied into the incident ticket.

The team creates a least-privilege replacement through the provider, updates two named jobs, verifies their expected read-only operation, deactivates the old key, and records the provider event time. It separately checks whether temporary sessions or other credentials were issued and follows the provider’s controls for those objects. That closes the authorization track only after both jobs demonstrably use the replacement.

For the copy track, the team inventories the release tag, pull-request reference, CI log, diagnostic bundle, image layers, developer clones, and backup retention. It removes or expires owned copies under each system’s rules and coordinates the known clone owners. A contractor confirms that an earlier download was placed under its retention process, but the team cannot independently verify deletion; that remains an explicit limit. It does not claim global erasure.

Scope the Retest Around a Closure Statement

Use the pentest scope planner to name the repositories, provider account, applications, build jobs, environments, allowed provider-side evidence, and the conditions for any check involving the leaked value. The report must redact the value while retaining enough identity to connect the finding, revocation event, rollout, and copy inventory. The article on report automation and evidence integrity explains why private evidence and public or executive output need separate boundaries.

Within an authorized cross-layer penetration test, Pentest.red could verify the agreed source, build, API, and infrastructure paths, show which owned capability was reachable, and give engineers reproducible evidence and remediation priority. The credential owner revokes the object and rolls out its replacement; the assessment verifies the agreed evidence and named consumers; each copy custodian performs deletion or retention actions in its own system. A narrow retest then confirms the approved closure conditions without turning it into a claim of complete incident eradication.

A defensible closure statement names both outcomes: the exposed credential lost its authorized capability at a recorded time, and the organization bounded and handled known copies with explicit residual limits. “The line was deleted,” “the history was rewritten,” and “the alert was closed” each describe only one part of that decision.

PENTEST.RED

Discuss pentest scope and pricing

We start by agreeing on systems, access, constraints and the expected evidence.

Prepare your testing scope

Based on in-depth research, edited for clarity and practical use.

PENTEST.RED / RED JOURNAL