security: remove SHA-256 password fallback, CSPRNG for verification codes and keys - #148
Merged
NetworkTheoryAppliedResearchInstitute merged 2 commits intoSep 14, 2026
Conversation
…keys - utils/bcrypt.js: the silent fallback hashed passwords with unsalted single-round SHA-256 when bcryptjs/bcrypt failed to load. bcryptjs is a declared dependency, so the fallback only ever fired on a broken install; now it throws instead of silently degrading. (CodeQL alerts #11, #12) - user_controller.js: 6-digit verification codes came from Math.random(), which is predictable; now crypto.randomInt. (CodeQL alert #10 source) - key_controller.js: generateMcElieseKey used Math.random().toString(36); now 32 bytes of crypto.randomBytes as base64url. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Jodson Graves <info@ntari.org>
csecrestjr
approved these changes
Aug 30, 2026
csecrestjr
reviewed
Aug 30, 2026
csecrestjr
left a comment
Collaborator
There was a problem hiding this comment.
Update README.es.md:94:node server.js with this
starts the server (e.g., http://localhost:5000)
NetworkTheoryAppliedResearchInstitute
deleted the
security/harden-auth-primitives
branch
September 14, 2026 18:51
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.
Fixes the credential-strength findings from CodeQL (alerts #10–#12):
backend/utils/bcrypt.js— the module silently fell back to unsalted, single-round SHA-256 for password hashing wheneverbcryptjs/bcryptfailed to load.bcryptjsis a declared dependency, so the fallback only ever fired on a broken install — which should fail loudly, not quietly store crackable hashes. It now throws with a clear message instead. No hash-format migration needed: any correctly-installed deployment was already using bcryptjs.backend/controllers/user_controller.js— 6-digit account verification codes were generated withMath.random(), which is predictable — a guessable code lets an attacker verify an account registered against someone else's email/phone. Nowcrypto.randomInt(100000, 1000000).backend/controllers/key_controller.js—generateMcElieseKey()produced ~13 chars ofMath.random().toString(36); now 32 bytes ofcrypto.randomBytes(base64url). Note: despite the name, this is a random token generator, not an actual McEliece implementation — if real post-quantum keys are intended, that's a separate work item.All three files pass
node --check. Remaining open CodeQL findings (path injection inmodels/message.js, missing rate limiting on eight routes, workflow permissions) are deliberately not in this PR — happy to follow up separately.🤖 Generated with Claude Code