Security, stability & quality quick wins from codebase audit - #181
Open
Sparksx wants to merge 1 commit into
Open
Security, stability & quality quick wins from codebase audit#181Sparksx wants to merge 1 commit into
Sparksx wants to merge 1 commit into
Conversation
Security: - Hash refresh tokens (SHA-256) before DB storage so a DB leak doesn't expose raw session tokens - Rate-limit the /api/auth/refresh endpoint (was unprotected) - Check active bans during login (banned users could still auth) - Use distinct JWT dev secrets for access vs refresh tokens - Enable Content-Security-Policy via Helmet (was disabled) - Restrict usernames to alphanumeric + underscore/hyphen/space - Move one-time pack check inside try/catch in payment route Stability: - Remove competing SIGINT/SIGTERM handlers from prisma.js; server/index.js now owns the full graceful-shutdown sequence - Wrap clan-leave in a transaction to prevent orphaned state when the owner leaves and ownership transfer is needed Bug fixes: - Fix starting gold: auth.js created new users with 0 gold instead of STARTING_GOLD (100) - Fix manifest.json theme_color mismatch with CSS --bg (#0e0b1a) - Fix manifest description (no longer references dungeons) - Fix French error messages in sprites route → English Cleanup: - Remove dead shopState destructuring from game state route - Cache Stripe client as a singleton (was re-created per call) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGK2HsyBdEjDkgY2eCSUDF
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
Full codebase audit across security, performance, stability, and functionality — this PR implements the highest-priority quick wins (13 fixes across 9 files).
Security (7 fixes)
/api/auth/refresh— was the only auth endpoint without the 5/min limitercontentSecurityPolicy: false)[a-zA-Z0-9_ -]on both register and change-usernameStability (2 fixes)
prisma.js— it calledprocess.exit(0)beforeserver/index.jscould close sockets and HTTP server gracefullyBug fixes (4 fixes)
createDefaultGameStatein auth.js usedgold: 0instead ofSTARTING_GOLD(100), so new registered users started with no gold#1a1a2e, now matches CSS--bg(#0e0b1a)Cleanup (2 fixes)
shopStatedestructuring from game state routeTest plan
npm test)npm run lint)npm run build)🤖 Generated with Claude Code
https://claude.ai/code/session_01LGK2HsyBdEjDkgY2eCSUDF
Generated by Claude Code