Skip to content

Security: Heap OOB read in RTCP XR parser - loop lacks bounds check #533

@decsecre583

Description

@decsecre583

Description

The fix for CVE-2024-35434 (commit da80ced) checks header size but the while loop uses attacker-controlled hdr_xr.len without validating each iteration stays in bounds.

To Reproduce

// Vulnerable pattern
if (size < sizeof(struct rtcp_hdr_xr))
    return;  // Header check OK

// But loop uses attacker-controlled len:
while (bsize < (ntohs(hdr_xr.len) + 1) * 4) {
    // No check: bsize + sizeof(blk_xr) <= size
    memcpy(&blk_xr, data + bsize, sizeof(blk_xr));  // OOB
}

Send RTCP XR packet: 8 bytes actual, hdr_xr.len claims 44 bytes.

gcc -fsanitize=address -g -o poc poc.c && ./poc

ASan Output

==25354==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x502000000018
READ of size 4 at 0x502000000018 thread T0
    #0 in process_rtcp_xr_VULNERABLE

0x502000000018 is located 0 bytes to the right of 8-byte region

SUMMARY: AddressSanitizer: heap-buffer-overflow in process_rtcp_xr_VULNERABLE

Fix

while (bsize < (ntohs(hdr_xr.len) + 1) * 4) {
    if (bsize + sizeof(blk_xr) > size)
        break;
    memcpy(&blk_xr, data + bsize, sizeof(blk_xr));
}

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions