✓ProveIt
Examples / Report #3117697 Saved analysis

Double Free Vulnerability in `libcurl` Cookie Management (`cookie.c`)

curl · 2025-04-2917.3s analysis · $0.018 in model calls

What the report claims

Double free vulnerabilities in libcurl's cookie management code can lead to program crashes, arbitrary code execution, data integrity issues, and denial of service.

Compare with curl's recorded outcome

Labeled AI slop

curl's maintainer lists this report as AI slop

Shown for comparison after analysis. The pipeline did not see this label.

ProveIt's finding

Code contradicts the claim

The code provides evidence against the report's central claim. Review the cited lines before deciding.

Why this finding?
  • The replace_existing function (lib/cookie.c:1026–1036) correctly unlinks the node before freeing the cookie exactly once; no double-free is present in the provided code.
  • The Curl_cookie_add function body is not included in the provided source, so the second claim cannot be verified.
  • Since the primary claimed flaw is contradicted by the code and the secondary is unverifiable, the report does not demonstrate a valid security vulnerability.
What still needs checking
  • The complete Curl_cookie_add function implementation (including the fail: error path) from lib/cookie.c at the target revision.
How this analysis ran 6 claims · 5 citations verified

Checked against curl master on 2025-04-29 (2fa3d528aea1). Dev evaluation split. Citation verification checks that a referenced line was in the evidence; it does not prove the model interpreted it correctly.

1 · Grounding
grounded
no model · 5 references checked out, 0 did not
2 · Claims
NVIDIA-Nemotron-3-Nano-30B-A3B
6 claims · 1621 tokens · $0.0002
3 · Evidence
4 code snippets
real curl source at 2fa3d528aea1
4 · Judgment
Nemotron-3-Ultra-550b-a55b
10044 tokens · 13.2s · $0.0173
5 · Receipts
5 of 5 citations verified
every citation must point at code the judge was shown
Review a draft reply to the reporter

Edit and verify before sending.

Thank you for the report. In the provided code, replace_existing (lib/cookie.c:1026–1036) removes the node from the list with Curl_node_remove and then calls freecookie exactly once — there is no double-free. The Curl_cookie_add function body was not included in the source excerpt; please provide the full function (especially the fail: label and surrounding logic) so we can assess the second claim.

Inspect all claims and source code 6 claims · 4 code excerpts

Report claims

C1flaw contradicted

Double free occurs when a cookie object is freed without ensuring it has not already been removed from the list, leading to double-free in the replace_existing function.

Read the reasoning

The code shows a correct remove-then-free pattern: the node is unlinked from the list at line 1033, then the cookie is freed once at line 1036. There is no second free of the same pointer in this function, and the node was in the list during iteration (line 949–1025), so it had not been removed already.

C2flaw not verifiable

Memory allocated for a cookie object is freed again on errors even if it was previously released, causing double-free in the Curl_cookie_add function.

Read the reasoning

The actual implementation of Curl_cookie_add (including any fail: label and freecookie calls) is not present in the provided source. The deterministic checks confirm the symbol exists, but the code needed to evaluate the claim is missing.

C3trigger not verifiable

Create multiple cookies with identical names, domains, and paths to trigger replacement scenario in replace_existing function.

Read the reasoning

Trigger claim depends on C1 being a real flaw; since C1 is contradicted, this trigger does not demonstrate a vulnerability.

C4trigger not verifiable

Add a malformed or invalid cookie header line to trigger error path in Curl_cookie_add function.

Read the reasoning

Trigger claim depends on C2; without the Curl_cookie_add function body, it cannot be assessed.

C5impact not verifiable

Program crash or segmentation fault due to double-free leading to undefined behavior.

Read the reasoning

Impact claim depends on the existence of the double-free flaws, which are not substantiated.

C6impact not verifiable

Potential arbitrary code execution and data corruption from memory corruption caused by double-free.

Read the reasoning

Impact claim depends on the existence of the double-free flaws, which are not substantiated.

Read the original report (excerpt)

Full report on HackerOne ↗

## Description: Two **Double Free** vulnerabilities have been identified in the `cookie.c` file of the `libcurl` library. These issues occur due to improper memory management, where the same memory area is freed multiple times under certain conditions. Below are clear steps to reproduce each vulnerability. --- ### Summary: The vulnerabilities occur in the following scenarios: 1. **`replace_existing` Function**: A cookie object is freed without ensuring it has not already been removed from the list, leading to double-free. 2. **`Curl_cookie_add` Function**: On errors, memory allocated for a cookie object is freed again, even if it was previously released. ## Steps To Reproduce: ### Case 1: Vulnerability in `replace_existing` Function 1. Create multiple cookies with identical names, domains, and paths. 2. Trigger a scenario where an existing cookie needs to be replaced (e.g., by adding a new cookie with the same attributes). 3. Observe the program crash or unexpected behavior due to double-free in the following code: ```c if (replace_n) { struct Cookie *repl = Curl_node_elem(replace_n); Curl_node_remove(replace_n); // Remove from the list freecookie(repl); // Free memory (double-free if already removed) } ``` ### Case 2: Vulnerability in `Curl_cookie_add` Function 1. Add a malformed or invalid cookie header line to the cookie input file. 2. Ensure the program encounters an error during cookie parsing. 3. Observe the program crash or unexpected behavior due to double-free in the following code: ```c fail: freecookie(co); // Memory freed again even if already released return NULL; ``` --- ## Impact ### Summary The **Double Free** vulnerabilities in `libcurl` can have severe security implications: 1. **Program Crash**: A double-free leads to undefined behavior, often resulting in segmentation faults. 2. **Arbitrary Code Execution**: Attackers could exploit this issue to execute arbitrary code in the context of the vulnerable program. 3. **Data Integrity**: Memory corruption caused by this vulnerability can lead to data leakage or integrity issues, compromising the application's reliability. 4. **Denial of Service (DoS)**: Exploiting this vulnerability could result in a denial-of-service condition. These vulnerabilities can be exploited by attackers to compromise the security and stability …

Source code

lib/cookie.clines 938–1040 · definition of replace_existing
C1: replace_existing checks if replace_n is set, then gets the cookie element from the node
C1: Curl_node_remove(replace_n) unlinks the node from the list
C1: freecookie(repl) frees the cookie after removal — single free, not double
lib/llist.clines 201–204 · definition of Curl_node_remove
201void Curl_node_remove(struct Curl_llist_node *e)
C1: Curl_node_remove only unlinks; it does not free the element
202{
203 Curl_node_uremove(e, NULL);
204}
lib/cookie.clines 36–117 · definition of Curl_cookie_add
C2: Provided source lines 36–117 contain only comments and the cap_expires helper; the Curl_cookie_add function body is not included
lib/cookie.clines 119–127 · definition of freecookie
Show 9 lines (not cited by the judge)
119static void freecookie(struct Cookie *co)
120{
121 free(co->domain);
122 free(co->path);
123 free(co->spath);
124 free(co->name);
125 free(co->value);
126 free(co);
127}