Skip to main content
CriticalSecretsOWASP A07:2021CWE-798

How to fix: Keycloak realm signing key in source

Keycloak realm RSA/EC private keys sign every JWT issued by the realm. A leaked key lets attackers mint valid tokens for any user.

Why it matters

A leaked Keycloak realm signing key allows an attacker to mint valid JWTs for any user in the realm, including realm-admin, with any roles, claims, or expiry they choose, effectively bypassing all authentication for every application in the realm.

Keycloak realm RSA/EC private keys sign every JWT issued by the realm. A leaked key lets attackers mint valid tokens for any user.

How to fix it

  1. 1Rotate via Realm Settings → Keys → Active → click the provider → Regenerate
  2. 2After rotation, all existing tokens signed with the old key become invalid immediately
  3. 3Store realm export backups (which contain signing keys) in an encrypted secrets store, not in source

Code examples

Keycloak: force key rotation via Admin CLI

bash
# Use the Keycloak Admin CLI to rotate the realm key
/opt/keycloak/bin/kcadm.sh config credentials \
  --server http://localhost:8080 \
  --realm master \
  --user admin --password admin

# Add a new RSA key provider (higher priority will be used for new tokens)
/opt/keycloak/bin/kcadm.sh create components \
  -r YOUR_REALM \
  -f - <<EOF
{
  "name": "rsa-generated",
  "providerId": "rsa-generated",
  "providerType": "org.keycloak.keys.KeyProvider",
  "config": { "priority": ["200"] }
}
EOF

References

Detected automatically by VulnRadar. The check id is secret-keycloak-realm-key, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is Keycloak realm signing key in source?
VulnRadar rates this critical severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id secret-keycloak-realm-key, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Keycloak realm signing key in source map to?
It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for keycloak realm signing key in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Keycloak realm signing key in source | VulnRadar