feat: S12.28 surface TLS peer-hostname verification when ServerName is NULL#534
Conversation
…s NULL Both TLS adapters (OpenSSL, mbedTLS) bound the peer identity to the certificate only when ServerName was set, so a NULL ServerName completed the handshake against any cert chaining to a trusted CA — a silent, MITM-class default with no diagnostic. Make the unverified-peer case observable: - ServerName == NULL -> WARNING (BAD_CONFIG / *_SERVER_NAME_NOT_SET), still connect chain-only (preserves the closed-network / IP-pinning use case). - ServerName == "" -> deliberate opt-out: connect chain-only, no diagnostic. - Non-empty ServerName -> SNI + identity check, unchanged. Reuses the existing *_SERVER_NAME_NOT_SET detail at WARNING severity; no public error-enum change. Documents that "no DNS" does not force NULL ServerName in both header comments and docs/integrating-mbedtls.md. Closes #529 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThe PR implements decision policy S12.28 for TLS peer-hostname verification when ChangesTLS peer-hostname verification diagnostic for NULL ServerName
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
☀️ Quality Summary 🚦 build-linux-gcc: 100% successful (✔️ 1438 passed) Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result. |
Purpose
Closes #529 — a High-severity finding from the pre-0.1.0 security audit. Both TLS adapters verified the certificate chain against the CA bundle, but bound the peer identity to the certificate only when
ServerNamewas configured. WithServerName == NULLthe handshake completed against any certificate chaining to a trusted CA — a silent, MITM-class default with no diagnostic emitted.Change Description
Make the unverified-peer case observable, per the model agreed with David (NULL warns,
""opts out):ServerName == NULL→ emitSolidSyslog_Error(WARNING, …, BAD_CONFIG, *_SERVER_NAME_NOT_SET)and still connect chain-only. Preserves the closed-network / IP-pinning use case while making it observable rather than silent.ServerName == ""→ deliberate opt-out: connect chain-only, no diagnostic. The explicit "I have no name to verify against" signal.ServerName→ SNI + identity check, unchanged.Decisions worth noting beyond the diff:
*_SERVER_NAME_NOT_SETdetail atWARNINGseverity rather than adding a new enum value — the name fits the NULL case, and severity is the discriminator (ERROR = a provided name couldn't be applied → unwound; WARNING = no name → connected unverified). No public error-enum change.SSL_set1_host/mbedtls_ssl_set_hostname) is a string check against the cert and needs no DNS. An IP-pinned target can still setServerNameto the name (or IP SAN) on its cert and get full MITM protection. Documented in bothServerNameheader comments anddocs/integrating-mbedtls.md.Test Evidence
TDD, mirrored across both adapters. New tests per adapter:
OpenWarnsWhenServerNameIsNull— handler fires once,WARNING/BAD_CONFIG/*_SERVER_NAME_NOT_SET.OpenStillConnectsWhenServerNameIsNull— Open returns true, transport not closed.OpenDoesNotWarnWhenServerNameIsEmpty/OpenSkipsHostnameSetupWhenServerNameIsEmpty/OpenConnectsWhenServerNameIsEmpty— the""opt-out.A few existing handshake-failure tests now set a
ServerNameso the new NULL-warning doesn't double-fire alongside their single expected error (test-only fallout from the behaviour change).Local runs (Tier A): OpenSSL
SolidSyslogTlsStreamgroup green (135 tests) in thegcccontainer; mbedTLSSolidSyslogMbedTlsStreamgroup green (54 tests) infreertos-host. MISRA suppressions renumbered for the shifted mbedTLS 11.5 cast sites and verified against the formatted source.Areas Affected
Platform/OpenSsl/Source/SolidSyslogTlsStream.c,Platform/MbedTls/Source/SolidSyslogMbedTlsStream.cPlatform/OpenSsl/Interface/SolidSyslogTlsStream.h,Platform/MbedTls/Interface/SolidSyslogMbedTlsStream.h(ServerNamedoc contract)docs/integrating-mbedtls.md,misra_suppressions.txt, tests, DEVLOG🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation