Secrets hygiene: env cookie secret, untrack dev DB, close connection leak - #177
Open
Alvin-Nahabwe wants to merge 16 commits into
Open
Secrets hygiene: env cookie secret, untrack dev DB, close connection leak#177Alvin-Nahabwe wants to merge 16 commits into
Alvin-Nahabwe wants to merge 16 commits into
Conversation
model training - Add all caret job queue label keys
Longitudinal ml
Fix docker modal blank screen
Add async caret job queue with concurrent
- cookie_password (the session-cookie signing key) was hardcoded as "aphrcpass1" in a public repo, so cookies could be forged. It now reads COOKIE_PASSWORD from the environment and warns loudly on the dev fallback. Deployments must set COOKIE_PASSWORD. - users_db/users.sqlite (a throwaway local-test database with dummy accounts) was committed. Untracked it; it is already covered by .gitignore. login::login_server recreates the tables on first run, and auth.R now creates the users_db/ directory and only runs its ALTER TABLE when the table already exists, so a fresh deployment boots cleanly with no committed database. - The login database connection was opened per session and never closed (the source of the "call dbDisconnect()" warnings). It is now closed on session end. - Added .gitleaks.toml allowlisting the dev DB path and the dev cookie fallback so the secret scan can be promoted to a blocking gate. Note: real password hashing is handled by the login package as salted SHA-512 (not the unsalted MD5 that was in the dev fixture). Moving to a slow KDF (bcrypt/argon2) would be stronger but needs a different auth package - tracked as a follow-up, not included here. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What & why
Three fixes to the auth layer plus a gitleaks config.
1. Cookie-signing secret → environment (the real vulnerability)
server/auth.Rhardcodedcookie_password = "aphrcpass1"in this public repo. That value is the key used to sign session cookies — with it public, a session cookie can be forged for any user, independent of the password database. It now readsCOOKIE_PASSWORDfrom the environment and warns loudly if it falls back to the dev default.Action required on deploy: set
COOKIE_PASSWORDin the environment (this also invalidates existing sessions once, which is desired).2. Untrack the committed dev database
users_db/users.sqlite(throwaway local-test accounts — confirmed no real users) was committed. Untracked it (already covered by.gitignore). Safe because:login::login_serverrecreates the tables on first run (dbWriteTablewhen the table is absent), andauth.Rnow creates theusers_db/directory and only runs itsALTER TABLE userswhen the table already exists — previously it would have crashed on a fresh DB with "no such table: users".A fresh clone/deploy now boots cleanly with no committed database.
3. Close the login DB connection
The connection was opened per session and never closed (the "call dbDisconnect()" warnings from issues.md). Now closed on
session$onSessionEnded.4. gitleaks config
.gitleaks.tomlallowlists the dev DB path and the dev cookie fallback so the secret scan (added in #176, currently advisory) can be flipped to blocking.Verified
parse()passes onauth.R. Confirmedlogin::login_serverauto-creates tables and uses salted SHA-512 (viadigest) for passwords — the unsalted MD5123456hashes were only in the dev fixture, now untracked.Follow-ups
login(which offers SHA-familysalt_algoonly). Recommendation, not urgent.Note on history
Per your decision, no history rewrite — the dev DB remains in past commits (it's fake data). The allowlist keeps the scan clean.
🤖 Generated with Claude Code