Skip to content

Possible Denial of Service: panic if guest sends packet with len < virtio net header length #577

@nirs

Description

@nirs

The NetWorker thread in the host can panic if a guest sends a virtio-net packet with a total descriptor length less than the virtio-net header size (VNET_HDR_LEN, which is 12 bytes). This happens because the write_frame method (e.g., in the Unixgram backend) attempts to slice the buffer using VNET_HDR_LEN as the start index (&buf[hdr_len..]). If the buffer's length (derived from the guest's descriptor chain) is smaller than hdr_len, Rust will panic. A malicious guest can exploit this to crash the networking worker thread of the host, leading to a Denial of Service.

            self.tx_frame_len = read_count;
            if read_count < VNET_HDR_LEN {
                tx_queue
                    .add_used(&self.mem, head_index, 0)
                    .map_err(TxError::QueueError)?;
                raise_irq = true;
                continue;
            }
            match self
                .backend
                .write_frame(VNET_HDR_LEN, &mut self.tx_frame_buf[..read_count])

Originally posted by @gemini-code-assist[bot] in #574 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions