A PGP private key is the secret half of an OpenPGP key pair. With it, someone can decrypt messages and files that were encrypted to you, and sign commits, releases, packages or emails in your name. The second danger is often the more serious: a stranger who can sign as the maintainer of a project can make a malicious release look genuine. If the key is protected by a passphrase, the leak is less immediate, but a weak passphrase can be guessed offline at any speed the attacker’s hardware allows. Revoke the key first, then investigate what it signed.
Check your GitHub account for leaked secrets — free
- Provider
- Other
- Severity
- Critical
- Impact
- Source code and build access
- Checked live by LeakWatch
- No
What a PGP private key looks like
An exported private key is ASCII armor: a text block between a header line and a footer line, with encoded data in between, split in lines of 64 or 76 characters:
-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: … (optional header lines)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
…
-----END PGP PRIVATE KEY BLOCK-----
The words are “PRIVATE KEY BLOCK”. A block that says “PUBLIC KEY BLOCK” is the public half, meant to be shared, and is not a leak. Older tools may print “SECRET KEY BLOCK” instead of “PRIVATE”, which is the same thing in an older name. Private keys are exported with gpg --export-secret-keys --armor, and may appear in files called private.asc, secret.gpg, key.asc or in a CI variable such as GPG_PRIVATE_KEY. A key can be passphrase-protected or not, and the block does not show which.
How PGP private keys get leaked
- CI signing setup. A key exported to sign releases or packages is pasted into a workflow, a script or an environment file.
- Repository backups.
private.ascor an exported keyring committed for convenience, or a whole.gnupgdirectory pushed. - Dotfiles and home backups. A personal repository that copies configuration folders, including the key store.
- Package publishing. Maven, Debian or other publishing projects that need a signing key and keep it next to the build files.
- Chat and tickets. A key pasted into a message to set up a new machine or to ask for help with a failing import.
- Container images. A key copied into an image layer for signing at build time, then published.
What to do in the first hour
- Revoke the key. Use the revocation certificate you generated when you created the key. If you do not have one, generate it with your key manager using the key itself, which is possible as long as you can unlock it. Import the certificate into your keyring so the key is marked revoked.
- Publish the revocation. Send the revoked public key to the key servers and anywhere you published the key: your website, your project’s page and any key directory. A revocation only protects people once they receive it.
- Create a new key pair, with a fresh passphrase, and keep the private key in a hardware token or a proper secret store, not in the repository.
- Tell the people who rely on the key. Publish the new public key and its fingerprint through channels that people already trust, and update the signing key in your CI and in documentation.
- Review what the old key signed. Check releases, packages, tags and commits published since the exposure for ones you did not make. If anything looks wrong, withdraw the release and say so publicly.
- Re-encrypt what matters. Messages and files encrypted to the old key can be read by whoever holds it. Move sensitive material to the new key, and rotate any secrets those files contained.
- Clean up the code and look for other secrets in the same commit. See I accidentally pushed an API key to GitHub.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at your key host
PGP has no central provider: a key is revoked by a certificate, not by a console. Import the revocation certificate, then upload the revoked public key to the key servers and sites where you published it. Platforms that store your public key, such as a code host that verifies signed commits, usually have a page in your settings where you remove the old key and add the new one. See the GnuPG documentation for revocation commands. A person has not confirmed any menu wording for this guide, so look for the section where your keys are listed and follow the documentation of the tool you use.
How LeakWatch detects it
The rule is called PGP Private Key Block. It looks for the exact header -----BEGIN PGP PRIVATE KEY BLOCK-----, then any run of letters, digits, +, /, =, colons, spaces and line breaks (which allows armor headers such as Version: and a checksum line), then the footer -----END PGP PRIVATE KEY BLOCK-----. The match needs both lines. A public key block, a block missing its footer, or a block whose body contains other characters is not reported. The severity is critical. This type is not checked live: whether a key is revoked or protected by a passphrase cannot be tested from the block itself, and LeakWatch does not try to use it.
LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.
FAQ
My private key has a passphrase. Do I still need to revoke it?
Yes, in most cases. A passphrase slows an attacker down but does not stop offline guessing, and you cannot know how strong it is against their effort. Revoking and replacing the key is the safe answer.
I never made a revocation certificate. Can I still revoke?
If you can still unlock the leaked key, you can generate a revocation certificate now. If you lost the passphrase, you cannot, and you must warn users by other means and stop using the key.
Does deleting the file from git help?
It helps going forward, but the key stays in history and in any clone. Only the revocation makes the leaked key stop being trusted.