Skip to content

fix(security): CSPRNG password gen + gate /uploads behind auth (P1 lows) - #15

Merged
sathyaprakash000 merged 1 commit into
mainfrom
fix/authz-low-hardening
May 25, 2026
Merged

fix(security): CSPRNG password gen + gate /uploads behind auth (P1 lows)#15
sathyaprakash000 merged 1 commit into
mainfrom
fix/authz-low-hardening

Conversation

@sathyaprakash000

@sathyaprakash000 sathyaprakash000 commented May 25, 2026

Copy link
Copy Markdown
Contributor

What & why

P1 leftover hardening (review lane 02 LOWs):

  1. generatePassword used Math.random() — not cryptographically secure. The one-time password generated for new users is now produced with crypto.randomInt().
  2. /uploads was served before auth — BDA profile images were anonymously fetchable by guessing a (random-ish) filename. Now gated behind authMiddleware (cookies are sent on same-origin <img> requests, so the authenticated SPA is unaffected).

Verification

  • node --check on index.js + users.js
  • npm test → 20/20 backend tests pass.

- users.js generatePassword: use crypto.randomInt instead of Math.random for
  the one-time generated user password (CSPRNG, not predictable).
- index.js: serve /uploads (BDA profile images) behind authMiddleware so the
  files can't be fetched anonymously by guessing a filename.

Addresses lane 02 LOWs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: KingArthur000 <sathyaprakashelango@gmail.com>
@sathyaprakash000
sathyaprakash000 merged commit b87d33f into main May 25, 2026
11 checks passed
@sathyaprakash000
sathyaprakash000 deleted the fix/authz-low-hardening branch May 25, 2026 04:12
Sign up for free to 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.

1 participant