Skip to content

fix: support secp256k1 elliptic curve for telegram OIDC#2548

Open
Jualhosting wants to merge 2 commits into
supabase:masterfrom
Jualhosting:fix-telegram-oidc-secp256k1
Open

fix: support secp256k1 elliptic curve for telegram OIDC#2548
Jualhosting wants to merge 2 commits into
supabase:masterfrom
Jualhosting:fix-telegram-oidc-secp256k1

Conversation

@Jualhosting
Copy link
Copy Markdown

@Jualhosting Jualhosting commented May 27, 2026

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Resolves #2534

When attempting to use Telegram OIDC or any Custom OAuth provider that uses the secp256k1 elliptic curve in their JWKS, the authentication flow fails. The underlying go-jose library does not support secp256k1, leading to a failure when attempting to fetch and verify the identity token signature.

What is the new behavior?

This PR introduces a fallback mechanism in ParseIDToken. When verifier.Verify() fails due to an "unsupported elliptic curve" error, the fallback logic:

  1. Manually fetches the JWKS from the issuer.
  2. Identifies the secp256k1 EC key.
  3. Performs ECDSA signature validation using the standard crypto/ecdsa package and golang-jwt/jwt, powered by decred/dcrd/dcrec/secp256k1 (which is already a dependency).
  4. Safely reconstructs the *oidc.IDToken struct for downstream compatibility.

This allows Telegram OIDC to work out of the box without requiring forks of go-oidc or go-jose.

Assistance Disclosure

I used Antigravity (a Gemini-based AI coding assistant) to help write the boilerplate and crypto logic for this secp256k1 OIDC support. I have manually verified the implementation and added tests to ensure correctness.

Resolves supabase#2534 by adding a fallback mechanism in ParseIDToken.
When go-jose throws unsupported elliptic curve error, the fallback
manually fetches the JWKS and verifies the secp256k1 signature
using go-ethereum/golang-jwt ECDSA implementation.
@Jualhosting Jualhosting requested a review from a team as a code owner May 27, 2026 14:08
Comment thread internal/api/provider/oidc_secp256k1.go Outdated
Comment thread internal/api/provider/oidc_secp256k1.go Outdated
@Jualhosting
Copy link
Copy Markdown
Author

Thank you for the excellent automated security scan findings! I have successfully addressed both the SSRF and OIDC token issuer verification bypass vulnerabilities in the latest commit:

  1. SSRF Protection: Integrated the internal utilities.ValidateOAuthURL() and utilities.FetchURLWithTimeout() helper functions to enforce secure outbound connections and prevent private/internal network access.
  2. Token Issuer Verification: Replaced the unverified claims.Iss field with the trusted OIDC provider issuer URL from provider.Claims(), and added a strict equality check ensuring the unverified token's issuer perfectly matches the configured, trusted OIDC provider issuer.

The PR is updated, fully secure, and ready for review! 🚀

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.

Support for Telegram OIDC: Unsupported elliptic curve secp256k1 in JWKS

1 participant