[GH-ISSUE #5302] ES256 JWT validation fails when JWKS key contains x5c field #10936

Open
opened 2026-08-05 01:27:45 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @AblabiX on GitHub (Feb 12, 2026).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/5302

Describe the problem

When using an OIDC provider (tested with Authentik) configured with ES256/ECDSA
signing keys, JWT validation fails with the following error even though the JWKS
endpoint correctly exposes an EC key:

token could not be parsed: token is unverifiable: error while executing keyfunc: 
key is not a valid RSA public key

The authentication works correctly with RSA/RS256 keys, but fails with EC/ES256 keys when the x5c field is present in the JWKS response.

To Reproduce

Steps to reproduce the behavior:

  1. Configure an OIDC provider (e.g., Authentik) with an EC P-256 signing key
  2. Ensure the JWKS endpoint returns the key with the x5c field populated
  3. Configure NetBird management server with AuthKeysLocation pointing to the JWKS URL
  4. Attempt to authenticate using a JWT token signed with ES256
  5. Authentication fails with "key is not a valid RSA public key" error

JWKS Key Structure (triggering the bug)

{
  "keys": [
    {
      "alg": "ES256",
      "kid": "example-kid",
      "kty": "EC",
      "use": "sig",
      "crv": "P-256",
      "x": "...",
      "y": "...",
      "x5c": ["..."],
      "x5t": "...",
      "x5t#S256": "..."
    }
  ]
}

Expected behavior

The function should check kty first to determine the key type, then handle x5c appropriately based on that type. EC certificates should be parsed with jwt.ParseECPublicKeyFromPEM(), not jwt.ParseRSAPublicKeyFromPEM().

Are you using NetBird Cloud?

self-host NetBird's control plane.

NetBird version

  • NetBird version: v0.64.6

Is any other VPN software installed?

no

Additional context

  • IdP: Authentik 2025.12.3
  • JWT Signing key Algorithm: ES256
  • Affected file: shared/auth/jwt/validator.go on getPublicKey()
Originally created by @AblabiX on GitHub (Feb 12, 2026). Original GitHub issue: https://github.com/netbirdio/netbird/issues/5302 **Describe the problem** When using an OIDC provider (tested with Authentik) configured with ES256/ECDSA signing keys, JWT validation fails with the following error even though the JWKS endpoint correctly exposes an EC key: ``` token could not be parsed: token is unverifiable: error while executing keyfunc: key is not a valid RSA public key ``` The authentication works correctly with RSA/RS256 keys, but fails with EC/ES256 keys when the x5c field is present in the JWKS response. **To Reproduce** Steps to reproduce the behavior: 1. Configure an OIDC provider (e.g., Authentik) with an EC P-256 signing key 2. Ensure the JWKS endpoint returns the key with the x5c field populated 3. Configure NetBird management server with AuthKeysLocation pointing to the JWKS URL 4. Attempt to authenticate using a JWT token signed with ES256 5. Authentication fails with "key is not a valid RSA public key" error JWKS Key Structure (triggering the bug) ```json { "keys": [ { "alg": "ES256", "kid": "example-kid", "kty": "EC", "use": "sig", "crv": "P-256", "x": "...", "y": "...", "x5c": ["..."], "x5t": "...", "x5t#S256": "..." } ] } ``` **Expected behavior** The function should check kty first to determine the key type, then handle x5c appropriately based on that type. EC certificates should be parsed with jwt.ParseECPublicKeyFromPEM(), not jwt.ParseRSAPublicKeyFromPEM(). **Are you using NetBird Cloud?** self-host NetBird's control plane. **NetBird version** - NetBird version: v0.64.6 **Is any other VPN software installed?** no **Additional context** - IdP: Authentik 2025.12.3 - JWT Signing key Algorithm: ES256 - Affected file: shared/auth/jwt/validator.go on getPublicKey()
saavagebueno added the triage-needed label 2026-08-05 01:27:45 -04:00
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#10936