SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
Security New Added 8 September 2026

GitHub: push declined due to repository rule violations, secret detected

Push protection found a recognisable credential in a commit and blocked the push. The secret is in history, not just the working tree, so deleting the line and committing again will not clear it. Treat any secret that reached a shared branch as compromised.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# 1. Revoke and reissue the credential first. Assume it leaked.

# 2. Remove it from history
git rebase -i HEAD~3          # edit the offending commit
# or for something buried deep
pipx run git-filter-repo --replace-text <(echo 'ghp_realtoken==>REDACTED')

# 3. Push the rewritten branch
git push --force-with-lease

# 4. Keep it out next time
pipx run detect-secrets scan > .secrets.baseline
# pre-commit hook with gitleaks or detect-secrets

How to diagnose Security errors

Security errors are usually a control working correctly. A rejected JWT, a CSP violation, an SELinux denial or a host key mismatch is the system telling you an invariant was broken, and the right response is to understand the invariant, never to disable the control. Two of these deserve special caution: an SSH host key mismatch can indicate a genuine interception, and JWT algorithm confusion is an active exploitation technique, not a configuration nuisance.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Decode tokens locally and check exp, nbf, iss and aud. Never paste a live token into an online decoder. It is a credential.
  2. Pin the accepted JWT algorithm explicitly on the verifying side. Accepting whatever the token's header claims is the algorithm-confusion vulnerability.
  3. For SELinux, read the actual denial: ausearch -m avc -ts recent | audit2why. Set the correct file context with semanage fcontext rather than running setenforce 0.
  4. For CSP violations, read the browser console message. It names the exact directive and blocked URI. Add the specific source, not a wildcard.
  5. For an SSH host key mismatch, verify the new fingerprint out of band before removing the old key. This warning exists to catch man-in-the-middle attacks.

Tools worth reaching for

  • ausearch / audit2why
  • openssl x509 -noout -text
  • ssh-keygen -lf
  • browser CSP console reports
  • local JWT decoding

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

docs.github.com

Related Security errors

See all 25 Security errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.