Skip to content

Commit ec7d0dd

Browse files
authored
fix(security): correct CSRF token expiration from nanoseconds to 1 hour (#390)
## Summary - **Critical security fix**: CSRF token expiration was incorrectly set to `3600` (interpreted as 3600 nanoseconds = ~3.6 microseconds) instead of `time.Hour` - This caused all login attempts to fail with "CSRF token validation failed" because tokens expired instantly - Production at https://accessmanager.netresearch.de/login is affected ## Root Cause ```go // Before (broken) - 3600 nanoseconds = instant expiration Expiration: 3600, // 1 hour // After (fixed) - proper 1 hour duration Expiration: time.Hour, ``` The Fiber CSRF middleware expects a `time.Duration`, but was given an untyped integer which Go interpreted as nanoseconds. ## Test plan - [x] Built and tested locally with docker compose - [x] Verified CSRF tokens are now properly validated - [x] Ran CSRF-related tests (`go test ./internal/web/... -run CSRF`)
2 parents 60bf7e6 + 129d143 commit ec7d0dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/web/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func createCSRFConfig(opts *options.Opts) *fiber.Handler {
188188
CookieSameSite: "Strict", // Strict for maximum security with proxy trust enabled
189189
CookieSecure: opts.CookieSecure, // Configurable based on HTTPS availability
190190
CookieHTTPOnly: true,
191-
Expiration: 3600, // 1 hour
191+
Expiration: time.Hour,
192192
KeyGenerator: csrf.ConfigDefault.KeyGenerator,
193193
ContextKey: "token", // Store token in c.Locals("token") for template access
194194
ErrorHandler: func(c *fiber.Ctx, err error) error {

0 commit comments

Comments
 (0)