RTSP CRLF injection in libcurl allows CURLOPT_RTSP_* values to inject commands into independent sessions
libcurl's RTSP options are interpolated into request lines and headers without checking for CR/LF, so a value containing a line break splits one intended RTSP operation into multiple requests. An application passing attacker-influenced data into these options could inject a TEARDOWN that terminates an unrelated party's active RTSP session.
- Disclosed after 28 hours
Summary
libcurl's RTSP code interpolates the values of CURLOPT_RTSP_STREAM_URI, CURLOPT_RTSP_TRANSPORT, and CURLOPT_RTSP_SESSION_ID directly into the RTSP request text with no check for embedded CR/LF, so a value containing \r\n splits one intended RTSP operation into multiple independent RTSP requests on the wire. I reproduced this on libcurl 8.21.0 and current HEAD (5c61e16869 / 8.22.0-DEV). Using a stateful test server modeling independent named RTSP resources (the way small/embedded RTSP servers, e.g. IP cameras and NVRs, commonly track a fixed set of channels), I demonstrated that an application performing a single, legitimate SETUP on its own resource can have a smuggled TEARDOWN command injected via CURLOPT_RTSP_STREAM_URI that terminates a completely independent, already-active session established over a separate connection by an unrelated party. The victim's later request against its own session then fails with 454 Session Not Found, even though the injecting application never referenced that session or resource. None of the three affected options are documented as raw/unsanitized protocol syntax -- unlike CURLOPT_HTTPHEADER, which explicitly warns it applies no filtering -- each is documented as a single well-formed value (a stream URI, a transport spec, a session ID). AI assistance (Claude) was used during source analysis, experiment design, and drafting this report; all technical claims and the reproduction below were independently run and verified by the researcher.
Affected Version
- curl/libcurl 8.21.0 (release tag
curl-8_21_0) - Also reproduced on current HEAD, commit
5c61e16869(8.22.0-DEV) - Build used for reproduction: local build from source, OpenSSL backend
- RTSP is compiled in by default (
CURL_DISABLE_RTSPdefaults toOFF; RTSP is not listed as experimental indocs/EXPERIMENTAL.md) curl -Voutput from the two builds used:curl 8.21.0-DEV (Linux) libcurl/8.21.0-DEV OpenSSL/3.5.5 zlib/1.3.1curl 8.22.0-DEV (Linux) libcurl/8.22.0-DEV OpenSSL/3.5.5 zlib/1.3.1
Steps to Reproduce
- Build curl from the
curl-8_21_0tag (or use HEAD) with RTSP support (default-on). - Stand up a stateful RTSP test server that tracks session state per named resource path (e.g.
/camera-A,/camera-B) globally, independent of which TCP connection issues a request -- modeling how small/embedded RTSP servers commonly implement a fixed set of channels. - Victim, connection #1: send
SETUP /camera-A RTSP/1.0thenPLAY /camera-A RTSP/1.0. Server marks/camera-Aactive and returns200 OKfor both. - Unrelated application, connection #2: using an unmodified libcurl client, call
curl_easy_setopt(CURLOPT_URL, "rtsp://HOST/camera-B")and setCURLOPT_RTSP_STREAM_URIto a value containing an embedded CR/LF sequence, then issue aSETUPrequest. The application's intent is exactly one operation, on its own resource,/camera-B. - Capture the raw bytes leaving the client on connection #2 and confirm they contain two independent, well-formed RTSP requests: the intended
SETUP /camera-B RTSP/1.0followed by an attacker-influencedTEARDOWN /camera-A RTSP/1.0. - Confirm server-side that
/camera-A's session state transitions from active to torn down as a direct result of processing connection #2's bytes -- a resource that connection, that application call, and thatcurl_easy_setoptinvocation never referenced. - Victim, connection #3 (a fresh connection resuming its own session, matching the documented use of
CURLOPT_RTSP_SESSION_ID: "Useful for resuming an in-progress session"): sendPLAY /camera-A RTSP/1.0. Confirm the response is454 Session Not Foundinstead of the200 OKit would have received before step 4-6. - Repeat with a clean, well-formed
CURLOPT_RTSP_STREAM_URI/CURLOPT_RTSP_TRANSPORTvalue (control case) and confirm exactly one request is sent and no cross-session effect occurs.
This was implemented as: a standalone libcurl C reproducer (rtsp_repro.c, parameterized by mode) driving the malicious SETUP; a stateful Python RTSP test server (rtsp_stateful_server.py) tracking per-resource session state and logging every parsed request plus the resulting state table; and a driver (rtsp_crosssession_test.py) that runs the full three-connection sequence and prints the server-side causal log end to end. All three are attached to this report as the PoC.
Vulnerable Source
lib/rtsp.c:
rtsp_setup_request():b->session_id,b->stream_uri, and the value passed tortsp_header_alloc()for theTransport:header are read directly fromCURL_EASY_STR(data, STRING_RTSP_SESSION_ID / STREAM_URI / TRANSPORT)with no validation.rtsp_header_alloc():*target = curl_maprintf("%s: %s\r\n", header_name, value)-- raw, unescaped interpolation.- Request-line construction inside
rtsp_do():
curlx_dyn_addf(&req_buffer,
"%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
"CSeq: %u\r\n",
block.request, block.stream_uri, rtsp->CSeq_sent);
...
curlx_dyn_addf(&req_buffer, "Session: %s\r\n", block.session_id);
block.stream_uri sits directly in the request line; block.session_id and the Transport value sit directly in header lines. None of the three is checked for CR/LF anywhere in this file.
The same function does explicitly guard against the application setting CSeq or Session as a custom header via CURLOPT_HTTPHEADER ("Session ID cannot be set as a custom header") -- the maintainers were alert to header confusion through that specific path, just not to CR/LF embedded inside the values of these three dedicated RTSP options. This pattern -- an app-supplied CURLOPT_* string interpolated unchecked into a line-oriented protocol command -- is the same shape as several fixes curl has shipped in the last two months for other protocols (SMTP envelope address, FTP ACCT, MIME part name/filename, gopher selector, MQTT topic, LDAP filter values), none of which touched RTSP.
We checked the documentation for all three options before reporting: CURLOPT_RTSP_STREAM_URI.md, CURLOPT_RTSP_TRANSPORT.md, and CURLOPT_RTSP_SESSION_ID.md each describe a single, well-formed data value (a URI, a transport specification, a session identifier) and give example values that are never raw multi-line protocol text. None carries any disclaimer comparable to CURLOPT_HTTPHEADER's explicit "libcurl passes on the verbatim strings you give it, without any filter or other safe guards. That includes white space and control characters." CURLOPT_RTSP_SESSION_ID.md even contains a security-motivated WARNING about a different risk (session-ID reuse across hosts on a reused handle) without ever mentioning CR/LF -- indicating this is a gap in what the maintainers considered, not a deliberately accepted and documented risk.
Impact
Confirmed impact
Using a stateful test server modeling independent named RTSP resources (not a real IP camera or NVR product -- a synthetic model of that class of server's session-tracking behavior), we demonstrated that a single CURLOPT_RTSP_STREAM_URI value, supplied by an application performing a SETUP against its own resource, can smuggle a second, fully independent, well-formed RTSP request (TEARDOWN) that terminates a different, already-active session established over an entirely separate connection by an unrelated party. The causal chain was traced end to end: the victim's session shows as active before the injection, the server's session-state log shows the transition to torn down attributed to the unrelated connection's request, and the victim's own subsequent request against the same resource independently confirms the loss (454 Session Not Found). This is unauthorized cross-session/cross-resource command injection with a demonstrated availability impact on a party the injecting application had no relationship to, reproduced identically on 8.21.0 and HEAD.
Limitations
- The test server is a minimal synthetic model built to isolate and prove the session-tracking-by-resource behavior pattern; we have not tested against, and are not claiming to have compromised, any specific real IP camera, NVR, or other RTSP server product. Real servers' session-identification strategies vary (some may key strictly on server-issued session tokens rather than resource path), which would change exploitability details without changing the underlying request-splitting primitive.
- Exploitation requires a necessary precondition: the application must pass attacker-controlled or attacker-influenced data into one of
CURLOPT_RTSP_STREAM_URI,CURLOPT_RTSP_TRANSPORT, orCURLOPT_RTSP_SESSION_IDwithout checking it for CR/LF first. This is not exploitable against curl by default or without that specific application behavior. - We did not attempt to demonstrate RTP/media-stream redirection via an injected
SETUPwith altered Transport parameters. That remains a plausible further consequence we have not built or verified, and we are not claiming it. - Not demonstrated: confidentiality impact, authentication bypass, or code execution.
- We have not identified a specific named open-source application using this exact option-forwarding pattern.
Weakness
Improper Neutralization of CRLF Sequences ('CRLF Injection') -- CWE-93. This is the correct protocol-agnostic classification for the mechanism (curl's own recent fixes for the same shape of bug in SMTP/FTP/MIME/gopher/MQTT/LDAP fall under the same weakness). The demonstrated consequence here is unauthorized command injection affecting an independent session/resource; if the program's taxonomy has a more specific category it considers a better fit for that consequence, we'd defer to their judgment, but CWE-93 is our primary recommendation as it accurately names the root cause.
Severity
Medium, offered as our assessment -- we recognize curl's security team makes the final determination and the illustrative CVSS vector below is not a substitute for that.
Justification: this is a demonstrated, reproducible instance of one application's single, legitimate operation on its own resource causing unauthorized termination of an independent, unrelated party's active session on a different resource -- a genuine violation of the isolation that's supposed to exist between independent RTSP sessions, not merely malformed output. We are not rating it higher than Medium because of the necessary precondition identified above (the application must first forward attacker-controlled or attacker-influenced data into one of these three options; this is not triggerable against arbitrary curl usage or by default), because the demonstration is against a synthetic test server modeling this class of server's session-tracking behavior rather than a verified real product, and because no confidentiality impact or authentication bypass has been shown.
Illustrative CVSS 3.1 vector for the demonstrated scenario: AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:L. We offer this only as a concrete reference point for how we reasoned about the demonstrated test, not as a claim of the final score.
Remediation
Add the same CR/LF rejection already used for SMTP/FTP/MIME/gopher/MQTT/LDAP at the three read points in rtsp_setup_request():
b->session_id = CURL_EASY_STR(data, STRING_RTSP_SESSION_ID);
if(b->session_id && strpbrk(b->session_id, "\r\n")) {
failf(data, "Refusing to send a Session ID with a CR or LF");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
...mirrored for STRING_RTSP_STREAM_URI and the value passed into rtsp_header_alloc() for STRING_RTSP_TRANSPORT. Given how many call sites across the codebase now carry this same hand-written check, a shared helper (e.g. Curl_str_has_crlf()) used by all of them, including this one, would reduce the risk of the next protocol handler missing it.
Regression Test
Add a libcurl test case: set CURLOPT_RTSP_STREAM_URI (and separately CURLOPT_RTSP_TRANSPORT, CURLOPT_RTSP_SESSION_ID) to a value containing "\r\nX-Injected: yes", issue a SETUP/PLAY, and assert curl_easy_perform() returns CURLE_BAD_FUNCTION_ARGUMENT before anything reaches the wire -- mirroring the structure of the existing SMTP CR/LF regression test (test 2110).
AI Disclosure
AI assistance (Claude) was used during source analysis, experiment design, and preparation of this report. All technical claims, the reproduction steps, and the source citations above were independently run and verified by the researcher before submission; nothing in this report is asserted on the basis of AI output alone.
Impact
Confirmed impact
Using a stateful test server modeling independent named RTSP resources (not a real IP camera or NVR product -- a synthetic model of that class of server's session-tracking behavior), we demonstrated that a single CURLOPT_RTSP_STREAM_URI value, supplied by an application performing a SETUP against its own resource, can smuggle a second, fully independent, well-formed RTSP request (TEARDOWN) that terminates a different, already-active session established over an entirely separate connection by an unrelated party. The causal chain was traced end to end: the victim's session shows as active before the injection, the server's session-state log shows the transition to torn down attributed to the unrelated connection's request, and the victim's own subsequent request against the same resource independently confirms the loss (454 Session Not Found). This is unauthorized cross-session/cross-resource command injection with a demonstrated availability impact on a party the injecting application had no relationship to, reproduced identically on 8.21.0 and HEAD.
Limitations
- The test server is a minimal synthetic model built to isolate and prove the session-tracking-by-resource behavior pattern; we have not tested against, and are not claiming to have compromised, any specific real IP camera, NVR, or other RTSP server product.
- Exploitation requires a necessary precondition: the application must pass attacker-controlled or attacker-influenced data into one of CURLOPT_RTSP_STREAM_URI, CURLOPT_RTSP_TRANSPORT, or CURLOPT_RTSP_SESSION_ID without checking it for CR/LF first. This is not exploitable against curl by default or without that specific application behavior.
- We did not attempt to demonstrate RTP/media-stream redirection via an injected SETUP with altered Transport parameters, and are not claiming it.
- Not demonstrated: confidentiality impact, authentication bypass, or code execution.
Context
libcurl's RTSP support lets an application drive a streaming session through a small set of dedicated options: CURLOPT_RTSP_STREAM_URI (the resource the request targets), CURLOPT_RTSP_TRANSPORT (the transport specification sent in the Transport: header) and CURLOPT_RTSP_SESSION_ID (the session identifier, documented as useful for resuming an in-progress session). Each of these is documented as a single, well-formed value: a URI, a transport spec, a session ID.
RTSP is a line-oriented text protocol, much like HTTP. A request looks like METHOD <uri> RTSP/1.0, followed by headers and a blank line. That means any value that ends up inside the request line or a header line must not contain CR or LF, or the value will split the request into more than one request on the wire.
The report shows that libcurl interpolates all three of these option values into the outgoing request text without checking for embedded CR/LF. An application that performs one legitimate SETUP on its own resource can therefore have a second, fully formed RTSP request smuggled onto the connection.
Setup
The researcher reproduced the issue on two builds:
- curl/libcurl 8.21.0, release tag
curl-8_21_0 - current HEAD at the time, commit
5c61e16869(8.22.0-DEV)
Both were local builds from source with the OpenSSL backend. The curl -V output of the two builds was:
curl 8.21.0-DEV (Linux) libcurl/8.21.0-DEV OpenSSL/3.5.5 zlib/1.3.1
curl 8.22.0-DEV (Linux) libcurl/8.22.0-DEV OpenSSL/3.5.5 zlib/1.3.1
RTSP is compiled in by default: CURL_DISABLE_RTSP defaults to OFF, and RTSP is not listed as experimental in docs/EXPERIMENTAL.md.
The test harness consisted of three pieces, all attached to the report as the PoC:
rtsp_repro.c, a standalone libcurl C reproducer parameterised by mode, which drives the maliciousSETUP.rtsp_stateful_server.py, a stateful Python RTSP test server that tracks session state per named resource path (for example/camera-Aand/camera-B) globally, independent of which TCP connection issues a request. It logs every parsed request plus the resulting state table.rtsp_crosssession_test.py, a driver that runs the full three-connection sequence and prints the server-side causal log end to end.
The server models how small and embedded RTSP servers, such as IP cameras and NVRs, commonly track a fixed set of channels. It is a synthetic model, not a real product.
The precondition for exploitation is on the application side: it must pass attacker-controlled or attacker-influenced data into one of the three options without checking it for CR/LF first. Nothing is exploitable against curl by default or without that specific application behaviour.
Finding it
Source analysis of lib/rtsp.c identified three read points in rtsp_setup_request() where values are taken straight from the easy handle with no validation:
b->session_idfromCURL_EASY_STR(data, STRING_RTSP_SESSION_ID)b->stream_urifromCURL_EASY_STR(data, STRING_RTSP_STREAM_URI)- the value passed to
rtsp_header_alloc()for theTransport:header, fromCURL_EASY_STR(data, STRING_RTSP_TRANSPORT)
rtsp_header_alloc() formats the header with raw, unescaped interpolation:
*target = curl_maprintf("%s: %s\r\n", header_name, value);
The request line and the Session: header are built inside rtsp_do():
curlx_dyn_addf(&req_buffer,
"%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
"CSeq: %u\r\n",
block.request, block.stream_uri, rtsp->CSeq_sent);
...
curlx_dyn_addf(&req_buffer, "Session: %s\r\n", block.session_id);
block.stream_uri sits directly in the request line, and block.session_id and the Transport value sit directly in header lines. None of the three is checked for CR/LF anywhere in the file.
What made this look like an oversight rather than an accepted risk is the surrounding context. The same function explicitly guards against the application setting CSeq or Session as a custom header through CURLOPT_HTTPHEADER, with the message "Session ID cannot be set as a custom header". The maintainers were alert to header confusion through that path, but not to CR/LF embedded inside the values of the three dedicated RTSP options.
The documentation was checked for all three options before reporting. CURLOPT_RTSP_STREAM_URI.md, CURLOPT_RTSP_TRANSPORT.md and CURLOPT_RTSP_SESSION_ID.md each describe a single, well-formed data value and give example values that are never raw multi-line protocol text. None carries a disclaimer comparable to CURLOPT_HTTPHEADER's explicit warning that libcurl passes on the verbatim strings given to it, "without any filter or other safe guards. That includes white space and control characters." CURLOPT_RTSP_SESSION_ID.md even contains a security-motivated WARNING about a different risk, session-ID reuse across hosts on a reused handle, without ever mentioning CR/LF. That points to a gap in what was considered, not a deliberately accepted and documented risk.
The same shape of bug, an application-supplied CURLOPT_* string interpolated unchecked into a line-oriented protocol command, had been fixed by curl in several other protocols in the preceding two months: SMTP envelope address, FTP ACCT, MIME part name and filename, gopher selector, MQTT topic, and LDAP filter values. None of those fixes touched RTSP.
Exploitation
Step 1: build and stand up the test server
Build curl from the curl-8_21_0 tag (or use HEAD) with RTSP support, which is on by default. Then run the stateful RTSP test server that tracks session state per named resource path, globally, independent of the TCP connection that issues a request.
Step 2: the victim establishes a session
On connection #1, the victim sends SETUP /camera-A RTSP/1.0 followed by PLAY /camera-A RTSP/1.0. The server marks /camera-A active and returns 200 OK for both requests.
Step 3: the unrelated application sends its SETUP
On connection #2, an unrelated application using an unmodified libcurl client calls:
curl_easy_setopt(CURLOPT_URL, "rtsp://HOST/camera-B")
and sets CURLOPT_RTSP_STREAM_URI to a value containing an embedded CR/LF sequence, then issues a SETUP request. The application's intent is exactly one operation, on its own resource, /camera-B.
Step 4: inspect the bytes on the wire
Capture the raw bytes leaving the client on connection #2. They contain two independent, well-formed RTSP requests: the intended SETUP /camera-B RTSP/1.0, followed by an attacker-influenced TEARDOWN /camera-A RTSP/1.0.
Step 5: confirm the server-side state change
On the server side, /camera-A's session state transitions from active to torn down as a direct result of processing connection #2's bytes. That resource was never referenced by that connection, by that application call, or by that curl_easy_setopt invocation.
Step 6: the victim notices the loss
On connection #3, a fresh connection resuming its own session, matching the documented use of CURLOPT_RTSP_SESSION_ID ("Useful for resuming an in-progress session"), the victim sends PLAY /camera-A RTSP/1.0. The response is 454 Session Not Found instead of the 200 OK it would have received before steps 3 to 5.
Step 7: control case
Repeat with a clean, well-formed CURLOPT_RTSP_STREAM_URI and CURLOPT_RTSP_TRANSPORT value. Exactly one request is sent and no cross-session effect occurs.
The causal chain was traced end to end: the victim's session shows as active before the injection, the server's session-state log shows the transition to torn down attributed to the unrelated connection's request, and the victim's own subsequent request against the same resource independently confirms the loss with 454 Session Not Found. The result was identical on 8.21.0 and HEAD.
Root cause
This is CWE-93, Improper Neutralization of CRLF Sequences, the protocol-agnostic classification for the mechanism. The root cause is that rtsp_setup_request() reads three application-supplied strings and interpolates them into a line-oriented protocol message without rejecting CR or LF. Because the request line and headers are terminated by \r\n, an embedded \r\n in any of the three values ends the current line and starts a new one, so the remainder of the value is parsed by the server as a separate request.
Existing defences did not cover this path. The function does block CSeq and Session being supplied through CURLOPT_HTTPHEADER, but that check is about header confusion through the custom-header option, not about control characters inside the dedicated RTSP options. The documentation for the three options describes them as single well-formed values and carries no warning about verbatim, unfiltered pass-through, unlike CURLOPT_HTTPHEADER. The same class of bug had already been fixed in SMTP, FTP, MIME, gopher, MQTT and LDAP, but the RTSP handler was not included in those fixes.
Impact
Confirmed: a single CURLOPT_RTSP_STREAM_URI value, supplied by an application performing a SETUP against its own resource, can smuggle a second, fully independent, well-formed RTSP request (TEARDOWN) that terminates a different, already-active session established over an entirely separate connection by an unrelated party. This is unauthorised cross-session and cross-resource command injection, with a demonstrated availability impact on a party the injecting application had no relationship to.
The report is explicit about the limits of the demonstration:
- The test server is a minimal synthetic model built to isolate and prove the session-tracking-by-resource behaviour pattern. No specific real IP camera, NVR or other RTSP server product was tested or compromised. Real servers' session-identification strategies vary; some may key strictly on server-issued session tokens rather than resource path, which would change exploitability details without changing the underlying request-splitting primitive.
- Exploitation requires the application to pass attacker-controlled or attacker-influenced data into one of
CURLOPT_RTSP_STREAM_URI,CURLOPT_RTSP_TRANSPORTorCURLOPT_RTSP_SESSION_IDwithout checking it for CR/LF first. It is not exploitable against curl by default or without that specific application behaviour. - RTP/media-stream redirection via an injected
SETUPwith altered Transport parameters was not attempted. It remains a plausible further consequence that was not built or verified, and is not claimed. - Confidentiality impact, authentication bypass and code execution were not demonstrated.
- No specific named open-source application using this exact option-forwarding pattern was identified.
The researcher offered Medium severity as their own assessment, noting that curl's security team makes the final determination. The reasoning: it is a demonstrated, reproducible case of one application's single legitimate operation on its own resource causing unauthorised termination of an independent party's active session on a different resource, a genuine violation of the isolation expected between independent RTSP sessions. It was not rated higher because of the necessary application-side precondition, because the demonstration used a synthetic server rather than a verified real product, and because no confidentiality impact or authentication bypass was shown. The illustrative CVSS 3.1 vector for the demonstrated scenario was:
AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:L
This was offered only as a concrete reference point for how the test was reasoned about, not as a claim of the final score.
Fix
The recommendation is to add the same CR/LF rejection already used for SMTP, FTP, MIME, gopher, MQTT and LDAP at the three read points in rtsp_setup_request(). For the session ID:
b->session_id = CURL_EASY_STR(data, STRING_RTSP_SESSION_ID);
if(b->session_id && strpbrk(b->session_id, "\r\n")) {
failf(data, "Refusing to send a Session ID with a CR or LF");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
The same check should be mirrored for STRING_RTSP_STREAM_URI and for the value passed into rtsp_header_alloc() for STRING_RTSP_TRANSPORT. Since many call sites across the codebase now carry this same hand-written check, the report suggests a shared helper, for example Curl_str_has_crlf(), used by all of them, including this one, to reduce the risk of the next protocol handler missing it.
For a regression test, the report proposes a libcurl test case that sets CURLOPT_RTSP_STREAM_URI (and separately CURLOPT_RTSP_TRANSPORT and CURLOPT_RTSP_SESSION_ID) to a value containing "\r\nX-Injected: yes", issues a SETUP or PLAY, and asserts that curl_easy_perform() returns CURLE_BAD_FUNCTION_ARGUMENT before anything reaches the wire. This mirrors the structure of the existing SMTP CR/LF regression test, test 2110.
Variants to test
- The other two RTSP options. The report names
CURLOPT_RTSP_TRANSPORTandCURLOPT_RTSP_SESSION_IDas affected alongside the stream URI, but the demonstrated cross-session scenario used the stream URI. Try a CR/LF-bearing Transport value and a CR/LF-bearing session ID against a stateful server. A positive result is a second well-formed request appearing in the captured bytes, or a state change on a resource the call never referenced. - Other line-oriented protocol handlers in the same library. The report lists SMTP envelope address, FTP ACCT, MIME part name and filename, gopher selector, MQTT topic and LDAP filter values as already fixed for this shape. Look for handlers that take an application-supplied
CURLOPT_*string and place it in a request line or header without a CR/LF check. A positive result is a value containing\r\nproducing two parsed commands on the wire. - Servers that key sessions on resource path. The exploitability depends on how the server identifies sessions. Against a server that tracks state per named resource globally, an injected
TEARDOWNfor another resource should end that resource's session, observable as a later454 Session Not Foundfrom the legitimate client. Against a server that keys strictly on server-issued session tokens, expect the injected request to fail or be ignored. - Injected
SETUPwith altered Transport parameters. The report flags media-stream redirection through an injectedSETUPas plausible but unverified. A positive result would be the server accepting the injectedSETUPand the media stream being directed to parameters the application never chose. Treat any such result as new ground, not as something this report established. - Applications that forward user input into these options. The precondition is application-side. Look for software that builds an RTSP URL or session identifier from user-supplied input and passes it to one of the three options. A positive result is a user-controlled string containing
\r\nreaching the wire as a separate RTSP request.
What happened, in plain words
A library called libcurl is used by many programs to talk to servers over the internet. One of the things it can do is speak RTSP, a language used for controlling video streams, for example from security cameras. A researcher found that three of the settings libcurl offers for RTSP accept text from the program using the library and paste it into the outgoing message without checking it for a special pair of invisible characters: a carriage return and a line feed. Those two characters mean "end of line" in this kind of message. If they appear inside a value, the server sees the end of one command and the start of another.
The researcher showed that a program making one ordinary request about its own camera stream could, through such a value, sneak a second command onto the connection. That second command shut down a completely different stream belonging to someone else, on a different connection. The victim's next request then failed with an error saying the session no longer existed.
This is a beginner's walkthrough of that report. Every technical term is explained where it first appears, and there is a glossary at the end.
Context
What libcurl and RTSP are
libcurl is a piece of software, a library, that other programs link into themselves so they do not have to write all the network code from scratch. It knows how to speak many internet languages: HTTP (the language of web pages), FTP (file transfer), SMTP (sending mail) and others. The command-line tool curl is built on the same library.
RTSP stands for Real Time Streaming Protocol. It is a language for controlling a live media stream: start it, pause it, stop it. Think of it as the remote control for a video feed, while a second language (RTP) carries the actual pictures and sound. IP cameras and NVRs (network video recorders, boxes that record several cameras at once) commonly speak RTSP.
The three settings involved
A program using libcurl configures it through options, named constants that start with CURLOPT_. Three RTSP options matter here:
CURLOPT_RTSP_STREAM_URI: which resource the request is about, for example a particular camera channel.CURLOPT_RTSP_TRANSPORT: how the media should be carried, sent in a header calledTransport:.CURLOPT_RTSP_SESSION_ID: the identifier of an existing session, documented as useful for resuming a session that is already in progress.
A session here means a conversation the server remembers: the client said hello, the server gave it a label, and later requests refer back to that label. It is like a coat-check ticket: the server holds your stream and hands you a number so you can claim it again later.
The documentation for each of these three options describes a single, well-formed value: a URI (an address), a transport specification, a session ID. None of them is described as raw protocol text.
Why line endings matter
RTSP is a line-oriented text protocol, much like HTTP. A request looks like METHOD <uri> RTSP/1.0, then a series of header lines, then a blank line. Each line ends with two characters: CR (carriage return, written \r) and LF (line feed, written \n). Together they are called CRLF.
The server reads the message line by line. So if a value that is supposed to sit inside one line secretly contains a CRLF, the server treats everything after it as a new line. If that new line looks like a complete command, the server will happily carry it out. This splitting of one message into several is called request smuggling or injection.
The report shows that libcurl pastes all three option values into the outgoing request text without checking for embedded CR/LF. A program making one legitimate SETUP (the RTSP command that starts a stream) on its own resource can therefore have a second, fully formed RTSP request smuggled onto the connection.
Setup
The versions tested
The researcher reproduced the issue on two builds of the software:
- curl/libcurl 8.21.0, release tag
curl-8_21_0 - the then-current development code, commit
5c61e16869(8.22.0-DEV)
A commit is a saved snapshot in a version-control system; a tag is a human-friendly name for one such snapshot, here a released version. 8.22.0-DEV means work in progress towards the next release.
Both were built locally from source code, with the OpenSSL backend. "Built from source" means compiling the program yourself rather than installing a ready-made package. A backend is the plug-in library that does a supporting job; OpenSSL handles encryption.
The curl -V command prints the version and the features compiled in. Its output for the two builds was:
curl 8.21.0-DEV (Linux) libcurl/8.21.0-DEV OpenSSL/3.5.5 zlib/1.3.1
curl 8.22.0-DEV (Linux) libcurl/8.22.0-DEV OpenSSL/3.5.5 zlib/1.3.1
Line by line: each line names the curl version, says it runs on Linux, gives the libcurl version, then lists the supporting libraries: OpenSSL 3.5.5 for encryption and zlib 1.3.1 for compression. The point of showing this is to pin down exactly which code was tested, so anyone can repeat it.
RTSP support is switched on by default when curl is compiled: the build switch CURL_DISABLE_RTSP defaults to OFF, and RTSP is not listed as experimental in docs/EXPERIMENTAL.md. In plain words, you do not need special flags to get this feature; it is there in a normal build.
The test harness
A test harness is the set of tools built to demonstrate and observe a bug. Three pieces were attached to the report as the PoC (proof of concept, meaning a working demonstration):
rtsp_repro.c, a standalone C program using libcurl, parameterised by mode, which sends the maliciousSETUP. "Parameterised by mode" means you can run it in different configurations, for example the attack case and the harmless control case.rtsp_stateful_server.py, a stateful Python RTSP test server. "Stateful" means it remembers things between requests: it tracks session state per named resource path, for example/camera-Aand/camera-B, globally, no matter which TCP connection sends a request. It logs every request it parses plus the resulting table of states.rtsp_crosssession_test.py, a driver that runs the whole three-connection sequence and prints the server-side log showing cause and effect from start to finish.
A TCP connection is the underlying network channel between two programs; think of it as a phone call that stays open. A resource path is the part of an address naming a particular thing, like /camera-A.
The server models how small and embedded RTSP servers, such as IP cameras and NVRs, commonly track a fixed set of channels. It is a synthetic model, not a real product: it was written to imitate a behaviour pattern, not copied from any camera.
The precondition
The precondition for exploitation is on the application side: the program using libcurl must pass attacker-controlled or attacker-influenced data into one of the three options without checking it for CR/LF first. Nothing is exploitable against curl by default or without that specific application behaviour. In everyday terms: the library is the faulty lock, but a burglar also needs a door where someone has taped over the keyhole.
Finding it
Reading the source
Source analysis of lib/rtsp.c, the file in curl's source code that handles RTSP, identified three read points in a function called rtsp_setup_request() where values are taken straight from the easy handle with no validation:
b->session_idfromCURL_EASY_STR(data, STRING_RTSP_SESSION_ID)b->stream_urifromCURL_EASY_STR(data, STRING_RTSP_STREAM_URI)- the value passed to
rtsp_header_alloc()for theTransport:header, fromCURL_EASY_STR(data, STRING_RTSP_TRANSPORT)
An easy handle is libcurl's internal object holding one transfer's settings; the program fills it in through the CURLOPT_ options. CURL_EASY_STR is the internal call that reads a text option back out of that object. "No validation" means nobody looked at the text to see whether it contained anything dangerous.
The formatting code
rtsp_header_alloc() formats a header with raw, unescaped interpolation:
*target = curl_maprintf("%s: %s\r\n", header_name, value);
Line by line: curl_maprintf builds a piece of text, like a fill-in-the-blanks sentence. %s means "put a string here". So the result is the header name, a colon and a space, the value, and then \r\n, the CRLF that ends the line. The value is dropped in exactly as supplied, with no escaping. Escaping means converting dangerous characters into a harmless written form; here nothing is converted.
The request line and the Session: header are built inside a function called rtsp_do():
curlx_dyn_addf(&req_buffer,
"%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
"CSeq: %u\r\n",
block.request, block.stream_uri, rtsp->CSeq_sent);
...
curlx_dyn_addf(&req_buffer, "Session: %s\r\n", block.session_id);
Line by line: curlx_dyn_addf appends text to a growing buffer, req_buffer, which will become the outgoing message. The first call writes the request line: the method (block.request, for example SETUP), a space, the stream URI (block.stream_uri), a space, RTSP/1.0, then CRLF. Next it writes a header line CSeq: followed by a sequence number (rtsp->CSeq_sent), then CRLF. The ... stands for code left out of the quotation. The second call writes Session: followed by the session ID, then CRLF.
The important part: block.stream_uri sits directly in the request line, and block.session_id and the Transport value sit directly in header lines. None of the three is checked for CR/LF anywhere in the file. If any of them contains a CRLF, the line ends early and whatever follows becomes a new line in the message.
Why it looked like an oversight
What made this look like an oversight rather than an accepted risk is the surrounding context. The same function explicitly guards against the application setting CSeq or Session as a custom header through CURLOPT_HTTPHEADER, with the message "Session ID cannot be set as a custom header". CURLOPT_HTTPHEADER is the option for adding your own raw header lines, and it is documented as passing text through verbatim. So the maintainers were alert to header confusion through that path, but not to CR/LF embedded inside the values of the three dedicated RTSP options.
What the documentation says
The documentation was checked for all three options before reporting. CURLOPT_RTSP_STREAM_URI.md, CURLOPT_RTSP_TRANSPORT.md and CURLOPT_RTSP_SESSION_ID.md each describe a single, well-formed data value and give example values that are never raw multi-line protocol text. None carries a disclaimer comparable to CURLOPT_HTTPHEADER's explicit warning that libcurl passes on the verbatim strings given to it, "without any filter or other safe guards. That includes white space and control characters."
CURLOPT_RTSP_SESSION_ID.md even contains a security-motivated WARNING about a different risk, session-ID reuse across hosts on a reused handle, without ever mentioning CR/LF. That points to a gap in what was considered, not a deliberately accepted and documented risk.
The same bug elsewhere
The same shape of bug, an application-supplied CURLOPT_* string interpolated unchecked into a line-oriented protocol command, had been fixed by curl in several other protocols in the preceding two months: SMTP envelope address, FTP ACCT, MIME part name and filename, gopher selector, MQTT topic, and LDAP filter values. None of those fixes touched RTSP. In other words, the team had been repairing the same kind of hole in room after room of the same house, and this room was missed.
Exploitation
Step 1: build and stand up the test server
Build curl from the curl-8_21_0 tag (or use the development code) with RTSP support, which is on by default. Then run the stateful RTSP test server that tracks session state per named resource path, globally, independent of the TCP connection that issues a request.
Why: you need a server that behaves like the class of device being modelled, so that a command aimed at one camera channel visibly affects that channel no matter who sends it.
Step 2: the victim establishes a session
On connection #1, the victim sends SETUP /camera-A RTSP/1.0 followed by PLAY /camera-A RTSP/1.0. The server marks /camera-A active and returns 200 OK for both requests.
Why: this creates the thing that will later be destroyed. SETUP prepares the stream, PLAY starts it, and 200 OK is the standard "success" reply. The victim is now watching camera A.
Step 3: the unrelated application sends its SETUP
On connection #2, an unrelated application using an unmodified libcurl client calls:
curl_easy_setopt(CURLOPT_URL, "rtsp://HOST/camera-B")
Line by line: curl_easy_setopt sets one option on the easy handle. CURLOPT_URL is the address to connect to; here it is an RTSP address for camera B. HOST is a placeholder for the server's name, left generic in the report.
It then sets CURLOPT_RTSP_STREAM_URI to a value containing an embedded CR/LF sequence, and issues a SETUP request. The application's intent is exactly one operation, on its own resource, /camera-B.
Why: this is the attack. The program believes it is asking about camera B only. The hidden CRLF inside the stream URI value will end that request line early and start a new one.
Step 4: inspect the bytes on the wire
Capture the raw bytes leaving the client on connection #2. They contain two independent, well-formed RTSP requests: the intended SETUP /camera-B RTSP/1.0, followed by an attacker-influenced TEARDOWN /camera-A RTSP/1.0.
Why: looking at the actual bytes, rather than at what the program thinks it sent, is the proof. TEARDOWN is the RTSP command that ends a session. The server sees two perfectly valid commands, not one command with a strange value in it.
Step 5: confirm the server-side state change
On the server side, /camera-A's session state transitions from active to torn down as a direct result of processing connection #2's bytes. That resource was never referenced by that connection, by that application call, or by that curl_easy_setopt invocation.
Why: this shows the effect is real and caused by the smuggled command, not by anything the victim did. The server's own log is the witness.
Step 6: the victim notices the loss
On connection #3, a fresh connection resuming its own session, matching the documented use of CURLOPT_RTSP_SESSION_ID ("Useful for resuming an in-progress session"), the victim sends PLAY /camera-A RTSP/1.0. The response is 454 Session Not Found instead of the 200 OK it would have received before steps 3 to 5.
Why: this is the harm made visible from the victim's side. 454 Session Not Found is the server saying "I have no such session", because the smuggled TEARDOWN already removed it.
Step 7: control case
Repeat with a clean, well-formed CURLOPT_RTSP_STREAM_URI and CURLOPT_RTSP_TRANSPORT value. Exactly one request is sent and no cross-session effect occurs.
Why: a control case is the same experiment without the ingredient under test. If the harmless value produces no second request and no damage, the CRLF is shown to be the cause, not some other quirk of the setup.
The causal chain was traced end to end: the victim's session shows as active before the injection, the server's session-state log shows the transition to torn down attributed to the unrelated connection's request, and the victim's own subsequent request against the same resource independently confirms the loss with 454 Session Not Found. The result was identical on 8.21.0 and the development code.
Root cause
This is CWE-93, Improper Neutralization of CRLF Sequences, the protocol-agnostic classification for the mechanism. CWE is a public catalogue of weakness types; "protocol-agnostic" means the label describes the mechanism itself, whatever language the server speaks.
The root cause is that rtsp_setup_request() reads three application-supplied strings and interpolates them into a line-oriented protocol message without rejecting CR or LF. Because the request line and headers are terminated by \r\n, an embedded \r\n in any of the three values ends the current line and starts a new one, so the remainder of the value is parsed by the server as a separate request.
Existing defences did not cover this path. The function does block CSeq and Session being supplied through CURLOPT_HTTPHEADER, but that check is about header confusion through the custom-header option, not about control characters inside the dedicated RTSP options. The documentation for the three options describes them as single well-formed values and carries no warning about verbatim, unfiltered pass-through, unlike CURLOPT_HTTPHEADER. The same class of bug had already been fixed in SMTP, FTP, MIME, gopher, MQTT and LDAP, but the RTSP handler was not included in those fixes.
Impact
Confirmed: a single CURLOPT_RTSP_STREAM_URI value, supplied by an application performing a SETUP against its own resource, can smuggle a second, fully independent, well-formed RTSP request (TEARDOWN) that terminates a different, already-active session established over an entirely separate connection by an unrelated party. This is unauthorised cross-session and cross-resource command injection, with a demonstrated availability impact on a party the injecting application had no relationship to. Availability means whether the service works at all; here the victim's stream stops working.
The report is explicit about the limits of the demonstration:
- The test server is a minimal synthetic model built to isolate and prove the session-tracking-by-resource behaviour pattern. No specific real IP camera, NVR or other RTSP server product was tested or compromised. Real servers' session-identification strategies vary; some may key strictly on server-issued session tokens rather than resource path, which would change exploitability details without changing the underlying request-splitting primitive.
- Exploitation requires the application to pass attacker-controlled or attacker-influenced data into one of
CURLOPT_RTSP_STREAM_URI,CURLOPT_RTSP_TRANSPORTorCURLOPT_RTSP_SESSION_IDwithout checking it for CR/LF first. It is not exploitable against curl by default or without that specific application behaviour. - RTP/media-stream redirection via an injected
SETUPwith altered Transport parameters was not attempted. It remains a plausible further consequence that was not built or verified, and is not claimed. - Confidentiality impact, authentication bypass and code execution were not demonstrated. Confidentiality means keeping data secret; authentication bypass means getting in without valid credentials; code execution means making the machine run an attacker's program.
- No specific named open-source application using this exact option-forwarding pattern was identified.
The researcher offered Medium severity as their own assessment, noting that curl's security team makes the final determination. Severity is a rough scale of how bad a bug is. The reasoning: it is a demonstrated, reproducible case of one application's single legitimate operation on its own resource causing unauthorised termination of an independent party's active session on a different resource, a genuine violation of the isolation expected between independent RTSP sessions. It was not rated higher because of the necessary application-side precondition, because the demonstration used a synthetic server rather than a verified real product, and because no confidentiality impact or authentication bypass was shown.
The illustrative CVSS 3.1 vector for the demonstrated scenario was:
AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:L
CVSS is a standard scoring system for vulnerabilities. A vector is the compact string of letters that records the answers to its questions. Read piece by piece: AV:N means the attack can come over the network; AC:L means the conditions are easy to meet; PR:N means the attacker needs no privileges; UI:N means no user has to be tricked into clicking; S:C means the impact can spill over from one security context to another; C:N means no confidentiality impact; I:H means a high integrity impact, meaning data or state can be changed; A:L means a low availability impact. This was offered only as a concrete reference point for how the test was reasoned about, not as a claim of the final score.
Fix
The recommendation is to add the same CR/LF rejection already used for SMTP, FTP, MIME, gopher, MQTT and LDAP at the three read points in rtsp_setup_request(). For the session ID:
b->session_id = CURL_EASY_STR(data, STRING_RTSP_SESSION_ID);
if(b->session_id && strpbrk(b->session_id, "\r\n")) {
failf(data, "Refusing to send a Session ID with a CR or LF");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
Line by line: the first line reads the session ID option out of the handle, as before. The if line asks two questions: is there a session ID at all, and does it contain a carriage return or line feed? strpbrk searches a string for any of the characters listed; here the list is \r\n. If both are true, failf records an error message, "Refusing to send a Session ID with a CR or LF", and the function returns CURLE_BAD_FUNCTION_ARGUMENT, an error code meaning the program passed a bad argument. In plain words: check the value, and if it hides a line break, refuse to send anything.
The same check should be mirrored for STRING_RTSP_STREAM_URI and for the value passed into rtsp_header_alloc() for STRING_RTSP_TRANSPORT. Since many call sites across the codebase now carry this same hand-written check, the report suggests a shared helper, for example Curl_str_has_crlf(), used by all of them, including this one, to reduce the risk of the next protocol handler missing it. A helper is a small reusable function; the point is to write the check once so nobody forgets it next time.
For a regression test, a test that makes sure a fixed bug stays fixed, the report proposes a libcurl test case that sets CURLOPT_RTSP_STREAM_URI (and separately CURLOPT_RTSP_TRANSPORT and CURLOPT_RTSP_SESSION_ID) to a value containing "\r\nX-Injected: yes", issues a SETUP or PLAY, and asserts that curl_easy_perform() returns CURLE_BAD_FUNCTION_ARGUMENT before anything reaches the wire. curl_easy_perform() is the call that actually carries out the transfer. This mirrors the structure of the existing SMTP CR/LF regression test, test 2110.
Variants to test
- The other two RTSP options. The report names
CURLOPT_RTSP_TRANSPORTandCURLOPT_RTSP_SESSION_IDas affected alongside the stream URI, but the demonstrated cross-session scenario used the stream URI. Try a CR/LF-bearing Transport value and a CR/LF-bearing session ID against a stateful server. A positive result is a second well-formed request appearing in the captured bytes, or a state change on a resource the call never referenced. - Other line-oriented protocol handlers in the same library. The report lists SMTP envelope address, FTP ACCT, MIME part name and filename, gopher selector, MQTT topic and LDAP filter values as already fixed for this shape. Look for handlers that take an application-supplied
CURLOPT_*string and place it in a request line or header without a CR/LF check. A positive result is a value containing\r\nproducing two parsed commands on the wire. - Servers that key sessions on resource path. The exploitability depends on how the server identifies sessions. Against a server that tracks state per named resource globally, an injected
TEARDOWNfor another resource should end that resource's session, observable as a later454 Session Not Foundfrom the legitimate client. Against a server that keys strictly on server-issued session tokens, expect the injected request to fail or be ignored. - Injected
SETUPwith altered Transport parameters. The report flags media-stream redirection through an injectedSETUPas plausible but unverified. A positive result would be the server accepting the injectedSETUPand the media stream being directed to parameters the application never chose. Treat any such result as new ground, not as something this report established. - Applications that forward user input into these options. The precondition is application-side. Look for software that builds an RTSP URL or session identifier from user-supplied input and passes it to one of the three options. A positive result is a user-controlled string containing
\r\nreaching the wire as a separate RTSP request.
Glossary
- Availability: whether a service keeps working; an availability impact means something stops working for someone.
- Backend: a supporting library that does part of the work, such as encryption.
- Build from source: compiling a program yourself from its code rather than installing a ready-made package.
- Carriage return (CR,
\r) and line feed (LF,\n): the two invisible characters that together mark the end of a line in many internet protocols. - Commit: a saved snapshot of code in a version-control system.
- Confidentiality: keeping data secret from people who should not see it.
- Control case: the same experiment run without the ingredient under test, to show that ingredient is the cause.
- CRLF injection: putting a line break inside a value so that one message is split into several commands.
- curl / libcurl: a command-line tool and the library underneath it that speak many internet protocols.
- CVSS: a standard scoring system for vulnerabilities; a vector is its compact answer string.
- CWE: a public catalogue of weakness types, such as CWE-93 for CRLF injection.
- Easy handle: libcurl's internal object holding one transfer's settings.
- Escaping: rewriting dangerous characters in a harmless form so they cannot change the meaning of a message.
- Header: a labelled line in a request or response carrying extra information, such as
Session:orTransport:. - Helper: a small reusable function written once and called from many places.
- IP camera: a camera that connects over a network and serves its video itself.
- Library: a bundle of code that other programs reuse instead of writing it themselves.
- NVR: network video recorder, a device that records several network cameras.
- OpenSSL: a widely used library that handles encryption.
- Option (
CURLOPT_*): a named setting a program uses to configure libcurl. - PoC (proof of concept): a working demonstration that a bug is real.
- Precondition: something that must already be true for an attack to work.
- Regression test: a test that makes sure a fixed bug stays fixed.
- Request smuggling: hiding a second request inside the first so the server processes both.
- Resource path: the part of an address naming a particular thing, such as
/camera-A. - RTP: the protocol that carries the actual media stream, separate from RTSP which controls it.
- RTSP: Real Time Streaming Protocol, the language for controlling a live media stream.
- Session: a conversation the server remembers and labels, so later requests can refer back to it.
- Severity: a rough scale of how bad a vulnerability is.
- Stateful: remembering information between requests rather than treating each one in isolation.
- Tag: a human-friendly name for a particular saved version of code.
- TCP connection: the network channel between two programs, like a phone call that stays open.
- Test harness: the set of tools built to demonstrate and observe a bug.
- Validation: checking that input is safe before using it.
- Vector (CVSS): the compact string of letters recording a vulnerability score's answers.