fix(permissions): match network rules against the resource host - #1958
Open
Scorpion197 wants to merge 1 commit into
Open
fix(permissions): match network rules against the resource host#1958Scorpion197 wants to merge 1 commit into
Scorpion197 wants to merge 1 commit into
Conversation
Network rule patterns written in the documented host form (`api.example.com`, `api.example.com:443`, `*.example.com`, `*`) never matched, because the kernel checks the URI form of the resource (`tcp://host:port`, `dns://host`) and a single `*` cannot cross the `//`. A documented allowlist denied every host and a documented blocklist permitted every host. Scheme-less `network` patterns are now matched against the host subject of the resource: the bare host, and `host:port` when a port is present. Patterns that carry a scheme keep matching the full URI. Resources that do not parse as `scheme://subject` are only matched by full-URI patterns, so unexpected shapes fail closed. Other pattern scopes are untouched. Existing tests that fed bare `host:port` resources into the network evaluator now use the `tcp://` form the kernel actually produces.
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.
Fixes #1884.
api.example.com,api.example.com:443,*.example.com,*) never matched, because the kernel checks the URI form of the resource (tcp://host:port,dns://host) and a single*cannot cross the//. A documented allowlist therefore denied every host, and a documented blocklist permitted every host.networkpatterns are now matched against the host subject of the resource: the bare host, andhost:portwhen a port is present. Patterns that carry a scheme (tcp://...,dns://...) keep matching the full URI, so existing policies written in that form are unchanged.scheme://subjectare only matched by full-URI patterns, so unexpected resource shapes fail closed. Other pattern scopes are untouched.crates/native-sidecar-core/tests/network_permissions.rscovering the matrix from the report in both directions, the URI form, IPv6 literals, last-rule-wins, the post-resolution evaluator, and the fail-closed cases. Existing tests that fed barehost:portresources into the network evaluator now use thetcp://form the kernel actually produces.permissions.mdx. The shippedallow-one-hostexample is unchanged and now works.This is the matcher alternative offered in #1910, which corrects the docs to the URI form instead. The TypeScript merge-over-default behavior described in the second half of #1884 is a separate layer and is not addressed here.