# clean-leaked-secrets-history

A secret got committed: stop pushing, remove it from the tree and from history (orphan commit for not-yet-shared repos, git filter-repo --replace-text otherwise), verify with gitleaks, force-push only with OK; rotation is Waleed's call.

- **Space:** github-ops-public (https://github.com/Tech-Realm/space-github-ops-public/tree/main/clean-leaked-secrets-history)
- **Level:** L1 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** git, gitleaks, git-filter-repo (pip)
- **Routes:** gh-cli; checks: 2
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use github-ops-public/clean-leaked-secrets-history` or MCP `get_pack github-ops-public/clean-leaked-secrets-history`
- **Files:** CHANGELOG.md, code/orphan_reset.sh, code/selftest.sh, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/results.json, pack.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

## Goal

The secret value exists nowhere in the repo's reachable history, and the owner knows exactly what leaked and where.

## Steps

1. Stop: don't push; list findings masked (`gitleaks detect --source . --log-opts=--all --redact`).
2. Tell Waleed which key (name + masked hint + where); he decides rotation. Never rotate or revoke keys yourself.
3. Remove from the tree: replace the value with an env NAME / vault reference and commit.
4. Repo never shared: replace history with one orphan commit of the clean tree: `bash code/orphan_reset.sh`.
5. Repo already shared: `git filter-repo --replace-text replacements.txt` (lines `literal:VALUE==>[REDACTED]`, file kept outside the repo and deleted after), then gitleaks again.

## Edge cases

- Orphaned objects keep counting on GitHub (e.g. contribution graph) until server GC; there is no API to force GC.
- Forks and clones keep the old history: rotation is the only real fix once shared.

## Don'ts

- Don't paste the secret into the replacements file inside the repo or into chat.
- Don't rotate, revoke or change real keys yourself.



---

Canonical URL: https://logicpacks.io/packs/github-ops-public/clean-leaked-secrets-history

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
