fix(net): normalize trailing-dot SNI in secret-injection matcher#771
Draft
G4614 wants to merge 1 commit into
Draft
fix(net): normalize trailing-dot SNI in secret-injection matcher#771G4614 wants to merge 1 commit into
G4614 wants to merge 1 commit into
Conversation
A guest-supplied SNI carrying the FQDN trailing dot (e.g. `api.openai.com.`) is admitted by the allow_net filter, which strips the dot (tcp_filter.go MatchesHostname), but the secret-injection matcher lowercased only and did not trim it. The result was an inconsistency: the connection was allowed, MITM was attempted, yet `SecretHostMatcher.Matches` returned false, so the `<BOXLITE_SECRET:...>` placeholder was forwarded upstream unsubstituted instead of being replaced (or fail-closed). Add a shared `normalizeHost` (lowercase + TrimSuffix ".") and apply it in both `Matches` and `SecretsForHost`, matching how the allowlist normalizes hostnames. Behavior is unchanged for SNIs without a trailing dot. Two-sided test: TestSecretHostMatcher_TrailingDot fails on every assertion with the production change reverted (placeholder host not matched), passes with it applied. Audit finding boxlite-ai#14 (low). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
boxlite security fixes seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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.
Summary
Source-level security audit fix. A guest-supplied SNI carrying the FQDN trailing
dot (e.g.
api.openai.com.) is admitted by theallow_netfilter (whichstrips the dot) but the secret-injection matcher lowercased only and did not trim
it — so the connection was allowed and MITM'd, yet the
<BOXLITE_SECRET:...>placeholder was forwarded upstream unsubstituted instead of replaced.
Fix
Add a shared
normalizeHost(lowercase +TrimSuffix(".")) and apply it inboth
MatchesandSecretsForHost, matching how the allowlist normalizeshostnames. Behavior is unchanged for SNIs without a trailing dot.
Test (two-sided)
TestSecretHostMatcher_TrailingDotfails on every assertion with the changereverted (trailing-dot host not matched) and passes with it applied.
Audit finding #14 (low). Note: finding #13 (allow_net wildcard depth) was
intentionally not changed — deep-subdomain matching is documented existing
behavior (TestTCPFilter_Wildcard) and never escapes the allowed parent domain.
🤖 Generated with Claude Code