curl/lib/vtls
Jay Satiro 12e1def51a sendf: change Curl_read_plain to wrap Curl_recv_plain
Prior to this change Curl_read_plain would attempt to read the
socket directly. On Windows that's a problem because recv data may be
cached by libcurl and that data is only drained using Curl_recv_plain.

Rather than rewrite Curl_read_plain to handle cached recv data, I
changed it to wrap Curl_recv_plain, in much the same way that
Curl_write_plain already wraps Curl_send_plain.

Curl_read_plain -> Curl_recv_plain
Curl_write_plain -> Curl_send_plain

This fixes a bug in the schannel backend where decryption of arbitrary
TLS records fails because cached recv data is never drained. We send
data (TLS records formed by Schannel) using Curl_write_plain, which
calls Curl_send_plain, and that may do a recv-before-send
("pre-receive") to cache received data. The code calls Curl_read_plain
to read data (TLS records from the server), which prior to this change
did not call Curl_recv_plain and therefore cached recv data wasn't
retrieved, resulting in malformed TLS records and decryption failure
(SEC_E_DECRYPT_FAILURE).

The bug has only been observed during Schannel TLS 1.3 handshakes. Refer
to the issue and PR for more information.

Ref: https://github.com/curl/curl/issues/9431#issuecomment-1312420361

Assisted-by: Joel Depooter
Reported-by: Egor Pugin

Fixes https://github.com/curl/curl/issues/9431
Closes https://github.com/curl/curl/pull/9904
2022-11-18 03:04:13 -05:00
..
bearssl.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
bearssl.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
gskit.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
gskit.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
gtls.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
gtls.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
hostcheck.c copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
hostcheck.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
keylog.c lib and tests: add missing curl.h includes 2022-09-12 09:41:47 +02:00
keylog.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
mbedtls_threadlock.c tidy-up: process.h detection and use 2022-11-01 22:27:28 +00:00
mbedtls_threadlock.h tidy-up: process.h detection and use 2022-11-01 22:27:28 +00:00
mbedtls.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
mbedtls.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
nss.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
nssg.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
openssl.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
openssl.h openssl: make certinfo available for QUIC 2022-09-27 14:02:27 +02:00
rustls.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
rustls.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
schannel_verify.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
schannel.c sendf: change Curl_read_plain to wrap Curl_recv_plain 2022-11-18 03:04:13 -05:00
schannel.h misc: remove duplicated include files 2022-10-26 11:27:59 +02:00
sectransp.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
sectransp.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
vtls_int.h lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
vtls.c vtls: fix build without proxy support 2022-11-12 00:14:24 +01:00
vtls.h lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
wolfssl.c lib: connection filters (cfilter) addition to curl: 2022-11-11 15:17:51 +01:00
wolfssl.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00
x509asn1.c ctype: remove all use of <ctype.h>, use our own versions 2022-09-06 08:32:36 +02:00
x509asn1.h copyright: make repository REUSE compliant 2022-06-13 09:13:00 +02:00