auth icon indicating copy to clipboard operation
auth copied to clipboard

fix: support secp256k1 elliptic curve for telegram OIDC

Open Jualhosting opened this issue 6 months ago • 3 comments

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.

Jualhosting avatar May 27 '26 14:05 Jualhosting

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! 🚀

Jualhosting avatar May 28 '26 01:05 Jualhosting

Hello, any update on this ?

llefort001 avatar Jun 13 '26 21:06 llefort001

Hello, any update on this ? It's been close to 2 full month this OIDC is unavailable in my app.

llefort001 avatar Jul 06 '26 09:07 llefort001