BUG: DestroySession sets MaxAge to -1 second instead of -1 #39

Closed
opened 2026-02-16 06:56:34 +01:00 by clawbot · 1 comment
Collaborator

Severity: MEDIUM

File: internal/service/auth/auth.go line ~234

Description

session.Options.MaxAge = -1 * int(time.Second)

time.Second is 1000000000 nanoseconds. So this sets MaxAge = -1000000000, which is still negative and works to delete the cookie, but it's semantically wrong. The gorilla/sessions library expects MaxAge in seconds, and the conventional value to delete a cookie is -1.

The code works by accident (any negative value deletes the cookie), but it's confusing and could break if gorilla/sessions ever validates the range.

Suggested Fix

session.Options.MaxAge = -1
## Severity: MEDIUM ## File: `internal/service/auth/auth.go` line ~234 ## Description ```go session.Options.MaxAge = -1 * int(time.Second) ``` `time.Second` is `1000000000` nanoseconds. So this sets `MaxAge = -1000000000`, which is still negative and works to delete the cookie, but it's semantically wrong. The gorilla/sessions library expects `MaxAge` in **seconds**, and the conventional value to delete a cookie is `-1`. The code works by accident (any negative value deletes the cookie), but it's confusing and could break if gorilla/sessions ever validates the range. ## Suggested Fix ```go session.Options.MaxAge = -1 ```
Owner

create a PR

create a PR
sneak closed this issue 2026-02-16 07:09:26 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/upaas#39
No description provided.