Repository navigation
Match SNI and Host names without regard to ASCII case - #94
Merged
Merged
Conversation
RFC 6066 §3 compares host names case-insensitively, but the route table compared bytes. A client sending PR-12.app.example.com missed the pr-12.app.example.com route and reached a wildcard or the default route, a dropped route no longer failed closed for another spelling of its name, and a route configured in mixed case matched only that spelling. build_route_table now keys every route on its lowercased name, and resolve_with and load_answer lowercase the name they look up (into a stack buffer, since they run per connection), so TLS SNI, the ACME Host header, the failover ingress and peer load queries all match in any case. Metric labels, routeHealth events and outgoing load-query names keep the configured spelling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A name longer than any configured route is skipped before it is scanned or hashed, and a mixed-case name is lowercased from its first uppercase byte. The docs now say metrics keep the spelling a route was installed with, which a reload that changes only case does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An exact lookup now tries the name as given first, so the usual lowercase SNI costs what it did before, and folds into the stack buffer only when that misses. fold_case reuses the same fold, so stored keys and lookup keys cannot drift apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lowercase name that misses the exact map now skips the stack buffer entirely instead of zeroing 255 bytes first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dawsontoth
marked this pull request as ready for review
November 19, 2026 17:41
kriszyp
approved these changes
Nov 20, 2026
kriszyp
left a comment
Member
There was a problem hiding this comment.
🤖 Reviewed with Muse Wonder 1.0 · adjudicated by Codex
| } | ||
| if self.dropped_exact.contains(sni) { | ||
| return None; | ||
| let has_exact_names = !self.exact.is_empty() || !self.dropped_exact.is_empty(); |
Member
There was a problem hiding this comment.
[major] Tables without exact names still scan each incoming name for uppercase before falling back
| } | ||
| let wildcard_suffix = spec.sni.strip_prefix("*."); | ||
| let wildcard_suffix = name.strip_prefix("*."); | ||
| if wildcard_suffix.is_some_and(|suffix| !configured_wildcards.insert(suffix)) { |
Member
There was a problem hiding this comment.
[minor] A skipped case-only wildcard duplicate can hide the rejection of the wildcard that was serving
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⊙ Problem
symphony compares route names byte for byte, but host names are case-insensitive (RFC 6066 §3). A client sending
PR-12.app.example.commisses thepr-12.app.example.comroute and lands on a wildcard or the default route, and a route that failed to build stops failing closed for another spelling. Non-browser clients hit this, as on the dev Central Manager's preview proxy (central-manager#1256).💡 Solution
Hostheader, the failover ingress (the sameresolve_withlookup) and peer load queries.API.Example.comandapi.example.comare one route, under the existing duplicate rules.routeHealthand peer load queries keep the spelling a route was installed with.'suspended'still reports the client's spelling.⚖️ Alternatives
sni.rs— misses the ACMEHostheader and peer load queries.updateConfigfor every tenant on the port-set.🤔 Two exact routes that differ only in case
They now collapse last-wins with no log or
failingRoutescount, like same-spelling duplicates; before, both served. Central Manager and host-manager configure lowercase names. Should such a pair log and count as failing (#92)?🤔 Accept a few nanoseconds per connection?
A lowercase exact hit costs what it did, a wildcard hit about 12 ns more, a mixed-case hit about 50 ns, beside a TLS handshake.
🤔 Post-review delta
Post-review delta: 7 lines in
src/router.rs, not re-reviewed — the last round's suggestion (skip the fold when a table has no exact names) and a comment trim. Tests rerun.🔧 Changes
src/router.rs:fold_casefolds configured names;first_to_foldandfold_intofold a lookup into a stack buffer, bounded byMAX_ROUTE_NAME_BYTES. Wildcard suffixes compare witheq_ignore_ascii_case.load_answerretries with the folded name.resolve_withprobes the raw name first, then the folded name when the table has exact names, throughexact_match.build_route_tablefolds each configured name once, keys the whole loop on it down to insertion, and leavesspec.snifor labels and logs; theclient_authdoc follows. Unit tests.src/proxy.rs: the route-name limit reads the router's constant, so the fold buffer and the config check cannot disagree.ts/types.ts:RouteConfig.sniandSuspendedConnection.snisay how case is matched and reported.README.md: the matching rule.CLAUDE.md: the invariant and why the fold lives in the table.✅ Verification
router.rs, and Node tests sending a mixed-caseservername(proxy.spec.ts) and ACMEHost(http-listener.spec.ts) throughSymphonyProxy. All fail on main (e06db8b).cargo test255 passed, clippy and fmt clean,npm test293 passed (2 environment skips).Performance: exact lookups try the name as sent first; only a miss scans it and lowercases it into a stack buffer, never allocated. Measured with a throwaway
resolve_withmicrobenchmark: lowercase exact hit unchanged, wildcard hit +12 ns, miss +1.5 ns.Microbenchmark
Release build, 100 exact routes plus a wildcard and a default, best of 5 × 20M lookups, two interleaved runs per side, Linux arm64 container.
Test cases
folding_is_ascii_only_and_skips_names_too_long_for_a_route: non-ASCII bytes are left alone, a 255-byte name folds, a 256-byte one is skipped.sni_matching_ignores_ascii_case: mixed-case client names reach exact and wildcard routes, a mixed-case configured route matches a lowercase client and keeps its spelling as its label, a 300-byte label still matches a wildcard, andA.B.APP.EXAMPLE.COMreaches only the default.a_dropped_route_fails_closed_in_any_case: a dropped exact or wildcard route stays closed for every spelling.routes_that_differ_only_in_case_are_duplicates: exact last-wins, wildcard first-wins, the skipped wildcard counted failing.a_respelled_route_under_a_new_client_cert_policy_is_dropped: a respelled route whose new cert fails and whose client-cert policy changed is not carried forward.a_reload_that_only_changes_case_keeps_the_route: a respelled route keeps its metric identity and installed label, on a healthy reload and on one whose cert fails.load_answer("UP.Example.com")answers forup.example.com.proxy.spec.tsandhttp-listener.spec.ts:matches … regardless of ASCII case.🤖 Generated by Claude Code (Claude Opus 5.5); posted via @dawsontoth.
Related PRs: none found
Complexity: medium
Deferred findings
3568822582e342c0minor correctness —src/router.rs— Case-only exact duplicates collapse silently on upgrade with no log or failingRoutes entry — filed Decide how to report exact routes that differ only in case #92f7682bdfe0600c53minor correctness —CLAUDE.md— Mixed-version: forwarded mixed-case SNI misroutes to an older ingress's wildcard — filed Mixed-case SNI forwarded to an older peer during a rolling upgrade can reach its wildcard route #9304da97247dd082dcminor security —src/router.rs— Respelled route given to another tenant carries forward the old upstream and old-group metric identity on cert failure — filed Cert carry-forward keeps the previous tenant's upstream when a reload reassigns the route #90635e97bab7c458e7minor reliability —src/router.rs— eprintln! panics if stderr write fails — filed A failed stderr write while logging a bad route panics the reload #897ce6fa47d6346898minor reliability —src/router.rs— Case-only respell during a rolling upgrade makes an old peer answer '-' to the load query, stalling spill to it — filed Mixed-case SNI forwarded to an older peer during a rolling upgrade can reach its wildcard route #93b89333f326c4482dnit correctness —src/http_proxy.rs— ACME Host with a trailing dot is not trimmed, unlike SNI — filed ACME Host header with a trailing dot does not match its route #91Review-Coverage: authored=claude; ran=cursor-composer,codex,gemini,cursor-grok; late=cursor-grok:adjudicated; adjudicated=domain; declined=muse; rounds=5; full=3 @ 73bf1a5
Review-Attention: read ~5m (decisions: fold-in-table-not-parser, respell-keeps-installed-identity, case-only-duplicates-collapse, perf-cost) @ 73bf1a5