Skip to content
DoS Disclosed report Intermediate

Cookie Max-Age Integer Overflow Vulnerability

The cookie parsing code in curl's lib/cookie.c has an integer overflow when adding a large Max-Age value to the current time, which can cause cookies to expire immediately or persist indefinitely. An attacker controlling a server or performing a man-in-the-middle attack could send crafted Set-Cookie headers to manipulate cookie lifetimes, potentially leading to denial of service or privacy violations.

bhaskar_ram Follow

Originally disclosed on HackerOne

Critical View original
  • Disclosed after 2 hours

Summary:

The cookie parsing code in lib/cookie.c contains an integer overflow vulnerability when processing the Max-Age attribute of HTTP cookies. The vulnerable code attempts to add the max-age value to the current timestamp without adequate overflow protection

While the code includes an overflow check (CURL_OFF_T_MAX - now < co->expires), this check itself can experience integer overflow in edge cases where:

  1. The max-age value is extremely large (near CURL_OFF_T_MAX)
  2. The current time (now) is large enough that the subtraction CURL_OFF_T_MAX - now produces unexpected results
  3. The addition co->expires += now occurs without proper bounds checking

An attacker can exploit this vulnerability by:

  1. Controlling a web server or performing a man-in-the-middle attack
  2. Sending HTTP responses with Set-Cookie headers containing extremely large Max-Age values
  3. Causing curl/libcurl to incorrectly calculate cookie expiration times
  4. Resulting in cookies persisting beyond their intended lifetime or being immediately expired

Vulnerable Code Location: lib/cookie.c:607-611

C
else if(CURL_OFF_T_MAX - now < co->expires)
    /* would overflow */
    co->expires = CURL_OFF_T_MAX;
else
    co->expires += now;

Affected version

Affected Versions: curl 7.x - 8.x

Steps To Reproduce:

Vulnerable Code Flow

  1. Cookie Header Parsing (parse_cookie_header())

    • Parses Max-Age attribute from Set-Cookie header
    • Calls curlx_str_number() to convert string to integer
    • Handles overflow cases but with insufficient protection
  2. Overflow Check (Line 607)

    C
    if(CURL_OFF_T_MAX - now < co->expires)
    
    • This check can itself overflow when now is large
    • Does not account for all edge cases
  3. Time Addition (Line 611)

    C
    co->expires += now;
    
    • Performs addition without verifying result
    • Can wrap around on overflow

Exploitation Scenarios

Scenario 1: Maximum Max-Age Value

HTTP
HTTP/1.1 200 OK
Set-Cookie: session=abc123; Max-Age=9223372036854775807; Path=/
  • Max-Age set to CURL_OFF_T_MAX (64-bit maximum)
  • When added to current time, may overflow
  • Cookie may expire immediately or persist indefinitely

Scenario 2: Near-Overflow Value

HTTP
HTTP/1.1 200 OK
Set-Cookie: tracking=xyz; Max-Age=9223372036854000000; Path=/
  • Max-Age chosen to overflow when added to time(NULL)
  • Bypasses overflow check due to edge case
  • Results in incorrect expiration calculation

Scenario 3: Cookie Jar Pollution

HTTP
HTTP/1.1 200 OK
Set-Cookie: cookie1=val; Max-Age=9223372036854775807
Set-Cookie: cookie2=val; Max-Age=9223372036854775806
Set-Cookie: cookie3=val; Max-Age=9223372036854775805
... (repeated many times)
  • Multiple cookies with overflow values
  • Fills cookie jar with persistent cookies
  • Causes denial of service

PoC Server

A malicious HTTP server has been developed to demonstrate the vulnerability:

File: poc_cookie_overflow.py

Bash
# Run the PoC server
python3 poc_cookie_overflow.py

# Server starts on http://localhost:8000
# Provides 4 different exploit scenarios

Testing Steps

Test 1: Maximum Max-Age Value

Bash
# Test with vulnerable curl
curl -c cookies.txt http://localhost:8000/exploit1

# Examine cookie file
cat cookies.txt

# Expected (vulnerable): Cookie with incorrect expiration
# Expected (patched): Cookie capped at 400 days

Test 2: Near-Overflow Value

Bash
curl -c cookies.txt http://localhost:8000/exploit2
cat cookies.txt

# Check if overflow occurred
python3 -c "
import time
with open('cookies.txt') as f:
    for line in f:
        if 'near_overflow' in line:
            parts = line.split()
            expiry = int(parts[4])
            now = int(time.time())
            print(f'Expiry: {expiry}')
            print(f'Now: {now}')
            print(f'Diff: {expiry - now} seconds')
            print(f'Days: {(expiry - now) / 86400} days')
"

Test 3: Negative Max-Age

Bash
curl -c cookies.txt http://localhost:8000/exploit3
cat cookies.txt

# Verify cookie was expired immediately

Test 4: Cookie Jar Pollution

Bash
curl -c cookies.txt http://localhost:8000/exploit4
wc -l cookies.txt

# Should show 10+ cookies with overflow values

Supporting Material/References:

Attached PoC, patch files

Impact

Summary:

  • Attacker-set session cookies persist beyond intended lifetime
  • Users remain logged in indefinitely
  • Session tokens cannot be properly expired
  • Tracking cookies persist longer than allowed
  • User privacy preferences bypassed
  • GDPR/privacy regulation violations
  • Authentication cookies may expire immediately
  • Or persist indefinitely, preventing logout
  • Access control mechanisms compromised
  • Malformed cookies fill up cookie storage
  • Legitimate cookies may be evicted
  • Application functionality degraded

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

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

Context

curl is a command-line tool and library for transferring data with URLs, and libcurl is the library underneath it. One of the features libcurl implements is HTTP cookie handling: when a response carries a Set-Cookie header, the library parses the attributes, computes an expiry time and, if the user asked for a cookie jar with -c, writes the cookies to a file so they can be reused later.

The Max-Age attribute of a cookie tells the client how many seconds from now the cookie should live. To turn that into an absolute expiry timestamp, the parser adds the Max-Age value to the current time. The report concerns that addition in lib/cookie.c, where the value coming from the server is added to the current timestamp without adequate overflow protection.

The report is filed against the curl source repository, https://github.com/curl/curl, and is classified as an integer overflow (CWE-190).

Setup

No accounts or roles are involved. The preconditions are:

  1. A victim running a curl or libcurl build that contains the vulnerable code (the report lists affected versions as curl 7.x to 8.x).
  2. The ability to control the HTTP responses the victim receives, either by running the web server the victim connects to or by performing a man-in-the-middle attack.
  3. A curl invocation that stores cookies, for example with -c cookies.txt, so the resulting expiry values can be inspected.

The researcher wrote a malicious HTTP server, poc_cookie_overflow.py, which serves four exploit scenarios. It is started with:

Bash
# Run the PoC server
python3 poc_cookie_overflow.py

# Server starts on http://localhost:8000
# Provides 4 different exploit scenarios

The report's tests fetch the scenarios from http://localhost:8000/exploit1 through /exploit4.

Finding it

The vulnerable code is in lib/cookie.c:607-611:

C
else if(CURL_OFF_T_MAX - now < co->expires)
    /* would overflow */
    co->expires = CURL_OFF_T_MAX;
else
    co->expires += now;

The intent is clear: before adding the parsed Max-Age value (co->expires) to the current time (now), the code checks whether the addition would exceed CURL_OFF_T_MAX, the largest value the offset type can hold. If it would, the expiry is capped at CURL_OFF_T_MAX; otherwise the addition is performed.

The researcher's observation is that the guard itself can overflow. The expression CURL_OFF_T_MAX - now is evaluated first, and in edge cases where now is large enough, that subtraction does not produce the value the comparison assumes. The check therefore does not cover all edge cases, and the subsequent co->expires += now can wrap around.

The report describes the flow that reaches this code:

  1. parse_cookie_header() parses the Max-Age attribute from the Set-Cookie header.
  2. It calls curlx_str_number() to convert the string to an integer. That conversion handles overflow cases, but the report states the protection is insufficient.
  3. The overflow check at line 607 runs, and can itself overflow when now is large.
  4. The addition at line 611 runs without verifying the result, and can wrap around on overflow.

The consequence is that curl/libcurl can calculate cookie expiration times incorrectly, so cookies persist beyond their intended lifetime or are immediately expired.

Exploitation

The report frames exploitation as: control a web server or perform a man-in-the-middle attack, send HTTP responses with Set-Cookie headers carrying extremely large Max-Age values, cause curl/libcurl to miscalculate the expiration, and end up with cookies that outlive their intended lifetime or expire at once. It gives three scenarios and four tests against the PoC server.

Step 1: Maximum Max-Age value

The first scenario sends a Max-Age equal to CURL_OFF_T_MAX, the 64-bit maximum:

HTTP
HTTP/1.1 200 OK
Set-Cookie: [redacted] Max-Age=9223372036854775807; Path=/

When this value is added to the current time it may overflow, so the cookie may expire immediately or persist indefinitely. The corresponding test fetches the scenario and inspects the jar:

Bash
# Test with vulnerable curl
curl -c cookies.txt http://localhost:8000/exploit1

# Examine cookie file
cat cookies.txt

# Expected (vulnerable): Cookie with incorrect expiration
# Expected (patched): Cookie capped at 400 days

On a vulnerable build the stored expiry is wrong; on a patched build the expiry is capped at 400 days.

Step 2: Near-overflow value

The second scenario picks a value just below the maximum, chosen so that adding it to time(NULL) overflows and bypasses the check:

HTTP
HTTP/1.1 200 OK
Set-Cookie: tracking=xyz; Max-Age=9223372036854000000; Path=/

The test fetches the scenario and then parses the jar to compare the stored expiry with the current time:

Bash
curl -c cookies.txt http://localhost:8000/exploit2
cat cookies.txt

# Check if overflow occurred
python3 -c "
import time
with open('cookies.txt') as f:
    for line in f:
        if 'near_overflow' in line:
            parts = line.split()
            expiry = int(parts[4])
            now = int(time.time())
            print(f'Expiry: {expiry}')
            print(f'Now: {now}')
            print(f'Diff: {expiry - now} seconds')
            print(f'Days: {(expiry - now) / 86400} days')
"

The script reads the expiry field (the fifth whitespace-separated field of the cookie line), subtracts the current time and prints the difference in seconds and days.

Step 3: Negative Max-Age

The third scenario exercises a negative Max-Age and checks that the cookie is expired immediately:

Bash
curl -c cookies.txt http://localhost:8000/exploit3
cat cookies.txt

# Verify cookie was expired immediately

Step 4: Cookie jar pollution

The fourth scenario sends many cookies with overflow values in one response:

HTTP
HTTP/1.1 200 OK
Set-Cookie: cookie1=val; Max-Age=9223372036854775807
Set-Cookie: cookie2=val; Max-Age=9223372036854775806
Set-Cookie: cookie3=val; Max-Age=9223372036854775805
... (repeated many times)

This fills the cookie jar with persistent cookies. The test counts the lines in the jar:

Bash
curl -c cookies.txt http://localhost:8000/exploit4
wc -l cookies.txt

# Should show 10+ cookies with overflow values

The report's comment says the count should show 10 or more cookies with overflow values.

Root cause

The parser converts the Max-Age string with curlx_str_number() and then tries to add it to the current time. The guard against overflow is written as CURL_OFF_T_MAX - now < co->expires. That guard assumes the subtraction CURL_OFF_T_MAX - now is itself safe, but in edge cases where now is large the subtraction produces unexpected results, so the comparison can pass values that will overflow when added. The addition co->expires += now then runs without verifying its result and wraps around.

The existing defence, the single comparison before the addition, therefore does not cover all inputs: the check and the operation it protects are not equivalent in the edge cases the report describes. The report does not go further into which specific values of now trigger the failure.

Impact

The report lists the following consequences, framed as what an attacker can achieve when they control the responses a curl/libcurl user receives:

  • Attacker-set session cookies persist beyond their intended lifetime, so users remain logged in indefinitely and session tokens cannot be properly expired.
  • Tracking cookies persist longer than allowed, bypassing user privacy preferences and leading to GDPR/privacy regulation violations.
  • Authentication cookies may expire immediately, or persist indefinitely, preventing logout.
  • Access control mechanisms are compromised.
  • Malformed cookies fill up cookie storage, legitimate cookies may be evicted and application functionality is degraded (the denial-of-service case shown in scenario 4).

These outcomes depend on the attacker being able to serve or modify the HTTP responses the victim's curl/libcurl instance processes.

Fix

The report does not describe a patch. Its own tests state the expected behaviour after a fix: in Test 1, a patched build caps the cookie at 400 days rather than storing an incorrect expiration. The report also attaches PoC and patch files as supporting material without describing their contents.

Variants to test

  • Send Max-Age values at and just below the type maximum (as in scenarios 1 and 2) against any client that converts cookie lifetimes into absolute timestamps, and inspect the stored expiry. A positive result is an expiry that is negative, wrapped, or far outside the intended lifetime.
  • Send a negative Max-Age and confirm the cookie is expired immediately rather than stored with a bogus expiry.
  • Send many overflow-valued cookies in one response and count the resulting jar entries; a positive result is a jar filled with persistent cookies from a single response.
  • Repeat the same inputs on a patched build and confirm the expiry is capped (the report's expected value is 400 days).

Hunting notes

This class of bug lives in parsers that turn attacker-supplied numeric attributes into timestamps or sizes: cookie Max-Age and Expires handling, cache lifetime headers, and any code that adds a remote value to the current clock. The signal during review is a hand-written overflow guard of the form MAX - now < value followed by an unchecked addition; the guard is only correct if the subtraction cannot itself overflow. To show impact, demonstrate the stored value after the addition (a cookie jar is a convenient observable) and, where possible, the persistence or immediate expiry of a session cookie. The report supports its case with a runnable PoC server covering four scenarios and with before/after expectations for a patched build.

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

What happened, in plain words

curl is a small program you run in a terminal to fetch things from the internet, and libcurl is the engine inside it that other programs also use. One of the jobs libcurl does is handle cookies. A cookie is a small piece of text that a website asks your browser (or curl) to keep and send back on later requests, usually so the site can remember who you are. When a website sends a cookie, it can also say how long the cookie should live, using an attribute called Max-Age, which is a number of seconds counted from now.

To store a cookie, curl has to turn "live for this many seconds" into "expire at this exact moment in the future". It does that by adding the number of seconds to the current time. The report is about that addition: when the number of seconds is enormous, the sum can go wrong, and the cookie ends up with a nonsense expiry date. The report calls this an integer overflow, which is a whole class of bug explained below.

The report was filed against the curl source code repository at https://github.com/curl/curl, and it lists affected versions as curl 7.x to 8.x.

Background you need first

A few ideas come up again and again, so here they are from zero.

What a cookie is. Imagine a cloakroom. You hand over your coat, you get a ticket with a number, and later you hand the ticket back to get your coat. A cookie is that ticket: a short label the server gives your client, which the client shows again on the next visit so the server knows it is the same visitor. Session cookies are the ones that keep you logged in.

What Set-Cookie and Max-Age are. When a web server wants to hand out a ticket, it puts a line in its response called Set-Cookie. That line can carry extra instructions, called attributes. Max-Age is one of them: it says how many seconds from now the ticket stays valid. Path=/ is another attribute, saying which parts of the site the cookie applies to.

What a timestamp is. A computer usually stores a moment in time as a single number: the count of seconds since 1 January 1970. "Now" is just a big number that keeps growing. An expiry time is another big number, further in the future.

What an integer overflow is. Computers store whole numbers in fixed-size boxes. A 64-bit box can hold numbers up to 9223372036854775807 and no more. If you add two numbers and the true answer is bigger than the box allows, the result does not error out; it wraps around, like a car odometer rolling from 999999 back to 000000. So a very large expiry can silently become a small one, or even a negative one. That is an integer overflow, catalogued as CWE-190.

What a man-in-the-middle attack is. Normally your computer talks directly to a website. In a man-in-the-middle attack, someone sits between you and the site and can read or change the messages going both ways. If an attacker can do that, they can put their own Set-Cookie lines into the responses you receive.

What a cookie jar is. curl can save the cookies it receives into a plain text file so they can be reused later. You ask for this with the -c option followed by a filename. That file is called the cookie jar, and it is very handy for this report because you can open it and read the expiry times curl calculated.

Setup

There are no accounts or user roles in this report. To see the bug you need three things:

  1. A victim running a curl or libcurl build that contains the vulnerable code (the report lists curl 7.x to 8.x).
  2. The ability to control the HTTP responses the victim receives, either by running the web server the victim connects to, or by performing a man-in-the-middle attack.
  3. A curl command that saves cookies, for example with -c cookies.txt, so the resulting expiry values can be inspected.

The researcher wrote a small malicious web server, poc_cookie_overflow.py, which serves four different exploit scenarios. It is started like this:

Bash
# Run the PoC server
python3 poc_cookie_overflow.py

# Server starts on http://localhost:8000
# Provides 4 different exploit scenarios

Line by line: python3 poc_cookie_overflow.py runs the Python script with the Python 3 interpreter. The comments say the server then listens on http://localhost:8000, meaning on your own machine (localhost) at port 8000, and that it offers four scenarios. The report's tests fetch the scenarios from http://localhost:8000/exploit1 through /exploit4.

Finding it

The vulnerable code is in lib/cookie.c, lines 607 to 611:

C
else if(CURL_OFF_T_MAX - now < co->expires)
    /* would overflow */
    co->expires = CURL_OFF_T_MAX;
else
    co->expires += now;

Line by line: CURL_OFF_T_MAX is the largest number the offset type can hold, the top of the box. now is the current time. co->expires at this point holds the number of seconds taken from Max-Age. The first line asks: if I subtract the current time from the maximum, is that still smaller than the requested lifetime? If yes, the lifetime would not fit, so the second line caps the expiry at the maximum. Otherwise the last line adds the current time to the lifetime, producing the absolute expiry moment.

The intent is sensible: check before you add, so you never overflow. The researcher's observation is that the check itself can overflow. The expression CURL_OFF_T_MAX - now is calculated first, and in edge cases where now is large enough, that subtraction does not produce the value the comparison assumes. The guard therefore does not cover every case, and the addition co->expires += now can wrap around.

The report describes the path the data takes to reach this code:

  1. parse_cookie_header() reads the Max-Age attribute out of the Set-Cookie header.
  2. It calls curlx_str_number() to turn the text into a number. That conversion handles overflow cases, but the report says the protection is insufficient.
  3. The overflow check at line 607 runs, and can itself overflow when now is large.
  4. The addition at line 611 runs without checking its result, and can wrap around.

The result is that curl or libcurl can work out a cookie's expiry time incorrectly, so the cookie either lives far longer than it should or expires straight away.

Exploitation

The report frames the attack in four moves: control a web server or perform a man-in-the-middle attack, send HTTP responses whose Set-Cookie headers carry extremely large Max-Age values, make curl or libcurl miscalculate the expiry, and end up with cookies that outlive their intended lifetime or expire at once. It then gives three scenarios and four tests against the PoC server.

Step 1: Maximum Max-Age value

The first scenario sends a Max-Age equal to CURL_OFF_T_MAX, the 64-bit maximum:

HTTP
HTTP/1.1 200 OK
Set-Cookie: [redacted] Max-Age=9223372036854775807; Path=/

Line by line: HTTP/1.1 200 OK is the server saying the request succeeded. Set-Cookie: hands out a cookie named session with the value abc123. Max-Age=9223372036854775807 asks for a lifetime of 9223372036854775807 seconds, which is the largest number the box can hold. Path=/ says the cookie applies to the whole site. When that lifetime is added to the current time, the sum may overflow, so the cookie may expire immediately or persist indefinitely.

The corresponding test fetches the scenario and inspects the jar:

Bash
# Test with vulnerable curl
curl -c cookies.txt http://localhost:8000/exploit1

# Examine cookie file
cat cookies.txt

# Expected (vulnerable): Cookie with incorrect expiration
# Expected (patched): Cookie capped at 400 days

Line by line: curl -c cookies.txt http://localhost:8000/exploit1 asks curl to fetch the first scenario and save any cookies it receives into cookies.txt. cat cookies.txt prints that file so you can read it. The comments state what to expect: on a vulnerable build the stored expiry is wrong, and on a patched build the expiry is capped at 400 days.

Step 2: Near-overflow value

The second scenario picks a value just below the maximum, chosen so that adding it to the current time overflows and slips past the check:

HTTP
HTTP/1.1 200 OK
Set-Cookie: tracking=xyz; Max-Age=9223372036854000000; Path=/

Line by line: this is the same shape of response, but the cookie is named tracking with value xyz, and the lifetime is 9223372036854000000 seconds, a little less than the maximum. The report says this value is chosen so that adding it to time(NULL), which is the C way of asking for the current time, overflows and bypasses the check.

The test fetches the scenario and then parses the jar to compare the stored expiry with the current time:

Bash
curl -c cookies.txt http://localhost:8000/exploit2
cat cookies.txt

# Check if overflow occurred
python3 -c "
import time
with open('cookies.txt') as f:
    for line in f:
        if 'near_overflow' in line:
            parts = line.split()
            expiry = int(parts[4])
            now = int(time.time())
            print(f'Expiry: {expiry}')
            print(f'Now: {now}')
            print(f'Diff: {expiry - now} seconds')
            print(f'Days: {(expiry - now) / 86400} days')
"

Line by line: the first two commands fetch the second scenario and print the jar. The python3 -c part runs a short Python program given directly on the command line. import time loads Python's time tools. with open('cookies.txt') as f: opens the jar and closes it automatically when done. for line in f: walks through the file one line at a time. if 'near_overflow' in line: picks out the cookie line for this scenario. parts = line.split() chops the line into pieces separated by spaces. expiry = int(parts[4]) takes the fifth piece, counting from zero, which is the expiry field, and turns it into a number. now = int(time.time()) gets the current time as a whole number of seconds. The four print lines then show the expiry, the current time, the difference in seconds, and the same difference in days (86400 seconds in a day).

Step 3: Negative Max-Age

The third scenario uses a negative Max-Age and checks that the cookie is expired immediately:

Bash
curl -c cookies.txt http://localhost:8000/exploit3
cat cookies.txt

# Verify cookie was expired immediately

Line by line: fetch the third scenario, save cookies to the jar, print the jar, and confirm from the output that the cookie was expired immediately rather than stored with a bogus expiry.

Step 4: Cookie jar pollution

The fourth scenario sends many cookies with overflow values in a single response:

HTTP
HTTP/1.1 200 OK
Set-Cookie: cookie1=val; Max-Age=9223372036854775807
Set-Cookie: cookie2=val; Max-Age=9223372036854775806
Set-Cookie: cookie3=val; Max-Age=9223372036854775805
... (repeated many times)

Line by line: each Set-Cookie line hands out one cookie, named cookie1, cookie2, cookie3 and so on, each with the value val, and each with a lifetime one second smaller than the last, all sitting at the very top of the number range. The ... means the pattern repeats many times. The effect is to fill the cookie jar with persistent cookies.

The test counts the lines in the jar:

Bash
curl -c cookies.txt http://localhost:8000/exploit4
wc -l cookies.txt

# Should show 10+ cookies with overflow values

Line by line: fetch the fourth scenario into the jar, then run wc -l cookies.txt, which counts the lines in the file. The comment says the result should show 10 or more cookies with overflow values.

Root cause

The parser turns the Max-Age text into a number with curlx_str_number() and then tries to add it to the current time. The guard against overflow is written as CURL_OFF_T_MAX - now < co->expires. That guard assumes the subtraction CURL_OFF_T_MAX - now is itself safe, but in edge cases where now is large the subtraction produces unexpected results, so the comparison can let through values that will overflow when added. The addition co->expires += now then runs without checking its result and wraps around.

The existing defence, a single comparison before the addition, therefore does not cover all inputs: the check and the operation it protects do not agree in the edge cases the report describes. The report does not go further into which specific values of now trigger the failure.

Impact

The report lists the following consequences, framed as what an attacker can achieve when they control the responses a curl or libcurl user receives:

  • Attacker-set session cookies persist beyond their intended lifetime, so users remain logged in indefinitely and session tokens cannot be properly expired.
  • Tracking cookies persist longer than allowed, bypassing user privacy preferences and leading to GDPR and privacy regulation violations.
  • Authentication cookies may expire immediately, or persist indefinitely, preventing logout.
  • Access control mechanisms are compromised.
  • Malformed cookies fill up cookie storage, legitimate cookies may be evicted and application functionality is degraded, which is the denial-of-service case shown in the cookie jar pollution scenario.

All of these outcomes depend on the attacker being able to serve or modify the HTTP responses that the victim's curl or libcurl instance processes.

Fix

The report does not describe a patch. Its own tests state the expected behaviour after a fix: in the first test, a patched build caps the cookie at 400 days instead of storing an incorrect expiry. The report also attaches PoC and patch files as supporting material without describing their contents.

Variants to test

  • Send Max-Age values at and just below the type maximum, as in scenarios 1 and 2, against any client that turns cookie lifetimes into absolute timestamps, and inspect the stored expiry. A positive result is an expiry that is negative, wrapped, or far outside the intended lifetime.
  • Send a negative Max-Age and confirm the cookie is expired immediately rather than stored with a bogus expiry.
  • Send many overflow-valued cookies in one response and count the resulting jar entries; a positive result is a jar filled with persistent cookies from a single response.
  • Repeat the same inputs on a patched build and confirm the expiry is capped, with the report's expected value of 400 days.

Hunting notes

This class of bug lives in parsers that turn attacker-supplied numeric attributes into timestamps or sizes: cookie Max-Age and Expires handling, cache lifetime headers, and any code that adds a remote value to the current clock. The signal during review is a hand-written overflow guard of the form MAX - now < value followed by an unchecked addition; the guard is only correct if the subtraction cannot itself overflow. To show impact, demonstrate the stored value after the addition, and a cookie jar is a convenient observable, and where possible show the persistence or immediate expiry of a session cookie. The report supports its case with a runnable PoC server covering four scenarios and with before and after expectations for a patched build.

Glossary

  • curl: a command-line program for fetching data from URLs.
  • libcurl: the library underneath curl that other programs also use to do the same transfers.
  • Cookie: a small piece of text a website asks a client to store and send back on later requests, often used to remember a logged-in user.
  • Cookie jar: a plain text file where curl saves cookies, requested with the -c option.
  • Set-Cookie: the response header a server uses to hand out a cookie.
  • Attribute: an extra instruction attached to a cookie, such as Max-Age or Path.
  • Max-Age: a cookie attribute giving the lifetime in seconds counted from now.
  • Path: a cookie attribute saying which parts of a site the cookie applies to.
  • Timestamp: a moment in time stored as a number, usually seconds since 1 January 1970.
  • Integer overflow: when a calculation produces a number too large for its fixed-size storage box, so the value wraps around instead of erroring.
  • CWE-190: the catalogue entry for integer overflow or wraparound.
  • CURL_OFF_T_MAX: the largest value the offset type used by curl can hold.
  • now: the current time, as used in the vulnerable calculation.
  • co->expires: the field holding the cookie's expiry, first as a lifetime and then as an absolute moment.
  • parse_cookie_header(): the function that reads cookie attributes out of a Set-Cookie header.
  • curlx_str_number(): the helper that converts a piece of text into a number.
  • Man-in-the-middle attack: an attacker sitting between a victim and a server, able to read or change the messages in both directions.
  • Denial of service: making a system unusable, here by filling cookie storage with junk.
  • GDPR: European data protection rules that limit how long personal data, including tracking cookies, may be kept.
  • PoC: proof of concept, a small working demonstration that a bug is real.
  • localhost: the name a computer uses to refer to itself.
  • Port: a numbered channel on a computer that a service listens on, such as 8000.
  • wc -l: a command that counts the lines in a file.
  • Session cookie: a cookie that keeps a user logged in.
  • Session token: the value inside a session cookie that identifies the logged-in user.

More by bhaskar_ram

View all

8 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.

Denial of service

The lesson behind this report.

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