szn

Bug 69 — Stack buffer overflow in Client.sendPacket

69. Stack buffer overflow in Client.sendPacket

File: src/client/client.zig:46–52 Severity: HIGH Status: ✅ FIXED — added bounds check for 5 + data.len > 4096 before serializing into fixed stack buffer. Unit test added.

fn sendPacket(self: *Client, msg_type: protocol.MessageType, data: []const u8) Error!void {
    const pkt = protocol.Packet.make(msg_type, data);
    var buf: [4096]u8 = undefined;
    const serialized = pkt.serialize(&buf);  // no bounds check

serialize writes 5 + data.len bytes into a fixed 4096-byte stack buffer with zero bounds checking. If data ≥ 4091 bytes, @memcpy writes past the end of the stack buffer. In ReleaseFast this corrupts the stack.