Skip to content

OAuth Security Fixes: SECRET_KEY validation, session cookies, error handling - #16

Merged
neoneye merged 1 commit into
PlanExeOrg:mainfrom
VoynichLabs:oauth-security-fixes
Feb 8, 2026
Merged

OAuth Security Fixes: SECRET_KEY validation, session cookies, error handling#16
neoneye merged 1 commit into
PlanExeOrg:mainfrom
VoynichLabs:oauth-security-fixes

Conversation

@82deutschmark

Copy link
Copy Markdown
Collaborator

Summary

This PR implements critical OAuth security fixes and improves error handling as outlined in the OAuth security analysis.

Changes

Phase 1: Critical Security Fixes

  • SECRET_KEY Validation: Now detects both your-secret-key AND dev-secret-key defaults (previously only checked one)
  • Production Enforcement: Application fails fast in production if default SECRET_KEY is used
  • Session Cookie Security: Added SECURE, HTTPONLY, and SAMESITE=Lax flags to prevent session hijacking
  • Documentation: Updated .env examples with SECRET_KEY generation instructions

Phase 2: Error Handling & UX

  • OAuth Callback Protection: Wrapped callback in try/except for graceful error handling
  • Profile Validation: Added validation with clear error messages for missing required fields
  • User Feedback: Login template now displays error messages to users
  • Logging: Added warning logs when OAuth profiles are missing email addresses

Files Changed

  • frontend_multi_user/src/app.py - Core OAuth security and error handling
  • frontend_multi_user/templates/login.html - Error message display
  • .env.developer-example - Updated documentation
  • .env.docker-example - Updated documentation

Testing

Tested locally with:

  • Default SECRET_KEY detection in dev mode (warning logged)
  • Session cookie flags properly set
  • Error handling for OAuth failures

Security Impact

Fixes the following vulnerabilities:

  • Session hijacking via default SECRET_KEY (CRITICAL)
  • Cookie theft via missing HTTPONLY/SECURE flags (HIGH)
  • CSRF attacks via missing SAMESITE flag (MEDIUM)
  • Poor UX on OAuth errors (LOW)

Related Issues

Addresses Issues #1, #3, #5, #6, #7 from OAUTH_ANALYSIS.md

Deployment Notes

⚠️IMPORTANT: Before deploying to production, ensure PLANEXE_FRONTEND_MULTIUSER_SECRET_KEY is set to a secure random value. Generate with:

python -c 'import secrets; print(secrets.token_hex(32))'```

Phase 1 (Critical Security):
- Fix SECRET_KEY validation to detect both 'your-secret-key' AND 'dev-secret-key' defaults
- Fail hard in production (when FLASK_ENV=production or PLANEXE_PUBLIC_BASE_URL set)
- Add session cookie security flags (SECURE, HTTPONLY, SAMESITE=Lax)
- Update .env examples with SECRET_KEY generation command
Phase 2 (Error Handling & UX):
- Wrap OAuth callback in try/except for better error handling
- Add profile field validation with clear error messages
- Log warning when OAuth profile missing email
- Update login.html to display error messages
Addresses Issues #1, #3, #5, PlanExeOrg#6, PlanExeOrg#7 from OAUTH_ANALYSIS.md
@neoneye
neoneye merged commit 11dade8 into PlanExeOrg:mainFeb 8, 2026
@neoneye
neoneye deleted the oauth-security-fixes branch February 10, 2026 15:10
Sign up for freeto 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.

2 participants

@82deutschmark@neoneye