Skip to content

fix(proxy): normalize trailing-dot CONNECT hosts before policy evaluation - #2248

Open
letv1nnn wants to merge 2 commits into
NVIDIA:mainfrom
letv1nnn:2201-normalize-trailing-dot-host
Open

fix(proxy): normalize trailing-dot CONNECT hosts before policy evaluation#2248
letv1nnn wants to merge 2 commits into
NVIDIA:mainfrom
letv1nnn:2201-normalize-trailing-dot-host

Conversation

@letv1nnn

Copy link
Copy Markdown
Contributor

Summary

Fixes inconsistent handling of trailing-dot hostnames (e.g. api.example.com.) in the sandbox supervisor's CONNECT proxy. Such hosts are valid RFC 1034 FQDNs used in Kubernetes ndots:5 environments to bypass search-domain expansion, but were treated as distinct from their undotted equivalents across policy evaluation, middleware selection, and credential matching.

Related Issue

#2201

Changes

  • Strip one trailing dot from CONNECT host before policy checks, normalize_connect_host(raw_host: &str) -> &str {...}
  • DNS resolvers still get the original dotted form (preserves ndots:5 bypass)
  • Unit tests for the normalization helper

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

@copy-pr-bot

copy-pr-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@TaylorMutch

Copy link
Copy Markdown
Collaborator

/ok to test 8384df5

@letv1nnn
letv1nnn force-pushed the 2201-normalize-trailing-dot-host branch from 8384df5 to 1544036 Compare July 13, 2026 19:20

@r3v5 r3v5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR: #2248
Author: letv1nnn (Artem Lytvyn)
Branch: 2201-normalize-trailing-dot-host -> main

Overview

Strips trailing dot from FQDN CONNECT hosts (e.g. api.example.com. → api.example.com) before policy evaluation, middleware selection, and credential matching. Fixes mismatches in K8s ndots:5 environments where dotted and undotted forms were treated as distinct hosts.

Key Design Decisions

  • Normalize once, early (proxy.rs:613): Single normalize_connect_host() call right after parse_target(), so all downstream policy logic sees the clean hostname.
  • Selective raw_host pass-through (proxy.rs:784, proxy.rs:837): resolve_and_check_trusted_gateway and resolve_and_check_allowed_ips still receive raw_host to preserve the ndots:5 DNS bypass
    behavior.

Notable Code

crates/openshell-supervisor-network/src/proxy.rs:4546

fn normalize_connect_host(raw_host: &str) -> &str {
    raw_host.strip_suffix('.').unwrap_or(raw_host)
}

Clean, zero-allocation — returns a sub-slice. Only strips one dot per RFC 1034.

Comment thread crates/openshell-supervisor-network/src/proxy.rs Outdated
Comment thread crates/openshell-supervisor-network/src/proxy.rs Outdated
@letv1nnn
letv1nnn force-pushed the 2201-normalize-trailing-dot-host branch from 1544036 to 0ae8014 Compare July 14, 2026 13:18
@letv1nnn
letv1nnn requested a review from r3v5 July 14, 2026 13:20

@r3v5 r3v5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good from my side!

@johntmyers

Copy link
Copy Markdown
Collaborator

/ok to test 0ae8014

@johntmyers johntmyers added the test:e2e Requires end-to-end coverage label Jul 14, 2026
@github-actions

Copy link
Copy Markdown

Label test:e2e applied for 0ae8014. Open the existing run and click Re-run all jobs to execute with the label set. The run will execute the standard E2E suite after building the required gateway and supervisor images once. The matching required CI gate status on this PR will flip green automatically once the run finishes.

@johntmyers johntmyers self-assigned this Jul 14, 2026
@johntmyers

Copy link
Copy Markdown
Collaborator

Hosts need to be normalized in the forward-proxy path as well. Currently, non-CONNECT requests are dispatched prior to the normalization. I think if we duplicate the normalization for now that's ok. We're going to refactor the proxy and align CONNECT and non-CONNECT paths under the same code. But to merge this as-is we need to make sure we normalize for both pathways.

@johntmyers

Copy link
Copy Markdown
Collaborator

Also need to normalize hostnames for hosts file (/etc/hosts) lookups and retain the raw_host for DNS.

@johntmyers johntmyers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@letv1nnn
letv1nnn force-pushed the 2201-normalize-trailing-dot-host branch from 0ae8014 to 6e09c21 Compare July 14, 2026 16:17
@letv1nnn
letv1nnn requested a review from johntmyers July 14, 2026 16:29
@github-actions

Copy link
Copy Markdown

This pull request has had no activity for 14 days and is now marked stale. It may be closed in 7 days if there is no further activity.

@github-actions github-actions Bot added the state:stale Inactive item at risk of automatic closure. label Jul 29, 2026
@johntmyers
johntmyers force-pushed the 2201-normalize-trailing-dot-host branch from 6e09c21 to fe03fb4 Compare August 11, 2026 18:59
@letv1nnn

Copy link
Copy Markdown
Contributor Author

hey @johntmyers, thanks for picking this up. Anything left from my side, or ready to merge?

@krishicks

Copy link
Copy Markdown
Collaborator

/ok to test fe03fb4

…tion

Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
@letv1nnn
letv1nnn force-pushed the 2201-normalize-trailing-dot-host branch from fe03fb4 to 329dc44 Compare August 18, 2026 14:49
@letv1nnn
letv1nnn requested a review from sjenning as a code owner August 18, 2026 14:49

@johntmyers johntmyers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Thanks @johntmyers. I checked the two paths you called out: the current patch now normalizes forward-proxy policy inputs and hosts-file lookup keys while retaining the dotted spelling for local DNS. One supported DNS sink still loses that spelling when CONNECT-by-hostname is enabled for an upstream proxy.

Action required: @letv1nnn, preserve raw_host for the upstream proxy's hostname CONNECT target and add the focused request-line regression test described inline.

Blocking findings:

  • GATOR-329dc440-01: the upstream-proxy hostname mode receives the normalized host instead of the absolute FQDN.

Carried findings:

  • None
Gator metadata
  • Validation: Project-valid localized fix for maintainer-authored issue #2201; verified maintainer feedback defines the forward-proxy and hosts-file requirements.
  • Docs: Not needed because this restores existing valid-FQDN behavior without changing commands, configuration, policy syntax, or documented workflows.
  • Checks: DCO is green; Branch Checks, Helm Lint, and E2E are pending for the current head.
  • E2E: test:e2e is applied; dispatch is deferred until the blocking code finding is resolved.
  • Head SHA: 329dc440656c07943d70e90c5f95e87060c316dd
  • Base SHA: dc374e88784a7e4a7366abd1fdb56c969efe6769
  • Merge base SHA: dc374e88784a7e4a7366abd1fdb56c969efe6769
  • Patch ID: ab45a6fddae8af48ecab38756c6f6c586af02da5
  • Gator payload: 7
  • Review mode: initial
  • Previous reviewed SHA: none
  • Review budget exhausted: no
  • Maintainer decision required: no
  • Next state: gator:in-review

Comment thread crates/openshell-supervisor-network/src/proxy.rs
@johntmyers johntmyers added the gator:in-review Gator is reviewing or awaiting PR review feedback label Aug 23, 2026
…host and add regression test

Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
@letv1nnn
letv1nnn requested a review from johntmyers August 23, 2026 21:17
@johntmyers

Copy link
Copy Markdown
Collaborator

/ok to test 6f0ad2f

@johntmyers johntmyers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

The latest author commit resolves GATOR-329dc440-01: the normalized hostname remains in policy and routing decisions, while the raw dotted FQDN now reaches the upstream proxy's hostname CONNECT target. The focused request-line regression test covers the required behavior, and no blocking findings remain in the follow-up delta.

Blocking findings:

  • No blocking findings remain

Carried findings:

  • None; GATOR-329dc440-01 is resolved
Gator metadata
  • Validation: Project-valid localized fix for maintainer-authored issue #2201; the latest delta addresses the prior supported-path obligation.
  • Docs: Not needed because this restores existing valid-FQDN behavior without changing commands, configuration, policy syntax, or documented workflows.
  • Checks: DCO is green; Branch Checks, Helm Lint, and E2E are pending for the current head.
  • E2E: test:e2e is applied and /ok to test 6f0ad2f6acdf15c261073cb2e82a50f08c3b0569 was posted; current-head workflow dispatch is awaiting confirmation.
  • Head SHA: 6f0ad2f6acdf15c261073cb2e82a50f08c3b0569
  • Base SHA: dc374e88784a7e4a7366abd1fdb56c969efe6769
  • Merge base SHA: dc374e88784a7e4a7366abd1fdb56c969efe6769
  • Patch ID: 91839f2e035313dea507bc7591d603fd3fdd2452
  • Gator payload: 7
  • Review mode: follow_up
  • Previous reviewed SHA: 329dc440656c07943d70e90c5f95e87060c316dd
  • Review budget exhausted: no
  • Maintainer decision required: no
  • Next state: gator:in-review pending confirmed current-head test dispatch

@johntmyers johntmyers added gator:watch-pipeline Gator is monitoring PR CI/CD status gator:approval-needed Gator completed review; maintainer approval needed and removed gator:in-review Gator is reviewing or awaiting PR review feedback gator:watch-pipeline Gator is monitoring PR CI/CD status labels Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:approval-needed Gator completed review; maintainer approval needed state:stale Inactive item at risk of automatic closure. test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants