PC-013CRITICALUnignored Files

Unignored .pem, .key, or .p12 Certificate File

Detects unignored private key and certificate archive files (.pem, .key, .p12, .pfx) in your project, including binary keystores.

Rule Slug
unignored-tls-ssh-keyfile
Affected Files
*.pem, *.key, *.p12, *.pfx
Detection Method
.gitignore Cross-Check
Live Rule Tester100% Browser-Local
CRITICAL: "certs/server.key" is NOT ignored by .gitignore and will be committed!

Vulnerable Pattern vs. Hardened Fix

Vulnerable Pattern
# Repository folder with unignored binary/text keys
├── certs/
│   ├── server.key         # NOT in .gitignore
│   └── apns-prod.p12      # Binary keystore NOT in .gitignore
└── .gitignore
Recommended Fix
# .gitignore
*.pem
*.key
*.p12
*.pfx
id_rsa
id_ed25519
Recommended .gitignore Patch
*.pem
*.key
*.p12
*.pfx
id_rsa
id_ed25519

Why This Fails in Production

Private keys and binary PKCS#12 keystores (.p12, .pfx) are frequently dropped into project directories during local HTTPS setup (mkcert), Apple Push Notification (APNs) integration, AWS EC2 SSH access (my-server.pem), or enterprise mutual-TLS debugging. Unlike plain text API keys, binary certificate containers like .p12 and .pfx cannot be detected reliably by plain text regex scanners, making filename-level .gitignore verification essential.

When an unignored .pem, .key, .p12, or .pfx file slips into a commit, the exposure is immediate and severe. An EC2 .pem key grants root or ubuntu shell access to cloud instances. An SSL .key file compromises domain TLS integrity. A .p12 Apple distribution or APNs certificate allows unauthorized code signing or push notification broadcasts to all installed mobile app users. Even password-protected .pfx archives can be attacked offline at millions of guesses per second once extracted from Git history.

PushCheck evaluates every discovered .pem, .key, .p12, and .pfx file against your parsed .gitignore rules before any binary filtering skips its contents. Files properly covered by .gitignore are reported transparently as Safely Ignored, while any unignored key file triggers a CRITICAL pre-push block with an instant copyable .gitignore patch.

Keep cryptographic key files outside project directories whenever possible (for example under ~/.ssh/ or a dedicated local certs directory) and always include strict key-file ignore patterns in every repository’s root .gitignore.

Remediation Steps

  1. 1Add *.pem, *.key, *.p12, and *.pfx to your root .gitignore file before staging changes.
  2. 2Move local SSH and TLS keys outside your repository working tree into ~/.ssh/ or a non-versioned machine directory.
  3. 3If any key file was pushed to a remote repository, revoke and reissue the certificate or SSH key pair immediately and remove the old public key from authorized servers.
  4. 4If you legitimately commit public CA trust bundles (.crt or .cer), keep private keys strictly separated and never bundle private keys inside .pem files.

Frequently Asked Questions

Why does PushCheck flag .p12 and .pfx files even though binary files are skipped from regex scanning?
PushCheck intentionally evaluates file-presence and .gitignore rules before skipping binary file contents. That way binary keystores (.p12, .pfx) and databases (.sqlite) are caught reliably without slowing down the browser.
What if I have a legitimate public certificate stored with a .pem extension?
Consider naming public-only X.509 certificates with .crt or .cer extensions, or explicitly un-ignoring only that specific public file in .gitignore (e.g., !certs/public-ca.pem) after verifying it contains no PRIVATE KEY block.
Are mkcert local development keys safe to commit?
No. Committing even local TLS private keys normalizes dangerous patterns and risks accidentally committing production keys placed in the same certs/ folder later.

Related Unignored Files Rules

Scan local project folder →