Uh oh!
There was an error while loading. Please reload this page.
net.tls: handle SSL.Error from set_min/max_proto_version in is_supported_version - #8294
Conversation
gaurav0107
commented
Jun 29, 2026
Heads up: the only red check is |
f1798a2 to
ad5f556Comparegaurav0107
commented
Jul 2, 2026
Update: I squashed the branch to a single commit ( |
Uh oh!
There was an error while loading. Please reload this page.
…ted_version is_supported_version() built an SSL.Context, set the min/max protocol version, then probed support with client_conn.recv(). Only the recv() probe was wrapped in try/except SSL.Error. On OpenSSL builds that have dropped a protocol version entirely (e.g. SSLv3 after POODLE / CVE-2014-3566, see pyca/cryptography#9523), set_min_proto_version(SSL3_VERSION) raises SSL.Error already at context-setup time, before the guarded recv(). The exception then propagated unhandled and crashed callers such as TlsConfig._warn_unsupported_version, which iterates over every Version to build the "supported versions" list. Move the protocol-version setters and connection setup inside the existing try, so a setup-time SSL.Error is treated the same as a probe-time one: the version is reported as unsupported (return False) instead of raising. Behavior for currently-supported versions is unchanged. Add a regression test that monkeypatches SSL.Context.set_min_proto_version to raise SSL.Error, reproducing the crash path deterministically on any OpenSSL build, and clear the is_supported_version LRU cache around it. Closesmitmproxy#8264
ad5f556 to
324cf78CompareUh oh!
There was an error while loading. Please reload this page.
Description
mitmproxy.net.tls.is_supported_version()builds anSSL.Context, sets themin/max protocol version, then probes support with
client_conn.recv(). Onlythe
recv()probe was wrapped intry/except SSL.Error.On OpenSSL builds that have dropped a protocol version entirely (e.g. SSLv3
after POODLE / CVE-2014-3566, see pyca/cryptography#9523),
set_min_proto_version(SSL3_VERSION)raisesSSL.Errorimmediately atcontext-setup time — before the guarded
recv(). The exception thenpropagated unhandled and crashed callers. The only production caller,
TlsConfig._warn_unsupported_version, iterates over everyVersionto buildthe "supported versions" list, so on those builds option validation crashed
outright.
This moves the protocol-version setters and connection setup inside the
existing
try, so a setup-timeSSL.Erroris treated the same as aprobe-time one: the version is reported as unsupported (
return False) insteadof raising. Behavior for currently-supported versions is unchanged.
A regression test (
test_supported_setup_error) monkeypatchesSSL.Context.set_min_proto_versionto raiseSSL.Error, reproducing the crashpath deterministically on any OpenSSL build (the existing
test_supported[SSL3]only exercises the
recv()path on builds that still allow SSL3 context setup).Closes#8264
Note: #8254 also touches this function but bundles it with an unrelated CRLF
prettifier fix (#8253) across four files. This PR is a focused, single-concern
alternative scoped to #8264 only; happy to defer to whichever the maintainers
prefer.
Checklist
## Unreleased: mitmproxy next).