mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-17 22:31:26 +02:00
Adversarial multi-agent review of the launch candidate produced 22 confirmed
findings (12 more were refuted). This closes the critical, high, and the
mediums/lows that are cheap and real, then does the iso/3D/Tavern art pass.
CRITICAL — unauthenticated remote kill switch
Socket.IO does not wrap listener invocation, and this process treats
uncaughtException/unhandledRejection as fatal, so ONE unguarded throw in ANY
listener exits the server. `socket.emit('debug_ping')` with no argument did
exactly that, and systemd restarts straight back into it. Every registration
in handleConnection now goes through a safe-dispatch wrapper that contains
sync throws and rejected promises to the offending socket; handleDebugPing
also stops trusting its payload.
HIGH
- NIP-98 login now binds the signed event to this deployment's host. The path
check alone let an event signed for any other origin authenticate here, and
linking ADOPTS the account owning that pubkey — full account takeover.
- Fog of war is enforced server-side. getState() shipped absolute
entrance/exit/treasure coordinates and the monster's exact position in every
frame, with concealment implemented only in the browser. Discovery is sticky;
the monster is reported only while in view.
- NODE_ENV must now be explicit and recognized. Unset, every production gate
read false while DebugManager reported production and silenced logging.
- Tavern chat applies the lobby's ban list, rate limiter and user_id
attribution before entering global chat.
- userRegistry is deleted by socket.id (it was keyed by socket.id and deleted
by socket.client.id, so nothing was ever freed).
MEDIUM / LOW
- Payouts: a legitimately split transfer_split kept its transaction hashes
instead of quarantining already-broadcast funds with tx_hash NULL, and
provably pre-broadcast failures return to 'pending' rather than needs_review.
- RateLimiter key parsing fixed — cleanup() freed nothing and expired windows
never reset, because ids contain colons.
- Enter no longer submits a paid entry from behind a modal.
- Lobby chat no longer double-escapes server-escaped text.
- Rate limits for identity:get / address:prompt / early_entry.
- Spectators released when a game ends by disconnect, not just settlement.
- movementManager / addressManager per-socket maps cleaned on disconnect.
Renderers
Iso: opaque shading instead of translucent fog, additive torch/lantern/beacon
light pools, crevice AO, embers, cold memory wash, and it stops reallocating
the whole canvas every animation frame.
3D: instanced level geometry (3 draw calls), procedural stone/flagstone
materials, torch lights + shadows, real meshes for stairs/chest/monster
(they were humanoid capsules), dust motes, wall cutaway, and lighting
rebalanced now that fog is measured from the camera.
Tavern
Block height and hash fragments drift around the stage edge and ripple when a
block lands, fed by a cosmetic chain tip added to the blockheight broadcast.
Speech bubbles work again (they keyed off a socketId the server stopped
sending).
126 suites / 1005 tests pass.
66 lines
2.8 KiB
JavaScript
66 lines
2.8 KiB
JavaScript
/**
|
|
* Rate-limiter storage-key resolution.
|
|
*
|
|
* Keys are `${id}:${action}`, and the id itself contains colons: `u:<userId>` / `s:<socketId>` from
|
|
* rateLimitContext.stableId, plus raw IPv6 addresses in ipStorage. The old key parser stripped only
|
|
* the first `:`-delimited segment, so `u:123:chat:message` resolved to the action `123:chat:message`
|
|
* and matched nothing. Both consequences were silent:
|
|
*
|
|
* - `cleanup()` skips entries whose limit it cannot resolve, so the ONLY registered memory
|
|
* reclamation freed nothing and both Maps grew for the lifetime of the process;
|
|
* - `_recordSingleAttempt` never reset an expired window, so counts accumulated forever.
|
|
*/
|
|
|
|
const RateLimiter = require('../src/network/rateLimiter');
|
|
|
|
describe('rate limiter key resolution', () => {
|
|
let limiter;
|
|
beforeEach(() => { limiter = new RateLimiter(); });
|
|
afterEach(() => { if (limiter.shutdown) limiter.shutdown(); });
|
|
|
|
test.each([
|
|
['stable user id', 'u:123:chat:message', 'chat:message'],
|
|
['socket-scoped id', 's:AbCdEf123456:game:queue', 'game:queue'],
|
|
['bare IPv4', '203.0.113.9:chat:message', 'chat:message'],
|
|
['IPv6 (colon-dense)', '2001:db8:85a3::8a2e:370:7334:chat:message', 'chat:message']
|
|
])('resolves the configured limit for a %s key', (_label, key, action) => {
|
|
expect(limiter._getLimitFromKey(key)).toBe(limiter.limits[action]);
|
|
});
|
|
|
|
test('returns undefined for a key with no configured action', () => {
|
|
expect(limiter._getLimitFromKey('u:123:not:a:real:action')).toBeUndefined();
|
|
});
|
|
|
|
test('cleanup() actually frees expired entries for realistic keys', () => {
|
|
const key = 'u:456:chat:message';
|
|
const window = limiter.limits['chat:message'].window;
|
|
limiter.storage.set(key, { count: 9, firstAttempt: Date.now() - window - 1000 });
|
|
limiter.ipStorage.set('2001:db8::1:chat:message', {
|
|
count: 4, firstAttempt: Date.now() - window - 1000
|
|
});
|
|
|
|
limiter.cleanup();
|
|
|
|
expect(limiter.storage.has(key)).toBe(false);
|
|
expect(limiter.ipStorage.size).toBe(0);
|
|
});
|
|
|
|
test('cleanup() leaves entries whose window is still open', () => {
|
|
const key = 'u:789:chat:message';
|
|
limiter.storage.set(key, { count: 1, firstAttempt: Date.now() });
|
|
limiter.cleanup();
|
|
expect(limiter.storage.has(key)).toBe(true);
|
|
});
|
|
|
|
test('an expired window resets the count instead of accumulating forever', () => {
|
|
const action = 'chat:message';
|
|
const key = `u:321:${action}`;
|
|
const window = limiter.limits[action].window;
|
|
limiter.storage.set(key, { count: 999, firstAttempt: Date.now() - window - 1000 });
|
|
|
|
limiter._recordSingleAttempt(key, Date.now());
|
|
|
|
expect(limiter.storage.get(key).count).toBe(1);
|
|
});
|
|
});
|