[Security] Fix 6 vulnerabilities: Plaintext Passwords, Hardcoded JWT, Default Accounts, Missing SECRET_KEY (CWE-256, CWE-798, CWE-1392, CWE-532)#350
Open
saaa99999999 wants to merge 2 commits into
Conversation
- Remove hardcoded JWT secrets (use JWT_SECRET/REFRESH_JWT_SECRET env vars) - Add SECRET_KEY from environment (required, not defaulted) - Remove hardcoded DEBUG=True (default to False) - Remove default admin accounts (sa/admin/test user) - Remove plaintext password from User.__repr__ Co-Authored-By: Security Researcher <noreply@anthropic.com>
Passwords were stored as plaintext in the database and compared directly during login and password reset. This adds bcrypt hashing via set_password/check_password methods on the User model.
Author
CVE Request — Action Needed from MaintainerThis PR fixes security vulnerabilities. To assign a CVE number: GitHub only issues CVEs from the official upstream repository, not from forks. Please:
If you prefer, I can submit the CVE via MITRE (cveform.mitre.org) instead — just let me know. Thank you for reviewing this PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Issues Fixed
1. Plaintext Password Storage (CWE-312) — Critical
All user passwords were stored as plaintext in the SQLite database. The User model defined passwords as a plain string column with no hashing:
:
Login compared raw password strings directly in the SQL query:
Password reset read and wrote plaintext passwords:
Anyone with database access (SQL injection, backup leak, insider threat) can read every user password in cleartext.
Fix: Added bcrypt password hashing via set_password()/check_password() methods on the User model:
:
Updated Register handler:
Updated Login handler:
Updated ResetPassword handler:
Also added to .
2. Hardcoded JWT Secrets (CWE-798) — Critical
had hardcoded JWT signing keys:
Anyone who knows these strings can forge valid tokens for any user, including admin and super_admin roles.
Fix: Read secrets from environment variables:
Other Fixes