Repository navigation
fix(policy,network): separate named and hostless destination classes — mixed scopes validate and match correctly #5198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eab3eec
7ecde29
82b6260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,15 +124,44 @@ endpoint_allowed(policy, network) if { | |
| endpoint.ports[_] == network.port | ||
| } | ||
|
|
||
| # Endpoint matching: hostless with allowed_ips — match any host on port. | ||
| # When an endpoint has allowed_ips but no host, it matches any hostname on the | ||
| # given port. The actual IP validation happens in Rust post-DNS-resolution. | ||
| # Endpoint matching: hostless with allowed_ips — raw-IP destinations only. | ||
| # The allowed_ips list is the destination selector for these endpoints, so | ||
| # they authorize connections addressed by IP literal on the given port. | ||
| # DNS-mediated hostname connections are governed by their named endpoints; | ||
| # the range check itself still happens in Rust after the pin. Raw-IPv6 | ||
| # destinations carry colons; a hostname always carries letters, so the | ||
| # literal-shaped check cannot match a mediated name. | ||
| endpoint_allowed(policy, network) if { | ||
| some endpoint | ||
| endpoint := policy.endpoints[_] | ||
| object.get(endpoint, "host", "") == "" | ||
| count(object.get(endpoint, "allowed_ips", [])) > 0 | ||
| endpoint.ports[_] == network.port | ||
| raw_ip_destination(network.host) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For DNS-named private services, the installable policy-generation skill still recommends an AGENTS.md reference: AGENTS.md:L225-L225 Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| raw_ip_destination(host) if { | ||
| parts := split(host, ".") | ||
| count(parts) == 4 | ||
| every part in parts { | ||
| ipv4_label(part) | ||
| } | ||
| } | ||
|
|
||
| raw_ip_destination(host) if { | ||
| contains(host, ":") | ||
| } | ||
|
|
||
| ipv4_label(s) if { | ||
| glob.match("[0-9]", [], s) | ||
| } | ||
|
|
||
| ipv4_label(s) if { | ||
| glob.match("[0-9][0-9]", [], s) | ||
| } | ||
|
|
||
| ipv4_label(s) if { | ||
| glob.match("[0-9][0-9][0-9]", [], s) | ||
| } | ||
|
|
||
| # Binary matching can be relaxed by trusted runtime configuration. In that | ||
|
|
@@ -1067,11 +1096,15 @@ endpoint_matches_request(ep, network) if { | |
| ep.ports[_] == network.port | ||
| } | ||
|
|
||
| # Hostless endpoint with allowed_ips: match on port only. | ||
| # Hostless endpoint with allowed_ips: raw-IP destinations on port only. | ||
| # Same destination-class separation as the admission matcher: DNS-mediated | ||
| # names are governed by named endpoints, so a hostless CIDR endpoint never | ||
| # constrains a hostname's pinned resolutions. | ||
| endpoint_matches_request(ep, network) if { | ||
| object.get(ep, "host", "") == "" | ||
| count(object.get(ep, "allowed_ips", [])) > 0 | ||
| ep.ports[_] == network.port | ||
| raw_ip_destination(network.host) | ||
| } | ||
|
|
||
| endpoint_matches_l7_request(ep, network, request) if { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For non-TCP proxy endpoints, a nonempty
hostcan still be an IP literal, so an endpoint such ashost: 10.10.0.5is not disjoint from a hostless endpoint on the same port. Both the exact-host and hostless branches ofendpoint_matches_requestmatch that raw-IP request, but this new shortcut permits them to disagree ontls,allowed_ips, and L7 metadata. The proxy'squery_tls_modeandquery_allowed_ipsstill take the first matching config, so a previously rejected ambiguous policy can now activate and apply the wrong TLS mode or deny an explicitly allowed IP using the other endpoint's CIDR. Preserve the overlap checks for host selectors that can match IP literals.Useful? React with 👍 / 👎.