# POST following PUT confusion

Reused libcurl easy handle that did a PUT then a POST wrongly invokes the read callback, sending CURLOPT_READDATA (or stdin) instead of POSTFIELDS, leaking data or causing UAF.

- Payout: $2,400
- Severity: medium
- Program: Internet Bug Bounty
- Found by: robbotic
- Disclosed: 2022-12-02
- CVE: CVE-2022-32221
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1752146
- Library page: https://bugbountylibrary.com/r/h1%3A1752146
- Tags: area:oss domain:oss impact:data-leak impact:dos kind:bounty platform:hackerone sev:medium tech:curl technique:regression technique:source-review vuln:info-disclosure vuln:memory-corruption

**Target:** libcurl easy handle state machine (PUT-to-POST transition)
**Root cause:** When a reused easy handle switches from PUT (using CURLOPT_READFUNCTION) to POST with CURLOPT_POSTFIELDS set, libcurl still calls the read callback instead of using the postfields buffer.
**Steps:**
1. Create easy handle, set CURLOPT_UPLOAD=1 and CURLOPT_READFUNCTION/CURLOPT_READDATA, perform PUT to host1.com.
2. Reuse same handle: set CURLOPT_POSTFIELDS to intended POST body, clear upload, perform POST to host2.com.
3. Observe libcurl performs an HTTP PUT, invoking the read callback and sending CURLOPT_READDATA contents (or stdin if unset) instead of POSTFIELDS.
4. If READDATA was freed between requests, observe use-after-free read.
**How found:** Reporter noticed a behavioral anomaly in curl issue #9507: a POST following a PUT on the same handle sent unexpected data, traced to the read callback being invoked despite CURLOPT_POSTFIELDS being set.
**Exploitation:** No active exploit demonstrated; presumed scenario where an app reuses a handle across hosts and leaks the PUT read-buffer (potentially credentials for host1) to host2, or reads freed memory causing segfault.
**Insight:** State-machine bugs in reused HTTP client handles: test option transitions (PUT->POST, upload->postfields) on the same handle, since per-request options may not fully reset and can leak buffers meant for a different host.

