GeezerVison is showing github.com — id(web/identity): a future-dated token never expires — decode_token's age check is one-sided (saturating_sub), unlike the envelope and signed-request windows · Issue #1800 · developing-today/code
id(web/identity): a future-dated token never expires — decode_token's age check is one-sided (saturating_sub), unlike the envelope and signed-request windows #1800Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionBug
pkgs/id/src/web/identity.rs — the identity token's 30-day expiry check is one-sided, so a future-dated token never expires until 30 days after its future date arrives:
pkgs/id/src/web/identity.rs:65 — TOKEN_MAX_AGE_SECS = 30 * 24 * 60 * 60.
pkgs/id/src/web/identity.rs:381, in decode_token (after the Ed25519 signature verifies):
if now.saturating_sub(payload.created_at) > TOKEN_MAX_AGE_SECS {
return None;
}
created_at is a u64 seconds timestamp set at issuance (register, :188; refresh, :235). When created_at > now, saturating_sub yields 0, the check passes, and it keeps passing for the entire future offset plus another 30 days. There is no future-date / skew refusal anywhere in decode_token, verify_token (:222), verify_and_refresh (:232) or verify_token_client_id (:245).
The crate's other time-window checks are two-sided, which makes this the odd one out:
- Directory envelopes refuse the future explicitly:
envelope.at <= now.saturating_add(ENVELOPE_SKEW_MS) (5 min), "envelope is dated in the future" (pkgs/id/src/directory.rs:303, :1234-1237), before the same-shaped TTL check at :1239.
- Signed directory requests use
signed.at.abs_diff(now) <= SIGNED_WINDOW_MS (pkgs/id/src/directory_auth.rs:327).
Tokens are minted only by the server, so the trigger is a server clock fault: the clock runs ahead at registration or refresh (NTP step, VM time sync, manual set), is later corrected, and every token minted in that window gains the full skew as extra lifetime — minutes in the common case, unbounded in the worst case. A token's stated 30-day maximum age is therefore not a bound.
Evidence (verified this run)
Laptop probe ~/git/fleet/probe-2026-10-28-laneB-tokenfuture/probe.mjs: the exact predicate from :381 with Rust u64 saturating-sub semantics, TOKEN_MAX_AGE_SECS from :65:
control old token (31d ago): expired=true
control fresh token: expired=false
future token (+10y): expired=false
future token (+10y) checked 5y later: expired=false
future token (+10y) expires only at created+30d: expired=true
BUG CONFIRMED: a future-dated token is never expired until 30d AFTER its future date
Line trace on main e91098f1 confirms the predicate is the only age check on all three verify paths, and no caller re-checks created_at.
Why it matters
The web identity token is the credential for the web UI and WebSocket auth (verify_token_client_id). Its 30-day cap is the only lifetime bound — identities themselves are kept indefinitely (see #1766). A clock incident at issuance silently stretches that cap by the size of the incident for every affected token, with no log or signal; the two sibling protocols in the same crate both treat a future date as a refusal, so this reads as an oversight, not a policy.
Acceptance criteria
-
decode_token refuses a token dated implausibly in the future: created_at more than a pinned skew allowance (small — minutes, on the scale of the envelope's 5-minute ENVELOPE_SKEW_MS, or a justified value) ahead of now is rejected.
- Regression tests alongside
test_token_expiry (identity.rs:~1054): a token dated past the skew allowance is refused; a token dated within it is accepted; the existing 30-day expiry test keeps passing.
- Existing identity tests pass (laptop or CI).
Found by new-issue-creator-code-b. Dedup: gh issue list --search 'identity token future OR created_at OR TOKEN_MAX_AGE' (open + closed) and the open-issue list on 2026-10-28 show no token-expiry filing; #1766 covers identity retention, not token lifetime. Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item app/idPackage/app: id (pkgs/ or apps/ in this repo) effort/xsTrivial: expected under 30 minutes of work on Oct 28, 2026developing-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (new-issue-creator-code-b)
- Session / ID: cron new-issue-creator-code-b run 2026-10-28 14:52 CDT
- Found via: filed this run
- Task: Filed after verifying on main
e91098f1 that pkgs/id/src/web/identity.rs decode_token (:381) checks token age with now.saturating_sub(payload.created_at) > TOKEN_MAX_AGE_SECS — one-sided: a future-dated created_at yields age 0 and the token stays valid until 30d after its future date. Sibling checks in the same crate are two-sided (directory envelope future refusal at directory.rs:1234 with ENVELOPE_SKEW_MS; signed requests abs_diff at directory_auth.rs:327). Laptop predicate probe: control 31d-old token expired=true; +10y future token expired=false, still false 5y later, expires only at created+30d.
- Expectation: effort/xs — triage pins the skew allowance (minutes scale, cf. ENVELOPE_SKEW_MS 5m) and decode_token refuses created_at beyond now+skew; regression tests next to test_token_expiry.
- Links: packet
queue-packets/packet-1800.json (repo-health-code-pilot, triage); probe ~/git/fleet/probe-2026-10-28-laneB-tokenfuture/ (laptop)
dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 3, 2026 agent-note:v1
state: handed_off
task 7928 (pr_shepherd, PR #3377, lane code-j) claimed 2026-11-03 and assigned by the execution-lane system to the opencode lane (assigned_lane=opencode) — checkpoint handed_off recorded; the laptop claimant launches the bound opencode session to merge current main into queue/5045-1800-future-token-skew, verify the future-dated-token tests, and land PR #3377. Revalidated fresh: PR #3377 OPEN on branch queue/5045-1800-future-token-skew, no held/do-not-merge labels; issue #1800 OPEN. Note: a previous claim of task 7928 was also handed off (13:44Z) and returned on lease expiry — the claimant should pick this up on its next poll. dezren39 commented on Nov 3, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 3, 2026 🤖 Agent note · done (fixed_merged)
- Agent: queue worker (repo-worker-code), lane aea12c82-c5af-4e5a-9b66-f8e360f87177
- Session / ID: task 7928 (openchamber scheduled lane, PR shepherd packet)
- Found via: queue claim
- Task: PR fix(id/web/identity): reject future-dated tokens beyond clock skew #3377 (the
decode_token future-dated-token fix) had gone CONFLICTING against main. Merged current origin/main (e438032cd) into queue/5045-1800-future-token-skew; the only conflict was in pkgs/id/src/web/identity.rs and was purely additive — HEAD's TOKEN_FUTURE_SKEW_SECS = 5 * 60 const against main's new identity-admission block (id(web): registered identities are kept forever — no delete, expiry or cap at any layer, and the register handler is unthrottled #1766). Kept both, no logic changed.
- Verification on the merged tree (
~/git/fleet/7928, pkgs/id): cargo test --features web --lib future_dated_token → 1 passed; cargo test --features web --lib test_token_expiry → 1 passed. The 300-second future-skew refusal (payload.created_at > now.saturating_add(TOKEN_FUTURE_SKEW_SECS)) and test_future_dated_token_within_and_beyond_skew are intact.
- Outcome: PR fix(id/web/identity): reject future-dated tokens beyond clock skew #3377 merged at 2026-11-03T16:16:00Z, merge commit
bb592a618151db2e0898ec5c6def3e63394675a2; this issue auto-closed COMPLETED.
- Labels: cleared
status:in-review, status/in-progress, status/triaged, queue/claimed, work/assigned.
- Links: id(web/identity): a future-dated token never expires — decode_token's age check is one-sided (saturating_sub), unlike the envelope and signed-request windows #1800 · PR fix(id/web/identity): reject future-dated tokens beyond clock skew #3377 · commit bb592a6
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|