Security: Unbounded network allocation allows denial-of-service #187
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: high
Category: security
Location:
src/shared/protocol.c:176,src/shared/chunk.c:160,src/shared/delta.c:111,src/shared/protocol.c:150Description:
Multiple protocol deserialization paths allocate memory based on size or count fields received directly from the network peer without any upper bound:
receive_data()allocatesmalloc((size_t)size)wheresizeis an 8-byte unsigned value from the wire.receive_str()allocatesmalloc(size + 1)wheresizeis asize_tfrom the wire.chunk_deserialize()allocatesmalloc(file_data_size)from a received size field.delta_signature_deserialize()allocatessig->block_count * sizeof(DeltaBlockSig)from a received count.delta_deserialize()allocatesdelta->instruction_count * sizeof(DeltaInstruction)from a received count.A malicious client can send a huge size/count and cause the server to allocate enormous memory, leading to OOM and denial of service. No authentication is required.
Suggested fix:
Add reasonable global and per-message bounds before allocation:
Check
sizeagainstMAX_WIRE_SIZEand available memory heuristics inreceive_data/receive_str. Validate block/instruction counts againstMAX_*limits in delta deserialization.Labels: security, dos