GHSA-fpw6-hrg5-q5x5 ech0's acess tokens with expiry=never cannot be revoked: logout panics, delete does not blacklist JTI
SummaryAccess tokens created with the "never expire" option have no `exp` JWT claim. Three independent revocation mechanisms fail for this token type. Logout at `internal/handler/auth/auth.go:154` and `:163` dereferences `claims.ExpiresAt.Time`, panicking on the nil field so the token never hits the blacklist. `RevokeToken` at `internal/repository/auth/auth.go:45-50` skips when `remainTTL <= 0`. The admin's "Delete token" panel action at `internal/service/setting/access_token_service.go:183-185` removes the database record but does not call `RevokeToken` to blacklist the JTI. Once a never-expire token leaks, the JWT stays cryptographically valid until the admin rotates the signing key across the entire instance.DetailsCreation path at `internal/util/jwt/jwt.go:103-105`:For `NEVER_EXPIRY`, `expiry = 0` and the conditional skips. The resulting JWT has no `exp` claim. The middleware at `internal/middleware/auth.go` accepts it; the `jwt/v5` parser does not require `exp` by default.Failure mode 1, logout panic at `internal/handler/auth/auth.go:163`:For a never-expire access token, `claims.ExpiresAt` is nil. `claims.ExpiresAt.Time` panics. Gin's Recovery middleware catches it and returns HTTP 500; the JTI never reaches `RevokeToken`. Line 154 shares the same pattern against refresh tokens, but refresh tokens are always issued with an expiry so the nil dereference does not fire there in practice.Failure mode 2, `RevokeToken` skip at `internal/repository/auth/auth.go:45-50`:Even if the logout path were patched to handle nil `ExpiresAt`, a caller computing `remainTTL = 0` would still skip the blacklist write.Failure mode 3, admin delete at `internal/service/setting/access_token_service.go:183-185`:Deletion removes the token's metadata row from the database. No call to `RevokeToken`, no write to the JTI blacklist. The JWT continues to validate because the signature is still authentic and the middleware does not consult the metadata table.The only way to invalidate a compromised never-expire token is to rotate `JWT_SECRET`, which invalidates every token for every user across the whole instance.Proof of ConceptDefault install. Admin creates a never-expire access token; its revocation pathways all fail:Observed on v4.5.6 in the test container:After the admin "deleted" the token, the same JWT string still returns the owner's profile data. The token stays valid with no path to invalidate it short of rotating `JWT_SECRET`.ImpactThe "never expire" option is intended for CLI and integration use cases where rotating tokens is expensive. When one of those tokens leaks (configuration file committed to a public repo, developer laptop compromised, log file uploaded by mistake), the admin has no remediation that does not nuke every other user's session.A compromised token gives the attacker:**Perpetual authenticated access** at whatever scopes the token holds until the JWT secret is rotated.**Admin's "revoke" UI button lies.** The token row disappears from the panel but the bearer keeps working. The admin believes they mitigated the incident.**Instance-wide blast radius on proper revocation.** The only working fix (rotate JWT_SECRET) forces every user to log in again and invalidates every other access token. Security incidents force operators into an all-or-nothing choice.Precondition: token theft. A stolen token is the standard threat model for any long-lived credential; the point of revocation is that stolen credentials can be invalidated. Ech0 currently has no working path to do that for the "never expire" class.Recommended FixThree coordinated changes, matching the three failure modes:Replace "never expire" with a very long expiry (for example 10 years) so every token has a finite `exp` claim. This removes the conditional at `jwt.go:103` entirely:If the "never expire" semantics must be preserved, make logout handle nil `ExpiresAt` explicitly:And accept non-positive TTLs in `RevokeToken` by substituting a long default.Blacklist the JTI when admin deletes an access token:Any two of the three changes close the gap; all three together make the revocation semantics match the admin's mental model.*Found by [aisafe.io](https://aisafe.io)*
CVSS v3.1 score: 7.4