Fix review findings: proto smuggling, trade-leg recall, escrow cap, static headers, rate limits, rankings DoS

Fixed: validator rejects __proto__/constructor keys at any depth (transport capacity bypass); trade and site shipments
cannot be recalled; trade escrow refund capped by Rack hall; CSP/nosniff on static files and connect-src 'self';
IPv6 /64 limiter keys + LRU eviction + per-username login bucket + scrypt concurrency cap; 5 s footprint cache for
rankings; rename uses text.cleanText; 429s no longer pinned in the idempotency store; 30-day notification prune;
units_offline notification on first offline. Accepted items listed in docs/DECISIONS.md R1.
Tested: npm test 182/182 incl. test/review-fixes.test.js (regression tests). Not re-reviewed after the fixes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
jvanvik 2026-10-11 19:06:51 +02:00
parent b18645dca1
commit d84b0c9d12
11 changed files with 190 additions and 17 deletions

View file

@ -21,7 +21,15 @@ function createSocialQueries({ db, clock, scheduler }) {
// ---------------------------------------------------------------- footprint (rankings and alliance sums)
// operatorId -> { footprint, towns } for a whole world, from two queries (no per-town round trips).
const fpCache = new Map(); // worldId -> { at, map }: a whole-world scan is O(towns), so reads share one for 5 s
function footprints(worldId, now) {
const hit = fpCache.get(worldId);
if (hit && now >= hit.at && now - hit.at < 5000) return hit.map;
const map = footprintsScan(worldId, now);
fpCache.set(worldId, { at: now, map });
return map;
}
function footprintsScan(worldId, now) {
const world = loadWorld(db, worldId);
const towns = new Map();
for (const t of db.all('SELECT id, owner_id, footprint, res_at FROM towns WHERE world_id = ?', worldId)) {