Urgent.News

What's breaking now, across hundreds of outlets.

Tech

JWKS and `kid` Explained: How to Find the Key That Signed Your Token (and Spot a Leaked Private Key)

A practical guide to reading a jwks.json file, matching the right key, and checking it is safe to publish. Your API receives a token signed by an identity provider. To verify it, you need the provider's public key. But which one? Providers rotate keys, and a single endpoint can publish several at once. The answer is a small JSON document called a JWKS, and a header field called kid. JWK and JWKS…

A JSON Web Key (JWK) is a standard way to represent a single cryptographic key using JSON, as defined in RFC 7517. A JSON Web Key Set (JWKS) is a JSON object containing an array of JWKs, which can be published by identity providers at a public URL, often at /.well-known/jwks.json or in the jwks_uri field of their OpenID Connect discovery document.

When an API receives a token signed by a provider, it needs the provider's public key to verify the signature. The token's header contains a kid (key ID) field, and the verification process involves decoding the token, reading the kid, finding the matching JWK in the JWKS, and building a public key to verify the signature. Providers may rotate keys, and a single endpoint can publish multiple keys, so it's crucial to use the kid field to select the correct key.

JWKS files contain various key types, such as RSA and EC, and include fields like kty (key type), kid (key ID), use (intended use), alg (algorithm), and n and e (RSA public modulus and exponent). When inspecting a JWKS, look out for private key material (like d, p, q, dp, dq, or qi for RSA keys), symmetric keys (kty: "oct"), missing kid fields, duplicate kid values, and weak RSA keys (modulus under 2048 bits).

To check for security issues, you can use the JWKS Viewer tool or write a few lines of code to scan the JSON for private fields, symmetric keys, missing or duplicate kid values, and weak RSA keys.

Rewritten by urgent.news; may contain errors — check the original.

Read the original at dev.to →

Report a problem with this story

More in Tech

How Instagram Split One Database Into Thousands

Shard keys, logical shards, and the 64-bit photo ID that says when a photo was made and which shard holds it Two different photos. Two different databases. Both stamped with the same ID: 3.

  • Instagram's user base grew to 14 million in a year.
  • Database split into thousands for efficient data management.
  • Shard keys and 64-bit photo ID determined data distribution.

Your JWT Secret Is Probably Too Weak. Here Is the 30-Second Fix

"secret", "changeme" and "mysupersecretkey" are not keys. They are passwords, and passwords get cracked offline. Open the config of almost any tutorial project and you will find a line like this…

  • Weak JWT secrets like "secret" and "changeme" are easily cracked offline.
  • Use cryptographically secure random generators to create strong, unique secrets.

More from Saturday 21 November →