fix: gracefully skip JWKS keys with unsupported elliptic curves#4
fix: gracefully skip JWKS keys with unsupported elliptic curves#4sergioperezcheco wants to merge 1 commit into
Conversation
When a JWKS endpoint returns keys with curves not supported by go-jose (e.g. secp256k1 used by Telegram), the entire key set unmarshal fails, breaking OIDC verification for all providers that use mixed key types. Add a fallback in RemoteKeySet.updateKeys() that parses each key individually when the full set unmarshal fails, skipping any keys that can't be decoded. This allows providers like Telegram (whose JWKS mixes RS256 and ES256K keys) to work as long as the token's signing key uses a supported curve. Includes tests for both the mixed-key and all-unsupported-curve cases. Closes ory/kratos#4572
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Telegram recently added an ES256K (secp256k1) key to their JWKS endpoint. go-jose doesn't support secp256k1, causing the entire JWKS set to fail parsing. This breaks all Telegram OIDC logins. Update go-oidc fork to include a fix that gracefully skips keys with unsupported curves when parsing JWKS, falling back to per-key parsing. See ory/go-oidc#4 for the upstream fix. Closes ory#4572
|
Hi maintainers — just checking if there's any update on this PR. It's a small, targeted fix that gracefully skips JWKS keys with unsupported elliptic curves (e.g. the This also unblocks ory/kratos#4580, where the kratos maintainers are waiting for this to merge upstream before they can remove the fork dependency. Happy to make any adjustments if needed! |
|
Hi @aeneasr — this is a small targeted fix that gracefully skips JWKS keys with unsupported elliptic curves (e.g. It also unblocks ory/kratos#4580, which depends on this fix landing upstream. Would appreciate a review when you have a moment. |
Telegram recently added an ES256K (secp256k1) key to their JWKS endpoint. go-jose doesn't support secp256k1, causing the entire JWKS set to fail parsing. This breaks all Telegram OIDC logins. Update go-oidc fork to include a fix that gracefully skips keys with unsupported curves when parsing JWKS, falling back to per-key parsing. See ory/go-oidc#4 for the upstream fix. Closes ory#4572
|
Friendly ping — is there anything you'd like me to change here? The fix is small (per-key decode with skip-on-unsupported-curve, error only when all keys fail) and unblocks kratos#4580 which is currently breaking all Telegram OIDC logins. Happy to refactor, add tests, or adjust the error semantics if you have a preference. |
Telegram recently added an ES256K (secp256k1) key to their JWKS endpoint. go-jose doesn't support secp256k1, causing the entire JWKS set to fail parsing. This breaks all Telegram OIDC logins. Update go-oidc fork to include a fix that gracefully skips keys with unsupported curves when parsing JWKS, falling back to per-key parsing. See ory/go-oidc#4 for the upstream fix. Closes ory#4572
Telegram recently added an ES256K (secp256k1) key to their JWKS endpoint. go-jose doesn't support secp256k1, causing the entire JWKS set to fail parsing. This breaks all Telegram OIDC logins. Update go-oidc fork to include a fix that gracefully skips keys with unsupported curves when parsing JWKS, falling back to per-key parsing. See ory/go-oidc#4 for the upstream fix. Closes ory#4572
so I hit this issue where Telegram OIDC login is completely broken in Ory Kratos (ory/kratos#4572). The root cause is that Telegram recently added an ES256K key (secp256k1 curve) to their JWKS endpoint. go-jose doesn't support secp256k1, so when it tries to unmarshal the entire JWKS set, it fails on that one key and the whole set is rejected — even though the token is signed with RS256 which works fine.
The fix is pretty straightforward: in RemoteKeySet.updateKeys(), when the normal unmarshal of the full key set fails, fall back to parsing each key individually as raw JSON. Keys that can't be decoded (like the secp256k1 one) get silently skipped, and the rest are returned normally. If ALL keys fail, it returns an error so we don't silently return an empty set.
Added two tests: one for the mixed case (valid RSA + unsupported secp256k1 → RSA still works) and one for the all-unsupported case (proper error returned).
This affects any OIDC provider that uses key types not supported by go-jose. Telegram is the most prominent example right now.
Closes ory/kratos#4572
Summary by CodeRabbit