Repository navigation
hardening(security): P1 sweep — credential logging, weak hashing, timing attack, fallback identity - #389
Merged
Conversation
…en comparison, fallback identity
Fixes 7 P1 findings from post-advisory security audit:
1. routes/quizzes.py — remove body fallback identity (3 locations)
identity.get("user_id") or data.get("user_id/wallet_address") allowed
attacker-supplied JSON body to act as identity when JWT absent.
Same root cause as GHSA-p7p9-jc8p-p38m. Now fails to None if no JWT.
2. routes/admin.py:113 — remove credential logging
print(f"Admin auth check - Header: {auth_header}") logged the full
Authorization: Bearer <ADMIN_TOKEN> value on every admin request.
3. routes/admin.py:136 — constant-time token comparison
Replace == with hmac.compare_digest to prevent timing side-channel
on admin token validation.
4. routes/auth.py:264,386 — replace SHA-256 no-salt with werkzeug PBKDF2
hashlib.sha256(password.encode()).hexdigest() has no salt and no
iterations, trivially crackable with GPU/rainbow tables.
Replaced with werkzeug.security.generate_password_hash /
check_password_hash (PBKDF2-HMAC-SHA256, salted, iterated).
Note: existing SHA-256 hashes will fail check; users need password reset.
5. routes/test_flow.py:12 — fix wrong JWT decode secret
Used SECRET_KEY (Flask session secret) instead of JWT_SECRET_KEY.
Legitimate tokens always failed; a token signed with SECRET_KEY passed.
6. routes/dashboard.py — remove X-Wallet-Address from auth documentation
Two strings still advertised the removed header as a supported auth
method, misleading clients and API consumers.
7. frontend/app/admin/login/page.tsx — remove admin token console.log
console.log('Attempting login with token:', adminToken) exposed the
full admin token in browser DevTools on every login attempt.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Changed Files
|
Contributor
|
👋 Hello! Thanks for your contribution. We will review this and get back to you as soon as possible. — th30d4y |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 28 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
Post-advisory security hardening sweep. Fixes 7 P1 findings identified after the four main advisories were patched.
Changes
routes/quizzes.py(×3)data.get("user_id")when JWT absent, same root cause as GHSA-p7p9routes/admin.py:113print(Authorization: Bearer <ADMIN_TOKEN>)on every requestroutes/admin.py:136token == expected_tokentiming-attack-vulnerable comparisonhmac.compare_digestroutes/auth.py:264,386hashlib.sha256(password)— no salt, no iterations, GPU-crackablewerkzeug.security.generate_password_hash(PBKDF2-HMAC-SHA256, salted)routes/test_flow.py:12SECRET_KEYused to decode JWT instead ofJWT_SECRET_KEY— legitimate tokens always failedJWT_SECRET_KEYroutes/dashboard.pyX-Wallet-Addressheader as valid authfrontend/.../admin/login/page.tsxconsole.log('Attempting login with token:', adminToken)in browserExisting users registered before this change have SHA-256 hashed passwords.
check_password_hashwill correctly reject them (SHA-256 hash ≠ PBKDF2 hash). Affected users will need a password reset. No data loss — old hashes remain in DB, just won't verify.Out of scope (separate PRs)
routes/auth.py) — requires DB schema change🤖 Generated with Claude Code