Security, stability & performance quick wins - #168
Open
Sparksx wants to merge 1 commit into
Open
Conversation
Security: - Enable Content-Security-Policy in production (was disabled) - Add explicit algorithms: ['HS256'] to all jwt.verify() calls - Add per-socket rate limiting on chat:player-profile and chat:request-history Stability: - Wrap clan leave + ownership transfer in a single interactive transaction - Fix mission progress race condition using interactive transaction with fresh read (prevents double-completion and XP duplication) - Fix event listener leak in home.js (CHAT_UPDATED added on every render without cleanup) Performance: - Cache PvP leaderboard for 30s (invalidated on rated fights) - Move socket.io-client from devDependencies to dependencies Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018UFcpKe77wqjaqWHNPnaZz
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
Comprehensive analysis of the game across 4 axes (security, stability, performance, functionality) followed by implementation of the highest-priority quick wins.
Changes
Security
server/index.js) — was fully disabled (contentSecurityPolicy: false), now enforcesdefault-src 'self'with targeted exceptions for Stripe checkout and Google OAuthserver/middleware/auth.js,server/routes/auth.js) — alljwt.verify()calls now specifyalgorithms: ['HS256']to prevent algorithm substitution attacksserver/socket/chat.js) — added per-socket rate limits onchat:player-profile(10/10s) andchat:request-history(5/5s) to prevent abuse and information enumerationStability
server/routes/clans.js) — member deletion + ownership transfer + clan disband now wrapped in a single interactive transaction (was sequential, risked leaderless clans on crash)server/routes/clans.js) — mission progress reporting now uses an interactive transaction with a fresh read of mission state, preventing concurrent requests from double-completing a mission and duplicating clan XPsrc/screens/home.js) —CHAT_UPDATEDlistener was added on everyrender()call without cleanup; now properly removes the previous listener before adding a new onePerformance
server/routes/pvp.js) — 30-second in-memory cache, invalidated on rated fights. Eliminates redundant DB queries for mostly-static datapackage.json) — moved fromdevDependenciestodependencies(correct classification for a runtime dependency)Test plan
npm test)npm run lint)npm run build)🤖 Generated with Claude Code
https://claude.ai/code/session_018UFcpKe77wqjaqWHNPnaZz
Generated by Claude Code