Repository navigation
Description
Summary: crates/auth/src/jwt.rs documents and constants a 15-minute access-token TTL (ACCESS_TOKEN_TTL_SECS: u64 = 15 * 60, doc comment "Access token lifetime: 15 minutes." at line 30). validate_token builds Validation::new(Algorithm::HS256) (line 79) without setting leeway, so it inherits jsonwebtoken's default 60-second leeway — a token presented up to 60 seconds after its nominal expiry is still accepted. The effective token lifetime is therefore ~16 minutes, not the 15 minutes documented and presumably relied on elsewhere (session-length assumptions, revocation-window reasoning).
Severity: S4 — latent/internal. A 60-second extension of a 15-minute token isn't a meaningful security exposure on its own, but it's an undocumented, implicit discrepancy between the stated contract and the actual behavior, now pinned by a characterization test rather than deliberately chosen.
Environment:
- Deploy: any
- Commit: 6411ddb
Repro steps:
- Mint a JWT with
expset to 5 seconds in the past. - Call
validate_tokenon it. - Observe it validates successfully (within the 60s leeway).
- Mint a JWT with
expset to 120 seconds in the past; observe it correctly fails withTokenExpired.
Expected: Either the leeway is a deliberate, documented choice (and the "15 minutes" doc comment should say "15 minutes + up to 60s leeway"), or the leeway should be set to 0 to match the documented contract exactly.
Observed: jsonwebtoken's default 60-second Validation leeway applies silently; nothing in crates/auth/src/jwt.rs sets or documents it near the ACCESS_TOKEN_TTL_SECS constant.
Evidence:
- Code:
crates/auth/src/jwt.rs:30-31(ACCESS_TOKEN_TTL_SECS, doc comment "15 minutes") - Code:
crates/auth/src/jwt.rs:78-79(validate_token,Validation::new(Algorithm::HS256)with no explicitleeway) - Existing characterization test:
expiry_leeway_is_60_seconds(crates/auth/src/jwt.rs:426-447) — pins the current 60s-leeway behavior with an explanatory comment noting that tightening it toleeway = 0would require updating that test (per the project's "tests are immutable during refactoring, but a deliberate behavior change is not a refactor" convention).
Suspected area: crates/auth/src/jwt.rs::validate_token — either set validation.leeway = 0 (deliberate behavior change, needs the pinned test updated) or add an explicit .leeway(60) with a doc-comment update so the 15-minute claim is accurate about what it actually guarantees.
Activity
fix(mermaid): close the four remaining gallery minors (#16, #18, #20, #…