Security, stability and performance quick wins - #178
Open
Sparksx wants to merge 1 commit into
Open
Conversation
Security: - Enable Content-Security-Policy headers in production (was fully disabled) - Hash refresh tokens before storing in DB (SHA-256, not plaintext) - Restrict JWT verify to HS256 algorithm (prevent algorithm confusion) - Add stricter rate limiting on game state saves (30/min) - Server-side gold check for clan creation (was client-only) Stability: - Wrap admin gold/essence/diamonds in transactions (fix race conditions) - Wrap clan leave + ownership transfer in a single transaction - Wrap payment refund clawback in a transaction (prevent negative gold) - Fix new player starting gold: 0 → 100 (STARTING_GOLD) Performance: - Cache Stripe SDK instance (was recreated on every request) - Add aggressive caching for Vite hashed assets (1yr immutable) - Remove redundant DB queries in chat socket handlers (role already on socket) - Add missing index on Purchase.stripePaymentId (used by refund webhook) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uNVMci3uw2PAKcThpwjce
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 codebase audit across security, stability, performance, and functionality — this PR implements the highest-priority quick wins identified.
Security
contentSecurityPolicy: false)Stability
createDefaultGameStateset gold to 0 instead of the intendedSTARTING_GOLD(100)Performance
max-age=1y, immutable) — previously served with no cache headerssocket.user.rolefrom connection middleware; two handlers were re-querying it on every callPurchase.stripePaymentId— used by the refund webhook for lookups, was doing a full table scanTest plan
npm test)npm run lint)npm run build)🤖 Generated with Claude Code
https://claude.ai/code/session_017uNVMci3uw2PAKcThpwjce
Generated by Claude Code