Skip to content

fix: gracefully skip JWKS keys with unsupported elliptic curves#4

Open
sergioperezcheco wants to merge 1 commit into
ory:v3from
sergioperezcheco:fix/jwks-unsupported-curve
Open

fix: gracefully skip JWKS keys with unsupported elliptic curves#4
sergioperezcheco wants to merge 1 commit into
ory:v3from
sergioperezcheco:fix/jwks-unsupported-curve

Conversation

@sergioperezcheco

@sergioperezcheco sergioperezcheco commented Jul 1, 2026

Copy link
Copy Markdown

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

  • Bug Fixes
    • Improved key handling so sign-in and token verification can still work when a JWKS contains an unsupported key type or curve.
    • Now skips only the unsupported keys and continues using any valid keys found.
    • Returns an error when no usable keys are available, preventing false success with an invalid key set.

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
@CLAassistant

CLAassistant commented Jul 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

sergioperezcheco added a commit to sergioperezcheco/kratos that referenced this pull request Jul 15, 2026
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
@sergioperezcheco

Copy link
Copy Markdown
Author

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 EdDSA keys that Telegram's OIDC provider sends) instead of returning an error.

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!

@sergioperezcheco

Copy link
Copy Markdown
Author

Hi @aeneasr — this is a small targeted fix that gracefully skips JWKS keys with unsupported elliptic curves (e.g. EdDSA keys from Telegram's OIDC provider) instead of returning an error.

It also unblocks ory/kratos#4580, which depends on this fix landing upstream. Would appreciate a review when you have a moment.

sergioperezcheco added a commit to sergioperezcheco/kratos that referenced this pull request Jul 17, 2026
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
@sergioperezcheco

Copy link
Copy Markdown
Author

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.

sergioperezcheco added a commit to sergioperezcheco/kratos that referenced this pull request Jul 20, 2026
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
sergioperezcheco added a commit to sergioperezcheco/kratos that referenced this pull request Jul 22, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JWKS parsing fails entirely when provider includes ES256K (secp256k1 in Telegram OIDC)

2 participants