summaryrefslogtreecommitdiff
path: root/yhttpd/src
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-30 12:32:36 +0300
committerPaul Buetow <paul@buetow.org>2026-06-30 12:32:36 +0300
commita0a881fb8ddd48a51292af1af85708b4c3593804 (patch)
tree5e7beb07bb8740d45a4c9a10829b3416556c67b2 /yhttpd/src
parent77c23e337ae5b4c0d37bea153dd1497fb3d3507b (diff)
Fix predictable/colliding session IDs (same-second login crash + hijacking)
sman::generate_id seeded rand() per call with time(0)+chat.session.kloakkey. Two problems: (1) two logins in the same wall-clock second produced identical tmpids; the collision retry then re-seeded with the same time and recursed forever -> stack overflow (SIGSEGV) -> DoS. (2) IDs were predictable (time-based seed + weak rand) -> session hijacking. Fix: generate IDs from /dev/urandom (one-time rand() fallback seeded with time^getpid, seeded once, not per call), and replace the unbounded recursion with a bounded retry loop (8 attempts). The give-up path returns a final candidate only if it does not collide (never overwriting/ leaking an existing session), else returns empty so login degrades gracefully instead of crashing. Also clear the urandom stream's failbit on a failed read so a transient failure self-heals, and guard i_len<=0. The runtime-disabled (md5hash=false) md5 transform block is left as-is; its separate bad-substr bug is out of scope here. Verified: 15 rapid same-second logins no longer crash (0 restarts); IDs are distinct; normal login + chat streaming still work. Independent fresh-context review: APPROVE-WITH-NITS; the give-up/leak, urandom-stuck, and i_len nits were addressed.
Diffstat (limited to 'yhttpd/src')
0 files changed, 0 insertions, 0 deletions