Skip to content

fix(tls): reject non-contiguous --tls-protocols on OpenSSL 4.0 - #444

Merged
fcostaoliveira merged 1 commit into
masterfrom
fix/tls-contiguous-protocols-openssl4
Jun 2, 2026
Merged

fcostaoliveira merged 1 commit into
masterfrom
fix/tls-contiguous-protocols-openssl4

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Jun 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • PR fix(tls): replace SSL_OP_NO_TLSv1/1_1 with set_min_proto_version (OpenSSL 4.0 compat) #432 added #ifdef SSL_OP_NO_TLSv1_x gap-mask blocks so the build works on OpenSSL 4.0 (where per-version disable constants are removed), but a user passing a non-contiguous --tls-protocols bitmask (e.g. tlsv1,tlsv1.2) on OpenSSL 4.0 would silently get the intermediate version (TLSv1.1) enabled with no warning.
  • Adds a bitmask_is_contiguous() helper (gated under #if OPENSSL_VERSION_NUMBER >= 0x40000000L) and a parser-time check that rejects non-contiguous selections on OpenSSL 4.0+ with an actionable error message.
  • On OpenSSL <= 3.x the existing gap-mask logic is unchanged; the new code compiles to nothing.

Test plan

  • Build with OpenSSL 3.x (current CI): clean build, zero new warnings -- confirmed locally.
  • Manual compilation against OpenSSL 4.0 is out of scope for CI; the guard is correct by construction and the helper is straightforward to unit-test if a 4.0 builder is added later.
  • Contiguous cases (tlsv1.2, tlsv1.1+tlsv1.2, tlsv1+tlsv1.1+tlsv1.2) must pass; non-contiguous cases (tlsv1+tlsv1.2, tlsv1+tlsv1.3) must be rejected.

Addresses Review 14 + PR #432 Review R4 concern (Refs: 2.4 review #37).

Generated with Claude Code


Note

Medium Risk
Changes TLS protocol selection behavior at startup on OpenSSL 4.0+ builds; previously invalid combinations could negotiate broader protocol versions than intended.

Overview
On OpenSSL 4.0+, per-version SSL_OP_NO_TLSv1_x gap masking in ssl_ctx_init no longer applies, so a non-contiguous --tls-protocols choice (e.g. tlsv1,tlsv1.2) could silently allow skipped versions (such as TLS 1.1) within the min/max envelope.

This PR adds a bitmask_is_contiguous() helper (compiled only when OPENSSL_VERSION_NUMBER >= 0x40000000L) and a parse-time check right after --tls-protocols is parsed that rejects non-contiguous selections with a clear error. Builds against OpenSSL ≤ 3.x are unchanged—the new code is ifdef’d out.

Reviewed by Cursor Bugbot for commit 98b49b5. Bugbot is set up for automated code reviews on this repo. Configure here.

PR #432 added gap-mask SSL_OP_NO_TLSv1_x #ifdef blocks so the build
works on OpenSSL 4.0 (where those constants are slated for removal).
But a user passing a non-contiguous bitmask (e.g. tlsv1,tlsv1.2)
on OpenSSL 4.0 would silently get the intermediate version enabled
inside the envelope, with no warning.

Adds parser-time validation: on OpenSSL >= 4.0 a non-contiguous
bitmask is rejected at startup with an actionable error. On OpenSSL
<= 3.x the gap-mask logic still enforces the user's selection.

Refs: 2.4 review #37 (Review 14 + PR #432 review R4).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@jit-ci

jit-ci Bot commented Jun 2, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@fcostaoliveira
fcostaoliveira merged commit 46c13eb into master Jun 2, 2026
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant