Skip to content
DoS Disclosed report Intermediate

RTSP RTP Interleaved Parser Assertion Failure (Zero-Length RTP Payload)

davkor Follow

Originally disclosed on HackerOne

Informational View original
  • Disclosed after 8 hours

Summary:

I am submitting this as a security issue primarily due to how it was discovered and that it's my first Curl submission, but I suspect I might be overly cautious here.

This issue was discovered as part of the AIXCC competition, and I am assisting on reporting true positive findings to upstream repositories, facilitated by way of of OpenSSF and OSTIF.

AI was used to find and root-cause this issue.

The issue is that a debug assertion (https://github.com/curl/curl/blob/3cf86508fdc3f54bb2a3f42c8c0bd464ea39883d/lib/rtsp.c#L784) is triggerable from the curl_fuzzer_rtsp (build from OSS-Fuzz). When I disable that specific assertion and run the crashing input, it passes without issues so I suspect release mode is fine.

Affected version

latest commit on GitHub.

Steps To Reproduce:

Bash
# 1. Clone oss-fuzz (or use existing checkout)
git clone https://github.com/google/oss-fuzz.git
cd oss-fuzz

# 2. Build the curl fuzzers (requires Docker)
python3 infra/helper.py build_fuzzers curl

# 3. Replay against the attached payload
python3 infra/helper.py reproduce curl curl_fuzzer_rtsp /tmp/curl_crash_input.bin
...
Running: /testcase
curl_fuzzer_rtsp: /src/curl/lib/rtsp.c:784: CURLcode rtsp_filter_rtp(struct Curl_easy *, struct rtsp_conn *, const char *, size_t, size_t *): Assertion `rtp_len < rtspc->rtp_len' failed.
AddressSanitizer:DEADLYSIGNAL
=================================================================
==14==ERROR: AddressSanitizer: ABRT on unknown address 0x00000000000e (pc 0x7fde2c69eb2c bp 0x7fff96291630 sp 0x7fff962915f0 T0)
SCARINESS: 10 (signal)
    #0 0x7fde2c69eb2c in pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #1 0x7fde2c64527d in raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527d) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #2 0x7fde2c6288fe in abort (/lib/x86_64-linux-gnu/libc.so.6+0x288fe) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #3 0x7fde2c62881a  (/lib/x86_64-linux-gnu/libc.so.6+0x2881a) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #4 0x7fde2c63b516 in __assert_fail (/lib/x86_64-linux-gnu/libc.so.6+0x3b516) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #5 0x5564d89cb51e in rtsp_filter_rtp /src/curl/lib/rtsp.c:784:7
    #6 0x5564d89c8c8f in rtsp_rtp_write_resp /src/curl/lib/rtsp.c:893:16
    #7 0x5564d8893930 in Curl_xfer_write_resp /src/curl/lib/transfer.c:772:14
    #8 0x5564d888fd2a in sendrecv_dl /src/curl/lib/transfer.c:298:14
    #9 0x5564d888fd2a in Curl_sendrecv /src/curl/lib/transfer.c:370:14
    #10 0x5564d88572a6 in state_performing /src/curl/lib/multi.c:1938:12
    #11 0x5564d88572a6 in multi_runsingle /src/curl/lib/multi.c:2672:17
    #12 0x5564d884e9a2 in multi_perform /src/curl/lib/multi.c:2775:17
    #13 0x5564d87fef55 in fuzz_handle_transfer(fuzz_data*) /src/curl_fuzzer/curl_fuzzer.cc:341:3
    #14 0x5564d87fe317 in LLVMFuzzerTestOneInput /src/curl_fuzzer/curl_fuzzer.cc:97:3
    #15 0x5564d869a57d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    #16 0x5564d8685302 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:329:6
    #17 0x5564d868b1d0 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:865:9
    #18 0x5564d86b6cf2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #19 0x7fde2c62a1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #20 0x7fde2c62a28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    #21 0x5564d867e3e4 in _start (/out/curl_fuzzer_rtsp+0x6723e4)

DEDUP_TOKEN: pthread_kill--raise--abort
==14==Register values:
rax = 0x0000000000000000  rbx = 0x000000000000000e  rcx = 0x00007fde2c69eb2c  rdx = 0x0000000000000006  
rdi = 0x000000000000000e  rsi = 0x000000000000000e  rbp = 0x00007fff96291630  rsp = 0x00007fff962915f0  
 r8 = 0x00000000000000bc   r9 = 0x00007e1e2b7e0000  r10 = 0x0000000000000008  r11 = 0x0000000000000246  
r12 = 0x0000000000000006  r13 = 0x00005564d955a520  r14 = 0x0000000000000016  r15 = 0x00005564d955b200  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb) in pthread_kill

Root Cause

The RTSP protocol supports interleaving RTP data within the TCP connection using a $-framed binary format (RFC 2326, Section 10.12):

  '$' <1-byte channel> <2-byte big-endian length> <length bytes of data>

curl's RTP interleaved parser (rtsp_filter_rtp) uses a 4-state machine:

  1. RTP_PARSE_SKIP — scanning for $ frame start
  2. RTP_PARSE_CHANNEL — reading the 1-byte channel number
  3. RTP_PARSE_LEN — reading the 2-byte payload length field
  4. RTP_PARSE_DATA — reading the RTP payload data

The bug is in the transition from RTP_PARSE_LEN to RTP_PARSE_DATA.

In RTP_PARSE_LEN (line 762), once both length bytes have been collected (buffer contains 4 bytes: $, channel, len_hi, len_lo), the expected total frame size is computed:

C
rtspc->rtp_len = RTP_PKT_LENGTH(rtp_buf) + 4;

Where RTP_PKT_LENGTH extracts the 16-bit big-endian value from bytes 2-3:

C
#define RTP_PKT_LENGTH(p) ((((unsigned int)((unsigned char)((p)[2]))) << 8) | \
                            ((unsigned int)((unsigned char)((p)[3]))))

When the payload length field is 0x0000 (zero):

  • RTP_PKT_LENGTH(rtp_buf) returns 0
  • rtspc->rtp_len = 0 + 4 = 4
  • The dynamic buffer (rtspc->buf) already contains exactly 4 bytes ($ + channel + 2 length bytes)
  • State transitions to RTP_PARSE_DATA

In RTP_PARSE_DATA (line 781):

  • rtp_len = curlx_dyn_len(&rtspc->buf) → 4
  • rtspc->rtp_len → 4
  • DEBUGASSERT(rtp_len < rtspc->rtp_len) → DEBUGASSERT(4 < 4) → FAILS

The assertion correctly detects an invariant violation: the parser entered the "read data" state when there is no data to read.

Impact

Summary:

The impact is that in debug builds an assertion is triggerable. In release builds, as far as I can tell, the issue does not have adverse effect other than the rtsp_filter_rtp state machine processes an invalid zero-length RTP frame and delivers a 4-byte header to the RTP write callback as if they were valid RTP data.

I considered making this public due to issues such as https://github.com/curl/curl/issues/12701 but, again, I'm being a bit cautious here. I am happy to submit this issue on GitHub if Curl maintainers confirm it's okay to do so.

The original report as published on HackerOne, by davkor. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

curl speaks RTSP, and RTSP allows RTP data to be interleaved with the control traffic on the same TCP connection. Each interleaved frame is a small binary envelope: a $ byte, a one-byte channel number, a two-byte big-endian length, and then that many bytes of payload. The parser that handles this in curl is rtsp_filter_rtp in lib/rtsp.c, and it is written as a four-state machine that walks the incoming byte stream looking for frame boundaries.

The report concerns a debug assertion inside that state machine. The author is explicit that this is a debug-build issue: the assertion fires, but with the assertion disabled the same input runs through without problems, so release builds are, as far as the author can tell, not affected in the same way.

The finding came out of the AIXCC competition. The author was helping report true positive findings upstream, facilitated through OpenSSF and OSTIF, and notes that AI was used both to find and to root-cause the issue. It is submitted as a security issue mainly because of how it was discovered, and the author says plainly that they may be overly cautious.

Setup

The affected version is described only as the latest commit on GitHub at the time of writing. The target is the curl_fuzzer_rtsp harness built from OSS-Fuzz, and the reproduction uses the OSS-Fuzz helper tooling, which requires Docker.

The assertion in question lives at a specific line of lib/rtsp.c in commit [redacted]:

Text
https://github.com/curl/curl/blob/[redacted]/lib/rtsp.c#L784

The reproduction is driven by a saved crashing input replayed into the fuzzer.

Finding it

The issue was found with AI assistance and root-caused with AI, as part of the AIXCC competition: a debug assertion in the RTSP RTP interleaved parser can be triggered from the curl_fuzzer_rtsp harness. The assertion is:

C
DEBUGASSERT(rtp_len < rtspc->rtp_len)

What made it worth reporting is the invariant behind it: the parser should only be in the state that reads payload data when there is payload data to read. An input that drives it into that state with nothing left to read is violating the parser's own model of the stream, even if the practical consequence in a release build is small.

Exploitation

Step 1: get OSS-Fuzz and build the curl fuzzers

Bash
git clone https://github.com/google/oss-fuzz.git
cd oss-fuzz
Bash
python3 infra/helper.py build_fuzzers curl

The first block clones the OSS-Fuzz repository and moves into it. The second builds the curl fuzzers through the helper script, which uses Docker underneath.

Step 2: replay the crashing input

Bash
python3 infra/helper.py reproduce curl curl_fuzzer_rtsp /tmp/curl_crash_input.bin

This runs the saved input against the curl_fuzzer_rtsp target. The report shows the output truncated with ... before the interesting part, and what comes back is an abort:

Text
Running: /testcase
curl_fuzzer_rtsp: /src/curl/lib/rtsp.c:784: CURLcode rtsp_filter_rtp(struct Curl_easy *, struct rtsp_conn *, const char *, size_t, size_t *): Assertion `rtp_len < rtspc->rtp_len' failed.
AddressSanitizer:DEADLYSIGNAL
=================================================================
==14==ERROR: AddressSanitizer: ABRT on unknown address 0x00000000000e (pc 0x7fde2c69eb2c bp 0x7fff96291630 sp 0x7fff962915f0 T0)
SCARINESS: 10 (signal)
    #0 0x7fde2c69eb2c in pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c) (BuildId: [redacted])
    #1 0x7fde2c64527d in raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527d) (BuildId: [redacted])
    #2 0x7fde2c6288fe in abort (/lib/x86_64-linux-gnu/libc.so.6+0x288fe) (BuildId: [redacted])
    #3 0x7fde2c62881a  (/lib/x86_64-linux-gnu/libc.so.6+0x2881a) (BuildId: [redacted])
    #4 0x7fde2c63b516 in __assert_fail (/lib/x86_64-linux-gnu/libc.so.6+0x3b516) (BuildId: [redacted])
    #5 0x5564d89cb51e in rtsp_filter_rtp /src/curl/lib/rtsp.c:784:7
    #6 0x5564d89c8c8f in rtsp_rtp_write_resp /src/curl/lib/rtsp.c:893:16
    #7 0x5564d8893930 in Curl_xfer_write_resp /src/curl/lib/transfer.c:772:14
    #8 0x5564d888fd2a in sendrecv_dl /src/curl/lib/transfer.c:298:14
    #9 0x5564d888fd2a in Curl_sendrecv /src/curl/lib/transfer.c:370:14
    #10 0x5564d88572a6 in state_performing /src/curl/lib/multi.c:1938:12
    #11 0x5564d88572a6 in multi_runsingle /src/curl/lib/multi.c:2672:17
    #12 0x5564d884e9a2 in multi_perform /src/curl/lib/multi.c:2775:17
    #13 0x5564d87fef55 in fuzz_handle_transfer(fuzz_data*) /src/curl_fuzzer/curl_fuzzer.cc:341:3
    #14 0x5564d87fe317 in LLVMFuzzerTestOneInput /src/curl_fuzzer/curl_fuzzer.cc:97:3
    #15 0x5564d869a57d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    #16 0x5564d8685302 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:329:6
    #17 0x5564d868b1d0 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:865:9
    #18 0x5564d86b6cf2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #19 0x7fde2c62a1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: [redacted])
    #20 0x7fde2c62a28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: [redacted])
    #21 0x5564d867e3e4 in _start (/out/curl_fuzzer_rtsp+0x6723e4)

DEDUP_TOKEN: pthread_kill--raise--abort
==14==Register values:
rax = 0x0000000000000000  rbx = 0x000000000000000e  rcx = 0x00007fde2c69eb2c  rdx = 0x0000000000000006
rdi = 0x000000000000000e  rsi = 0x000000000000000e  rbp = 0x00007fff96291630  rsp = 0x00007fff962915f0
 r8 = 0x00000000000000bc   r9 = 0x00007e1e2b7e0000  r10 = 0x0000000000000008  r11 = 0x0000000000000246
r12 = 0x0000000000000006  r13 = 0x00005564d955a520  r14 = 0x0000000000000016  r15 = 0x00005564d955b200
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c) (BuildId: [redacted]) in pthread_kill

The stack is short and direct: rtsp_filter_rtp at lib/rtsp.c:784 is called from rtsp_rtp_write_resp at line 893, which is reached through Curl_xfer_write_resp and the normal transfer machinery (sendrecv_dl, Curl_sendrecv, state_performing, multi_runsingle, multi_perform), and finally from the fuzzer's fuzz_handle_transfer and LLVMFuzzerTestOneInput. The abort is the assertion failure itself, surfaced by AddressSanitizer as ABRT.

Root cause

The interleaved RTP framing is defined by RFC 2326, Section 10.12, and the report lays it out as:

Text
  '$' <1-byte channel> <2-byte big-endian length> <length bytes of data>

curl's parser walks this with four states:

  1. RTP_PARSE_SKIP, scanning for the $ frame start
  2. RTP_PARSE_CHANNEL, reading the one-byte channel number
  3. RTP_PARSE_LEN, reading the two-byte payload length field
  4. RTP_PARSE_DATA, reading the RTP payload data

The bug sits in the transition from RTP_PARSE_LEN to RTP_PARSE_DATA. In RTP_PARSE_LEN (line 762), once both length bytes have been collected, the buffer holds four bytes: $, channel, length high byte, length low byte. The expected total frame size is then computed as:

C
rtspc->rtp_len = RTP_PKT_LENGTH(rtp_buf) + 4;

RTP_PKT_LENGTH extracts the 16-bit big-endian value from bytes 2 and 3:

C
#define RTP_PKT_LENGTH(p) ((((unsigned int)((unsigned char)((p)[2]))) << 8) | \
                            ((unsigned int)((unsigned char)((p)[3]))))

When the length field is 0x0000, the arithmetic lines up badly:

  • RTP_PKT_LENGTH(rtp_buf) returns 0
  • rtspc->rtp_len becomes 0 + 4 = 4
  • the dynamic buffer rtspc->buf already contains exactly those 4 bytes
  • the state moves to RTP_PARSE_DATA

In RTP_PARSE_DATA (line 781) the comparison is then made between two equal numbers:

  • rtp_len = curlx_dyn_len(&rtspc->buf) is 4
  • rtspc->rtp_len is 4
  • DEBUGASSERT(rtp_len < rtspc->rtp_len) becomes DEBUGASSERT(4 < 4), which fails

The parser has entered the read-data state when there is no data to read, and the assertion is doing exactly its job by catching that invariant violation.

Impact

The author's own assessment is narrow. In debug builds, an assertion is triggerable. In release builds, as far as the author can tell, there is no adverse effect beyond the state machine processing an invalid zero-length RTP frame and delivering a 4-byte header to the RTP write callback as if it were valid RTP data.

The author also notes having considered making the issue public, citing other curl issues such as https://github.com/curl/curl/issues/12701, but chose to be cautious, and offers to file the issue on GitHub if the curl maintainers confirm that is acceptable.

Fix

The report does not propose or describe a fix.

  1. Zero-length frames on other interleaved parsers. Send a frame header whose declared length is 0x0000 and check whether the parser enters its data state anyway. A positive result is an assertion, an abort, or a callback invoked with only the header bytes.
  2. Boundary lengths around the header size. Try lengths of 0, 1 and values that make the computed total equal the number of bytes already buffered, and watch for off-by-header-size comparisons of the same shape as rtp_len < rtspc->rtp_len.
  3. Split delivery of the length field. Feed the $, channel and the two length bytes across separate reads so the state machine transitions on partial buffers, and check whether the length computation and the buffer length can be made to agree exactly at the transition.
  4. Truncated frames followed by a new $. Deliver a header promising payload, then a $ before the payload arrives, and see whether the parser resynchronises or mis-frames the next packet.
  5. The same input against a release build. Replay the crashing input with assertions disabled to confirm the reported behaviour, namely that it passes and only the write callback sees the header bytes.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

curl is a very widely used program for moving data between computers. It is the tool behind a lot of the downloads and web requests that other software makes on your behalf, and it is also a library that other programs embed. Among the many ways it can talk to a server is a protocol called RTSP, which is the kind of protocol used to control streaming media, for example a video player asking a camera or a media server to start, pause or stop a stream.

RTSP has a feature where two kinds of traffic can share one connection. The control messages ("start playing", "stop") and the actual media data travel down the same pipe, one after the other, and the receiver has to tell them apart. To do that, the media data is wrapped in a small envelope: a marker byte, a channel number, a length, and then the data itself. curl contains a piece of code whose only job is to open these envelopes as the bytes arrive. That piece of code is called a parser.

This report is about a mistake in that parser. When the envelope says "the data inside me is zero bytes long", the parser still moves on to the step where it reads the data, even though there is nothing to read. In a special kind of build of curl used for testing, called a debug build, the code contains a self-check that notices this impossible situation and deliberately stops the program. The issue was found with AI assistance as part of the AIXCC competition, and reported upstream. The author is upfront that this is a debug-build problem: with the self-check switched off, the same input runs through without trouble, so ordinary release builds are, as far as the author can tell, not affected in the same way.

The finding came out of a competition called AIXCC. The author was helping to report genuine findings back to the projects that own the code, with help arranged through two organisations, OpenSSF and OSTIF, and notes that artificial intelligence was used both to find the problem and to work out its cause. The author says they are submitting it as a security issue mainly because of how it was discovered, and admits they may be overly cautious.

The setup

The affected version is described only as the latest commit on GitHub at the time of writing. A commit is a saved snapshot of a code project; "latest commit" means the newest state of the code, not a numbered release.

The target is a fuzzer. A fuzzer is a program that feeds huge numbers of generated or mutated inputs into another program to see whether any of them make it crash. The specific one here is called curl_fuzzer_rtsp, and it is built from OSS-Fuzz, a Google-run service that continuously fuzzes open-source projects. The reproduction uses OSS-Fuzz's helper tooling, which needs Docker. Docker is software that runs a pre-packaged environment (a "container") so that the build works the same way on any machine.

The self-check in question lives at a specific line of the file lib/rtsp.c, in commit [redacted]:

Text
https://github.com/curl/curl/blob/[redacted]/lib/rtsp.c#L784

This is a link to the exact version of the file on GitHub, with #L784 pointing at line 784. Pinning the commit matters because code changes over time; a link to a moving branch could point at different code tomorrow.

The reproduction is driven by a saved input file that made the fuzzer crash, replayed into the fuzzer again.

Finding it

The issue was found with AI assistance during the AIXCC competition: a debug self-check in the RTSP RTP interleaved parser can be triggered from the curl_fuzzer_rtsp harness. A harness is the thin wrapper that connects a fuzzer to the code under test: it takes the raw bytes the fuzzer produces and feeds them into curl as if they had arrived from a network connection.

The self-check is this line:

C
DEBUGASSERT(rtp_len < rtspc->rtp_len)

In plain words: "in debug builds, stop the program unless the number of bytes actually held (rtp_len) is strictly smaller than the number of bytes the frame is supposed to contain (rtspc->rtp_len)". DEBUGASSERT is a macro, a shorthand that the compiler expands into a check; in debug builds it aborts the program when the condition is false, and in release builds it is typically compiled away to nothing.

What made it worth reporting is the rule behind the check. The parser should only be in the state that reads payload data when there is payload data to read. An input that drives it into that state with nothing left to read breaks the parser's own model of the stream, even if the practical consequence in a release build is small.

Reproducing it

Step 1: get OSS-Fuzz and build the curl fuzzers

Bash
git clone https://github.com/google/oss-fuzz.git
cd oss-fuzz

Line by line:

  1. git clone https://github.com/google/oss-fuzz.git downloads a full copy of the OSS-Fuzz project from GitHub. Git is the version-control system that stores code history; cloning makes a local copy you can work in.
  2. cd oss-fuzz changes the current directory into the folder that was just downloaded, so the next commands run in the right place.
Bash
python3 infra/helper.py build_fuzzers curl

This runs OSS-Fuzz's helper script with Python 3 and tells it to build the fuzzers for the project named curl. Underneath, the helper uses Docker to assemble the right compiler, libraries and settings. The reason for this step is that you cannot replay a crash without first having the exact program that crashed.

Step 2: replay the crashing input

Bash
python3 infra/helper.py reproduce curl curl_fuzzer_rtsp /tmp/curl_crash_input.bin

This asks the same helper to reproduce a crash: the project is curl, the target is curl_fuzzer_rtsp, and the saved input is the file /tmp/curl_crash_input.bin. Replaying a saved input is how you confirm that a crash is real and repeatable rather than a one-off fluke.

The report shows the output truncated with ... before the interesting part, and what comes back is an abort:

Text
Running: /testcase
curl_fuzzer_rtsp: /src/curl/lib/rtsp.c:784: CURLcode rtsp_filter_rtp(struct Curl_easy *, struct rtsp_conn *, const char *, size_t, size_t *): Assertion `rtp_len < rtspc->rtp_len' failed.
AddressSanitizer:DEADLYSIGNAL
=================================================================
==14==ERROR: AddressSanitizer: ABRT on unknown address 0x00000000000e (pc 0x7fde2c69eb2c bp 0x7fff96291630 sp 0x7fff962915f0 T0)
SCARINESS: 10 (signal)
    #0 0x7fde2c69eb2c in pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c) (BuildId: [redacted])
    #1 0x7fde2c64527d in raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527d) (BuildId: [redacted])
    #2 0x7fde2c6288fe in abort (/lib/x86_64-linux-gnu/libc.so.6+0x288fe) (BuildId: [redacted])
    #3 0x7fde2c62881a  (/lib/x86_64-linux-gnu/libc.so.6+0x2881a) (BuildId: [redacted])
    #4 0x7fde2c63b516 in __assert_fail (/lib/x86_64-linux-gnu/libc.so.6+0x3b516) (BuildId: [redacted])
    #5 0x5564d89cb51e in rtsp_filter_rtp /src/curl/lib/rtsp.c:784:7
    #6 0x5564d89c8c8f in rtsp_rtp_write_resp /src/curl/lib/rtsp.c:893:16
    #7 0x5564d8893930 in Curl_xfer_write_resp /src/curl/lib/transfer.c:772:14
    #8 0x5564d888fd2a in sendrecv_dl /src/curl/lib/transfer.c:298:14
    #9 0x5564d888fd2a in Curl_sendrecv /src/curl/lib/transfer.c:370:14
    #10 0x5564d88572a6 in state_performing /src/curl/lib/multi.c:1938:12
    #11 0x5564d88572a6 in multi_runsingle /src/curl/lib/multi.c:2672:17
    #12 0x5564d884e9a2 in multi_perform /src/curl/lib/multi.c:2775:17
    #13 0x5564d87fef55 in fuzz_handle_transfer(fuzz_data*) /src/curl_fuzzer/curl_fuzzer.cc:341:3
    #14 0x5564d87fe317 in LLVMFuzzerTestOneInput /src/curl_fuzzer/curl_fuzzer.cc:97:3
    #15 0x5564d869a57d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    #16 0x5564d8685302 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:329:6
    #17 0x5564d868b1d0 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:865:9
    #18 0x5564d86b6cf2 in main (/src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10)
    #19 0x7fde2c62a1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: [redacted])
    #20 0x7fde2c62a28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: [redacted])
    #21 0x5564d867e3e4 in _start (/out/curl_fuzzer_rtsp+0x6723e4)

DEDUP_TOKEN: pthread_kill--raise--abort
==14==Register values:
rax = 0x0000000000000000  rbx = 0x000000000000000e  rcx = 0x00007fde2c69eb2c  rdx = 0x0000000000000006
rdi = 0x000000000000000e  rsi = 0x000000000000000e  rbp = 0x00007fff96291630  rsp = 0x00007fff962915f0
 r8 = 0x00000000000000bc   r9 = 0x00007e1e2b7e0000  r10 = 0x0000000000000008  r11 = 0x0000000000000246
r12 = 0x0000000000000006  r13 = 0x00005564d955a520  r14 = 0x0000000000000016  r15 = 0x00005564d955b200
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c) (BuildId: [redacted]) in pthread_kill

What this output means, piece by piece:

  1. Running: /testcase says the fuzzer is now running the saved input file.
  2. The next line is the self-check firing. It names the file and line (/src/curl/lib/rtsp.c:784), the function (rtsp_filter_rtp), and the condition that failed: rtp_len < rtspc->rtp_len.
  3. AddressSanitizer:DEADLYSIGNAL and the ERROR: AddressSanitizer: ABRT line come from AddressSanitizer, a tool built into the test build that watches for memory errors and reports crashes. ABRT means the program aborted itself, which is exactly what a failed assertion does.
  4. SCARINESS: 10 (signal) is a score the fuzzing tooling attaches to crashes; a signal means the process was killed by the operating system or by itself rather than exiting normally.
  5. The numbered #0 to #21 lines are the call stack: the list of function calls that led to the crash, newest at the top. Reading from the top down, pthread_kill, raise and abort are the standard C library steps that terminate a process. __assert_fail is the library routine that reports a failed assertion. rtsp_filter_rtp at lib/rtsp.c:784 is curl's parser, the place the check lives. rtsp_rtp_write_resp at line 893 is the function that calls the parser. Curl_xfer_write_resp and the transfer functions (sendrecv_dl, Curl_sendrecv, state_performing, multi_runsingle, multi_perform) are curl's normal machinery for moving data during a transfer. fuzz_handle_transfer and LLVMFuzzerTestOneInput are the fuzzer harness, and the remaining frames are the fuzzing engine and the program's entry point.
  6. DEDUP_TOKEN: pthread_kill--raise--abort is a short fingerprint the fuzzing service uses to group crashes that look the same, so duplicates can be spotted automatically.
  7. The Register values block dumps the contents of the processor's registers at the moment of the crash. It is diagnostic detail for developers and not needed to understand the bug.
  8. The final SUMMARY line repeats that the crash was an abort reported by AddressSanitizer.

The stack is short and direct: the parser is reached through the ordinary transfer path, and the abort is the assertion failure itself.

Why it happens

The interleaved RTP framing is defined by a standards document, RFC 2326, Section 10.12. An RFC is a published technical specification; this one describes RTSP. The report lays the frame format out as:

Text
  '$' <1-byte channel> <2-byte big-endian length> <length bytes of data>

Reading that line: every frame starts with a dollar-sign byte, then one byte holding the channel number, then two bytes holding the length of the data, then that many bytes of data. "Big-endian" describes the order in which the two length bytes are read: the first byte is the high part of the number and the second is the low part, the way you write a number like 12 (the 1 matters more than the 2).

curl's parser walks through this with four states, like a person following a checklist one item at a time:

  1. RTP_PARSE_SKIP, scanning for the $ that starts a frame
  2. RTP_PARSE_CHANNEL, reading the one-byte channel number
  3. RTP_PARSE_LEN, reading the two-byte payload length field
  4. RTP_PARSE_DATA, reading the RTP payload data

The bug sits in the move from RTP_PARSE_LEN to RTP_PARSE_DATA. In RTP_PARSE_LEN (line 762), once both length bytes have been collected, the buffer holds four bytes: $, channel, length high byte, length low byte. The expected total frame size is then computed as:

C
rtspc->rtp_len = RTP_PKT_LENGTH(rtp_buf) + 4;

In plain words: take the length written in the frame, add 4 for the header bytes already read, and store the result as the total size the frame should have. RTP_PKT_LENGTH extracts the 16-bit big-endian value from bytes 2 and 3:

C
#define RTP_PKT_LENGTH(p) ((((unsigned int)((unsigned char)((p)[2]))) << 8) | \
                            ((unsigned int)((unsigned char)((p)[3]))))

Line by line: #define creates a named shorthand. p is the buffer. (p)[2] is the third byte (counting from zero), the high byte of the length; it is cast to an unsigned byte and then shifted left by 8 bits, which moves it into the high half of a 16-bit number. (p)[3] is the fourth byte, the low half, cast the same way. The | combines the two halves into one number. The backslash at the end of the first line simply lets the definition continue on the next line.

When the length field is 0x0000, the arithmetic lines up badly. 0x0000 is how programmers write zero in hexadecimal, a base-16 way of writing numbers. Then:

  • RTP_PKT_LENGTH(rtp_buf) returns 0
  • rtspc->rtp_len becomes 0 + 4 = 4
  • the dynamic buffer rtspc->buf already contains exactly those 4 bytes
  • the state moves to RTP_PARSE_DATA

A dynamic buffer is a block of memory that can grow as more bytes arrive; here it holds the bytes read so far. In RTP_PARSE_DATA (line 781) the comparison is then made between two equal numbers:

  • rtp_len = curlx_dyn_len(&rtspc->buf) is 4
  • rtspc->rtp_len is 4
  • DEBUGASSERT(rtp_len < rtspc->rtp_len) becomes DEBUGASSERT(4 < 4), which fails

curlx_dyn_len asks the dynamic buffer how many bytes it currently holds. The parser has entered the read-data state when there is no data to read, and the assertion is doing exactly its job by catching that broken rule.

What it means in practice

The author's own assessment is narrow. In debug builds, an assertion is triggerable. In release builds, as far as the author can tell, there is no adverse effect beyond the state machine processing an invalid zero-length RTP frame and delivering a 4-byte header to the RTP write callback as if it were valid RTP data. A callback is a function that the library calls when something happens, so the application can react; here it would receive four header bytes and be told they are media data.

The author also notes having considered making the issue public, citing other curl issues such as https://github.com/curl/curl/issues/12701, but chose to be cautious, and offers to file the issue on GitHub if the curl maintainers confirm that is acceptable.

Fix

The report does not propose or describe a fix.

  1. Zero-length frames on other interleaved parsers. Send a frame header whose declared length is 0x0000 and check whether the parser enters its data state anyway. A positive result is an assertion, an abort, or a callback invoked with only the header bytes.
  2. Boundary lengths around the header size. Try lengths of 0, 1 and values that make the computed total equal the number of bytes already buffered, and watch for off-by-header-size comparisons of the same shape as rtp_len < rtspc->rtp_len.
  3. Split delivery of the length field. Feed the $, channel and the two length bytes across separate reads so the state machine transitions on partial buffers, and check whether the length computation and the buffer length can be made to agree exactly at the transition.
  4. Truncated frames followed by a new $. Deliver a header promising payload, then a $ before the payload arrives, and see whether the parser resynchronises or mis-frames the next packet.
  5. The same input against a release build. Replay the crashing input with assertions disabled to confirm the reported behaviour, namely that it passes and only the write callback sees the header bytes.

Glossary

  • Assertion: a check written into code that stops the program if a condition the programmer believes must always be true turns out to be false.
  • Debug build: a version of a program compiled with extra checks and diagnostic information, used during development rather than by end users.
  • Release build: the version of a program compiled for normal use, usually without the extra development checks.
  • Parser: code that reads a stream of bytes and works out its structure, deciding what each part means.
  • State machine: a way of writing a parser as a set of named states, where each incoming byte causes a move from one state to another.
  • RTSP: a protocol for controlling streaming media, such as asking a server to start or stop a stream.
  • RTP: the protocol that carries the actual media data in a stream.
  • Interleaving: sending two kinds of traffic down one connection by alternating frames of each.
  • Frame: one complete unit of data with a header and a payload.
  • Header: the fixed-size beginning of a frame that describes what follows.
  • Payload: the actual data carried inside a frame.
  • Big-endian: a byte order where the most significant part of a number comes first.
  • Hexadecimal: a base-16 way of writing numbers, where 0x0000 means zero.
  • Buffer: a block of memory holding bytes that have been read but not yet processed.
  • Dynamic buffer: a buffer that can grow as more bytes arrive.
  • Macro: a named shorthand that the compiler expands into code wherever it is used.
  • Callback: a function the library calls when something happens, so the application can react.
  • Fuzzer: a program that feeds large numbers of generated or mutated inputs into another program to find crashes.
  • Harness: the wrapper that connects a fuzzer to the code under test.
  • OSS-Fuzz: a Google-run service that continuously fuzzes open-source projects.
  • Docker: software that runs a pre-packaged environment so a build works the same on any machine.
  • Git: the version-control system that stores code history.
  • Commit: a saved snapshot of a code project.
  • AddressSanitizer: a tool built into test builds that detects memory errors and reports crashes.
  • Call stack: the list of function calls that led to the current point in a program.
  • Abort: a program deliberately terminating itself, usually because a check failed.
  • RFC: a published technical specification, such as RFC 2326 for RTSP.
  • AIXCC: the competition during which this issue was found.
  • OpenSSF: an organisation that supports open-source security.
  • OSTIF: an organisation that helps arrange security work on open-source projects.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.