New Ory Agent Security is now live! Claim your complimentary test drive. Get Started!

Skip to main content

v26.4.10

v26.4.10​

JSON Web Keys must follow stricter rules​

Ory Hydra Authorization, Ory Kratos Identities, and Ory Oathkeeper IAM Proxy now reject a JSON Web Key that breaks one of these rules:

  • An RSA key is at most 4096 bits long.
  • Base64url-encoded key values, such as n, e, d, x, and k, have no padding, as RFC 7518 requires. A value that ends in = is invalid.
  • In an Ed25519 key, x is 32 bytes long and is not a low-order point. In an Ed25519 private key, d is the 32-byte seed, and x is the public key that belongs to it.

Ory Hydra applies these rules to keys sent to the JSON Web Key API, to the jwks and jwks_uri of OAuth 2.0 clients, and to the keys of trust relationships for the JWT bearer grant. It also requires an HMAC key ("kty": "oct") that signs or verifies a token to be at least 32 bytes long for HS256, 48 bytes for HS384, and 64 bytes for HS512. Ory Kratos applies the rules to the key sets of session tokenizer templates, whether they are inline, file://, or https:// sources. Ory Oathkeeper applies them to the key sets of the jwt authenticator and the id_token mutator, and oathkeeper credentials generate no longer creates RSA keys longer than 4096 bits.

Breaking changes​

A request that sends a key that breaks one of these rules fails, and one such key makes its whole key set invalid.

This includes keys that are already stored. Ory Hydra can't load an OAuth 2.0 client, trust relationship, or JSON Web Key set that stores an RSA key longer than 4096 bits or an Ed25519 key that breaks the rules above. If such a key is in hydra.openid.id-token, hydra.jwt.access-token, or a key set listed in webfinger.jwks.broadcast_keys, /.well-known/jwks.json fails with 500 Internal Server Error. If it is in hydra.openid.id-token or hydra.jwt.access-token, issuing ID tokens or JSON Web Token access tokens fails as well.

Keys that Ory Hydra generates follow every rule, so only imported keys are affected. Stored keys also follow the encoding rule already, because Ory Hydra stores keys without padding.

Before you upgrade, replace these stored keys and any key set file or URL that serves a key breaking one of the rules, for example with an RSA key of 4096 bits or less, or an ES256 key. Ory Hydra can still delete or overwrite a stored key that breaks the rules after the upgrade, through the JSON Web Key API or hydra delete jwks.