github.com/golang-jwt/jwt/v5 v5.2.2: Delegated JWT login accepts tokens with no `exp` (a regression), so a login link without an expiry opens a session forever
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go
- Domain
- authentication, backend, security
Research direction
Start in model/session/delegated.go at CheckDelegatedJWT (lines 42-60) and confirm how pkg/crypto/jwt.go calls jwt.ParseWithClaims without jwt.WithExpirationRequired(). Make the missing-exp case reject alongside the expired case, then add a no-ExpiresAt case to model/session/delegated_test.go that must fail. Update docs/delegated-auth.md to state exp is mandatory and short. Done when the new test passes and the docs say so.
Written by the indexing model from the issue text.
Description
Severity: Minor — a limited or confusing misbehaviour, of a secondary feature or in an edge case.
- Severity: medium. A control the code originally enforced (a delegated token must carry an
expin the future) was silently dropped. A token that lacksexpgives a full password-less, 2FA-less session on the instance named in itsnameclaim, with no time limit. There are two preconditions. First, the external portal mints tokens withoutexp, and the integration guide does not tell it to set one. Second, the attacker gets hold of one such link: it travels in the query string, so it can end up in proxy or access logs, browser history orRefererheaders. Tokens cannot be forged, so this is not high. - CVSS 3.1: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N — 6.8
- Found by: claude
- Where:
linagora/cozy-stackmodel/session/delegated.go:52 - Introduced by: sha=5741ccdee9dc54776f5b2b036e72aeddce962d5e pr=3177 confidence=likely — "Use github.com/golang-jwt/jwt (#3177)", 2021-11-29. The original code (
320c91f6, "Add delegated jwt", 2019-01-30) usedjwt-go'sStandardClaimsand checkedif claims.ExpiresAt < time.Now().Unix(). A missingexpdecoded to0and was rejected, soexpwas required in effect. The migration switched toRegisteredClaims, whereExpiresAtis a*NumericDate, and rewrote the check asExpiresAt != nil && ExpiresAt.Before(time.Now()). That rewrite turned a missingexpfrom "rejected" into "accepted". The move to v5 (9d2a7564, 2023-10-10) only changed the import, and cozy-stack still passes nojwt.WithExpirationRequired(). - Weakness: in
web/auth/auth.go:262-267,GET /auth/login?jwt=<token>(unauthenticated) callssession.CheckDelegatedJWT(instance, token). On success it callsSetCookieForNewSession(c, session.NormalRun, "").CheckDelegatedJWT(model/session/delegated.go:42-60) does three things:keyFunc := func(token *jwt.Token) (interface{}, error) { return base64.StdEncoding.DecodeString(JWTSecret.(string)) } err := crypto.ParseJWT(token, keyFunc, &claims) ... if claims.RegisteredClaims.ExpiresAt != nil && claims.RegisteredClaims.ExpiresAt.Before(time.Now()) { return errors.New("Token has expired") } if claims.Name != instance.Domain { ... } return nilcrypto.ParseJWTcallsjwt.ParseWithClaimswith no parser options. In the library,Validator.Validatecallsv.verifyExpiresAt(claims, now, v.requireExp)(validator.go:105). When the claim is absent, that returnserrorIfRequired(required, "exp")(validator.go:174), which is nil becauserequireExpis false. The project-side check is then skipped too, becauseExpiresAt == nil. Nothing else bounds the token:iatis not checked, there is nojtior one-time-use store, andaud/issare not checked. The only binding is the customnameclaim, which must equal the instance domain. The integration guide (docs/delegated-auth.md:21-22) only says to "create a JWT, with the parameternameas the instance domain", so a portal that follows it leavesexpout. The unit tests (model/session/delegated_test.go) only cover tokens with a future or pastexp, never a missing one.
Confirmed by Joern on the library CPG.requireExpis set only atparser_option.go:65(WithExpirationRequired), andverifyExpiresAtis called only fromValidator.Validate(validator.go:105). So without that option, a missingexpis accepted. The cozy-stack half is not in the databases. It was read by hand:ParseJWTatpkg/crypto/jwt.go:22-36, the handler atweb/auth/auth.go:262, and the git history above. - Impact: anyone holding a delegated login URL whose token has no
expgets a new full session on that user's instance, as many times as they like and for as long as the context'sjwt_secretis not rotated. That session covers files, contacts, settings and the flows reachable from a logged-in session, with no password and no 2FA. Even whenexpis set, a link can be replayed any number of times within its lifetime. Exposure: every context withauthentication.<context>.jwt_secretconfigured. None of the listed Linagora projects mints these tokens (a search forlogin?jwt=/jwt_secretacross them found only unrelated uses). The issuers are external portals run by the integrator. - Remediation: restore the original rule in
CheckDelegatedJWT:
An alternative is to parse withif claims.RegisteredClaims.ExpiresAt == nil || claims.RegisteredClaims.ExpiresAt.Before(time.Now()) { return errors.New("Token has expired") }jwt.WithExpirationRequired(), which would mean lettingcrypto.ParseJWTtake...jwt.ParserOption. As hardening, also cap the lifetime: reject aniatolder than a few minutes, or anexp - iatabove a few minutes. Make links single-use by requiring ajtiand keeping it in the cache untilexp. Updatedocs/delegated-auth.mdto say thatexp(andiat/jti, if you adopt them) is mandatory and short. Add adelegated_test.gocase with noExpiresAtthat must fail. Siblings checked:model/rag/broker.go:128already requiresExpiresAt != nil. Thepermission.Claimstokens use their owniat-basedExpired()inmodel/permission/claims.go, so no other site has the same!= nil &&pattern.
Finding SEV-1 (medium) of the twake-qa deep dependency review of cozy-stack: github.com/golang-jwt/jwt/v5 v5.2.2 (golang-jwt/jwt at v5.2.2); full report: deep-dependency-reviews/20261122-204318-eed494-github-com-golang-jwt-jwt-v5.md.
Found by automated QA (twake-qa, claude -p + deep dependency review) on 0951d184286d, severity: minor, browsers: none, first seen 2026-11-22.
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 147
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 146
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from linagora/cozy-stack
-
ai-driven-qa bug claude Minor
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
linagora/cozy-stack#5374 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
linagora/cozy-stack#5231 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
linagora/cozy-stack#5228 ·
Maintainers usually reply within 1 day
-
Search: update ADR 008 to send share keys from the stackPossibly taken @shepilov claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
linagora/cozy-stack#5210 ·
Maintainers usually reply within 1 day
-
CSP: AppendCSPRule adds the sources to an earlier directive when the directive name appears in one of its sources (e.g. https://frame-src.example.com)Possibly taken A pull request linked to this issue is open or already merged. Openai-driven-fuzzing bug Minor
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
linagora/cozy-stack#5161 · 1 comment ·
Maintainers usually reply within 1 day
All issues in linagora/cozy-stack
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Add CybeDefendOpen
Difficulty 1/5 Under an hour Newbie friendliness 66/100
slavakurilyak/awesome-ai-agents#1031 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
kagent-dev/kagent#3792 ·
Maintainers usually reply within 1 day
-
new-compilers request
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
compiler-explorer/compiler-explorer#9640 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
google/certificate-transparency-go#1859 ·
Maintainers usually reply within 1 day