Commit graph

5 commits

Author SHA1 Message Date
Stephen Dennis
9674b6d834 fix: resolve Pass 4 Hydra High audit defects #1091–#1094
- #1091: saveSession uses ON CONFLICT upsert so REPLACE cannot CASCADE-wipe scrollback
- #1092: loadFromDb keeps memoryBytes_ in lockstep with append() (no size_t underflow)
- #1093: reset lenBytesRead before MaskKey after extended length (no maskKey OOB)
- #1094: deliver WS CLOSE (and protocol errors) so session paths close the FD;
  complete zero-length payloads after the mask key (empty CLOSE)

proxy_regression: ok (ext-len mask + CLOSE + unmasked teardown)
2026-07-24 17:39:49 -06:00
Stephen Dennis
83136cec4f Fix all four Hydra proxy issues
1. GANL Integration — closed, already fully GANL-based.

2. Status Dumps — add SessionManager::dumpStatus() triggered by
   SIGUSR1. Logs session/link/scrollback state and metrics.

3. Duration Strings — add parseDuration() supporting s/m/h/d
   suffixes. Applied to all timeout config fields.

4. Scrollback Re-encryption — add ScrollBack::reencryptInDb()
   that decrypts with old key and re-encrypts with new key.
   Wire into changePassword() for all sessions owned by the
   account. Signature updated to accept old key and return new.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:28:02 -06:00
Stephen Dennis
706800347f Enforce maxScrollbackMemoryMb with per-session memory tracking
ScrollBack now tracks approximate memory usage (sum of text + source
string sizes) via memoryBytes().  Updated on every append — adds new
line size, subtracts evicted line size when the ring buffer wraps.

SessionManager checks the global total across all sessions before
each append in onBackDoorData().  When the configured limit is hit,
a LOG_WARN fires (once per crossing).  The ring buffer's fixed
capacity continues to evict oldest entries, bounding per-session
growth.  The global check prevents runaway memory from many active
sessions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 18:29:59 -06:00
Stephen Dennis
1167fe2c07 Add scroll-back persistence with AEAD encryption (Phase 1 Step 8)
Encrypt scroll-back lines with AES-256-GCM using the player-derived key
before flushing to SQLite.  Sessions are saved to the saved_sessions
table and restored on login after a Hydra restart.  Flush triggers:
periodic (60s), on detach, and on shutdown.  AAD includes account ID,
session ID, and sequence number to prevent reordering attacks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 12:04:38 -06:00
Stephen Dennis
0c2588e745 Add Hydra proxy skeleton (Phase 1 Step 4)
New mux/proxy/ directory with build infrastructure and stub
implementations for all Phase 1 components: config parser (working),
logging (working), front door, back door, session manager, account
manager (SQLite schema creation working), telnet bridge, and
scroll-back ring buffer (working). Hydra binary builds, links against
libmux.so + libganl.a + libsqlite3.a, reads config, opens database,
logs startup, and exits cleanly.

Integrated into autotools: proxy added to SUBDIRS, Makefile generated
by configure, hydra installed to game/bin alongside netmux. All 665
existing smoke tests pass.

Next: GANL initiateConnect() for outbound connections (Step 1).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 09:05:17 -06:00