Skip to content

Authorization server: refuse every failed private_key_jwt client assertion with 401 invalid_client #7028

Closed

Description

@ChrisJBurns

Part of #6886.

Problem

When a private_key_jwt client assertion fails a check, the token endpoint answers with different errors depending on which check failed (v0.60.0):

  • a wrong aud or an unregistered key: 401 invalid_client;
  • an exp more than MaxAssertionLifespan ahead: 500 server_error. SetClientAssertionJWT returns a plain error (pkg/authserver/storage/memory.go, and the Redis equivalent), which surfaces as a server error;
  • a reused jti: 400 jti_known (fosite's ErrJTIKnown).

RFC 6749 §5.2 assigns invalid_client to every failed client authentication. Clients treat server_error as a retryable outage, so an assertion that will never be accepted looks like one that might be. jti_known is not a registered OAuth error code, so clients cannot classify it.

The accepted assertion audience is also broader than the issuer. clientAssertionAudienceConfig accepts the issuer or the token endpoint URL, and an aud array containing either (pkg/authserver/server/private_key_jwt_client_auth.go). #6946 said a later release would require the issuer as the only value. Once #7019 closes #6893, nothing tracks that change.

Mecatl's broker authenticates to the authorization server this way on every token request. Its design requires aud to be the issuer as the only value and requires a 401 invalid_client for every failed check (credentials-and-lifecycle.md, step 5).

Change

  • Every failed private_key_jwt check returns 401 invalid_client: wrong aud, unknown key, bad signature, expired, not yet valid, over-long lifetime, and reused jti. The error_description may say which check failed, but must not echo the assertion.
  • A storage failure while recording the jti (not a policy refusal) stays a 500 server_error.
  • Optionally, require the issuer as the assertion's only aud value, as Accept issuer as client assertion audience #6946 planned. This could be a configuration option, so existing clients can migrate.

Clock skew and the exp - iat bound are #6954.

Acceptance

  • Each of these assertions gets 401 invalid_client with no token issued: an expired assertion, one whose exp is beyond the maximum lifespan, one whose jti was used before, a wrong aud, and an unregistered key.
  • With the strict audience on, an assertion whose aud is the token endpoint URL, or an array with an extra value, gets 401 invalid_client.

Activity

  1. added
    needs-triage
    on Nov 2, 2026
  2. jhrozek commented on Nov 3, 2026

    @jhrozek
    Contributor

    Two cases from "private_key_jwt authentication failures return 500 or 400 instead of 401 invalid_client" (#6995), which I'm closing as a duplicate of this issue. Please add them to the acceptance:

  3. removed
    needs-triage
    on Nov 3, 2026
  4. jhrozek commented on Nov 3, 2026

    @jhrozek
    Contributor
  5. jhrozek commented on Nov 3, 2026

    @jhrozek
    Contributor

    9. Assigning to
    @pcbeingused333 per #6995 (comment)

    For some reason I can't assign this to you @pcbeingused333 but feel free to send a PR

  6. jhrozek commented on Nov 3, 2026

    @jhrozek
    Contributor

    I split the optional strict audience into #7039. It changes which assertions are accepted and needs a migration option, so it gets its own PR. #7036 covers the rest of this issue and will close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions