Skip to content

Fix inverted MinTlsVersion protocol version mapping - #438

Merged
jadamcrain merged 3 commits into
mainfrom
fix/min-tls-version-inverted
Jul 27, 2026
Merged

Fix inverted MinTlsVersion protocol version mapping#438
jadamcrain merged 3 commits into
mainfrom
fix/min-tls-version-inverted

Conversation

@jadamcrain

Copy link
Copy Markdown
Member

Summary

From<MinTlsVersion> for ProtocolVersions had its match arms swapped, so neither variant did what its name and documentation said:

Variant Was configured Now
V12 TLS 1.2 only TLS 1.2 and 1.3
V13 TLS 1.2 and 1.3 TLS 1.3 only

The security-relevant half is V13: because TLS 1.2 remained enabled, the setting did not fail closed against a peer that only supports TLS 1.2, despite the guide stating it "will force the usage of TLSv1.3". V12 — the default in the bindings — pinned connections to TLS 1.2 and made TLS 1.3 unavailable.

This is not an exploitable weakness: rustls only offers hardened TLS 1.2 suites, and active downgrade is still caught by the TLS 1.2 ServerHello sentinel. The defect is that a stated security control did not enforce, and gave no signal that it hadn't.

Introduced in 25da741 (#333), first shipped in 1.6.0.

Changes:

  • Swap the arms so each matches its documented meaning.
  • Add tests asserting the configured version set per variant; both fail against the previous implementation.
  • Clarify the MinTlsVersion doc comments and the v13 FFI schema description to state the fail-closed behavior.
  • Correct the TLS guide, which also used variant names (Tls1_2, Tls1_3) that exist in no binding.
  • Changelog entry under 1.7.0-RC4, with a :bell: note: V13 users become stricter, and bindings users on the default V12 gain TLS 1.3 negotiation.

Known gap: the tests cover the configured ProtocolVersions, which is what regressed, but not a live handshake — that needs certificate fixtures the repo doesn't currently have. Worth a follow-up.

Fixes #437

MinTlsVersion::V13 mapped to a ProtocolVersions value with both TLS 1.2
and 1.3 enabled, so it did not exclude TLS 1.2 and would not fail the
handshake against a peer that only supports TLS 1.2. MinTlsVersion::V12
mapped to v12_only(), disabling TLS 1.3 entirely.

Swap the arms so each matches its documented meaning: V12 allows TLS 1.2
and 1.3, V13 allows only TLS 1.3. Add tests asserting the configured
version set for each variant, clarify the enum and FFI schema
documentation, and correct the TLS section of the guide.

Fixes #437
The guide referred to Tls1_2 and Tls1_3, which are not the variant names
in any binding. Use V12 and V13, matching the convention already used for
CertificateMode elsewhere in the same document, and attribute the default
to the bindings rather than implying Rust has one.
@jadamcrain jadamcrain added bug Something isn't working documentation Improvements or additions to documentation ffi Bindings issue labels Jul 27, 2026
@jadamcrain
jadamcrain merged commit c927a09 into main Jul 27, 2026
32 checks passed
@jadamcrain
jadamcrain deleted the fix/min-tls-version-inverted branch July 27, 2026 02:20
@jadamcrain jadamcrain mentioned this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation ffi Bindings issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MinTlsVersion match arms are inverted — V13 permits TLS 1.2, V12 disables TLS 1.3

1 participant