Skip to content

Panic when a random expiring authentication key duration overflows the clock #3051

Done

Description

@josecelano-bot

Goal

Creating a random expiring authentication key with a seconds_valid that overflows the clock returns DurationOverflow through every public path (tracker-core API and both REST endpoints) instead of panicking.

Problem

key::generate_key computes the expiry with CurrentClock::now_add(&lifetime).unwrap(). now_add returns None on overflow, so a huge seconds_valid panics in the request task and the client gets an empty reply. It is reachable with an admin token through POST /api/v1/keys with {"key": null, "seconds_valid": 18446744073709551615} and through the generate-key endpoint POST /api/v1/key/18446744073709551615. The pre-generated-key path already returns PeerKeyError::DurationOverflow and a 400. Impact: availability of an authenticated endpoint, not an open attack surface.

Reproduced on 2026-11-25 against a real tracker built from develop at 11c54fb48: both random-key requests dropped the connection and logged a panic at packages/tracker-core/src/authentication/key/mod.rs:111, while the pre-generated request returned 400. Found while testing tracker-core for #2902 (EPIC #1347).

Decision

Fix at the seam: key::generate_key returns Result<PeerKey, key::DurationOverflow> (new dedicated error type) and KeysHandler::generate_expiring_peer_key returns Result<PeerKey, PeerKeyError>. Both are breaking pub changes, allowed before tracker-core 4.0.0. Both REST paths map to AuthKeyError::DurationOverflow.

The full specification (bug-fix process, regression test strategy, plan, acceptance criteria) will be in docs/issues/open/ of the spec-only PR.

Activity

  1. added 9 commits that reference this issue on Nov 25, 2026
  2. added 3 commits that reference this issue on Nov 25, 2026
  3. added 3 commits that reference this issue on Nov 25, 2026
  4. 2 remaining items

  5. added a commit that references this issue on Nov 26, 2026
  6. added 11 commits that reference this issue on Nov 26, 2026
  7. added 2 commits that reference this issue on Nov 26, 2026
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