Skip to content

Comments

security: harden JWT secrets, path traversal, CORS, and auth#325

Merged
javi11 merged 1 commit intomainfrom
security/harden-auth-cors-paths
Feb 24, 2026
Merged

security: harden JWT secrets, path traversal, CORS, and auth#325
javi11 merged 1 commit intomainfrom
security/harden-auth-cors-paths

Conversation

@javi11
Copy link
Owner

@javi11 javi11 commented Feb 24, 2026

Summary

Full security hardening pass across Go backend and React frontend, addressing critical, high, and medium severity findings from a security audit.

Critical

  • C1: JWT_SECRET env var is now required — server fails to start with a clear error instead of using a hardcoded fallback
  • C2: generateRandomSalt() returns an error if crypto/rand fails — no more hardcoded fallback salt
  • C3: ImportMethods.tsx now uses credentials: "include" instead of reading a JWT from localStorage (consistent with all other API calls)

High

  • H1: handleSystemBrowsefilepath.Clean + IsAbs validation prevents ../../../etc/passwd traversal
  • H2: Import handler — same path validation on FilePath field
  • H3: Uploaded filenames sanitized with filepath.Base before joining with upload dir
  • H5: CORS restricted to COOKIE_DOMAIN env var value (both http/https); api.allowed_origins config overrides; falls back to *
  • H8: CookieSecure defaults to true; opt out for local HTTP dev via COOKIE_SECURE=false

Medium

  • M1: RespondInternalError suppresses err.Error() details in production (APP_ENV=development or DEBUG=true restores them)
  • M2: /auth/login and /auth/register rate-limited to 10 requests/minute per IP using Fiber's built-in limiter
  • M4: Minimum password length raised from 8 → 12 characters across backend and frontend
  • M6: ResetHealthChecksBulk SQL refactored from fmt.Sprintf string interpolation to parameterized ? placeholder

Low

  • L1: WebDAV credential-update log no longer includes the username value

Critical fixes:
- C1: Fail startup if JWT_SECRET env var is not set (no more hardcoded fallback)
- C2: generateRandomSalt returns error instead of hardcoded fallback string
- C3: Replace localStorage token in ImportMethods with credentials: "include"

High severity fixes:
- H1: Validate and reject non-absolute paths in system browse handler
- H2: Sanitize file paths in import handler with filepath.Clean + IsAbs check
- H3: Use filepath.Base on uploaded filenames to prevent path traversal
- H5: CORS now derives allowed origins from COOKIE_DOMAIN env var; explicit
  api.allowed_origins config overrides; falls back to wildcard
- H8: CookieSecure defaults to true; opt out via COOKIE_SECURE=false

Medium severity fixes:
- M1: RespondInternalError suppresses err details in production (APP_ENV!=dev)
- M2: Rate-limit /auth/login and /auth/register to 10 req/min per IP
- M4: Minimum password length raised from 8 to 12 characters
- M6: Replace fmt.Sprintf SQL string interpolation with parameterized placeholder

Low severity fixes:
- L1: Remove username value from WebDAV credential-update log line

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@javi11 javi11 merged commit 5e8fb75 into main Feb 24, 2026
1 check passed
@javi11 javi11 deleted the security/harden-auth-cors-paths branch February 24, 2026 21:02
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