Skip to content

pingpong: call Curl_pp_init() in the DO actions of the users#12752

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/pp-init
Closed

pingpong: call Curl_pp_init() in the DO actions of the users#12752
bagder wants to merge 1 commit intomasterfrom
bagder/pp-init

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Jan 21, 2024

... and not in *connect.

The pp_init function stores a pointer to the current download buffer for the handle and if the transfer is performed on a reused connection, the *connect function is not called and as a result then pp_init is not called for this transfer from there.

A second place that calls pp_init is the pingpong sendf() function.

If pp_init is NOT called, the pingpong struct keeps the old pointer set when the connectiom was setup. As the download buffer is allocated on-demand when reaching the CONNECT state and freed in the DONE state, there is a risk that a transfer reusing a connection uses a different buffer which can lead to the the pingpong code accessing the already freed buffer.

Thanks to the backup call in the send function, this bug is hard to trigger: it needs to reuse the connection, not send any commands because of an early failure and yet have the pingpong code attempt reading response data from the server.

This has so far only been achieved by the fuzzer.

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66012

@bagder
Copy link
Copy Markdown
Member Author

bagder commented Jan 22, 2024

#12757 is a bigger take that should supersede this. I keep this open until that happens, just in case.

@bagder bagder added the on-hold label Jan 22, 2024
... and not in *connect.

The pp_init function assigns the linestart_resp pointer to the current
download buffer for the handle and if the transfer is performed on a reused
connection, the *connect function is not called and as a result then pp_init
is not called for this transfer from there.

A second place that calls pp_init is the pingpong sendf() function.

If pp_init is NOT called, the pingpong struct keeps the old pointer set
when the connectiom was setup. As the download buffer is allocated
on-demand when reaching the CONNECT state and freed in the DONE state,
there is a risk that a transfer reusing a connection uses a different
buffer which can lead to the the pingpong code accessing the already
freed buffer.

Thanks to the backup call in the send function, this bug is hard to
trigger: it needs to reuse the connection, not send any commands because
of an early failure and yet have the pingpong code attempt reading
response data from the server.

This has so far only been achieved by the fuzzer when doing FTP wildcard
requests.

This is a temp fix while "the real one" is being worked on => completely
removing the (ab)use of the download buffer in the pingpong protocol
code.

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66012
@bagder
Copy link
Copy Markdown
Member Author

bagder commented Jan 25, 2024

Replaced by #12757

@bagder bagder closed this Jan 25, 2024
@bagder bagder deleted the bagder/pp-init branch January 25, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant