Skip to content

fix(security): reduce cookie max-age, sanitize errors, replace panic with error#575

Merged
lakhansamani merged 1 commit intomainfrom
fix/cookie-errors-panic
Apr 5, 2026
Merged

fix(security): reduce cookie max-age, sanitize errors, replace panic with error#575
lakhansamani merged 1 commit intomainfrom
fix/cookie-errors-panic

Conversation

@lakhansamani
Copy link
Copy Markdown
Contributor

Summary

  • Cookie max-age: Reduced session cookie from 1 year to 24 hours to match server-side session expiry
  • Error sanitization: Removed internal error details from user-facing error messages in verify_email, reset_password, verify_otp; internal details are already captured in debug logs
  • Panic removal: Changed GenerateOTP() from string to (string, error) return, replacing panic() with proper error propagation; updated all 4 callers

Files Changed

  • internal/cookie/cookie.go — max-age reduction
  • internal/graphql/verify_email.go — generic error messages
  • internal/graphql/reset_password.go — generic error messages
  • internal/graphql/verify_otp.go — generic error messages
  • internal/utils/generate_otp.go — return error instead of panic
  • internal/graphql/login.go, signup.go, resend_otp.go, forgot_password.go — handle OTP error

Test plan

  • make test-sqlite passes (no regressions)

…e panic with error return

- Session cookie max-age reduced from 1 year to 24 hours to match server-side session expiry
- Error messages in verify_email, reset_password, and verify_otp no longer leak internal error details
- GenerateOTP now returns (string, error) instead of panicking on crypto/rand failure
@lakhansamani lakhansamani merged commit 9ff4462 into main Apr 5, 2026
@lakhansamani lakhansamani deleted the fix/cookie-errors-panic branch April 5, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant