Skip to content

fix(permissions): match network rules against the resource host - #1958

Open
Scorpion197 wants to merge 1 commit into
rivet-dev:mainfrom
Scorpion197:fix/network-permission-host-patterns
Open

fix(permissions): match network rules against the resource host#1958
Scorpion197 wants to merge 1 commit into
rivet-dev:mainfrom
Scorpion197:fix/network-permission-host-patterns

Conversation

@Scorpion197

Copy link
Copy Markdown

Fixes #1884.

  • 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 therefore 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 (tcp://..., dns://...) keep matching the full URI, so existing policies written in that form are unchanged.
  • Resources that do not parse as scheme://subject are only matched by full-URI patterns, so unexpected resource shapes fail closed. Other pattern scopes are untouched.
  • Adds crates/native-sidecar-core/tests/network_permissions.rs covering 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 bare host:port resources into the network evaluator now use the tcp:// form the kernel actually produces.
  • Documents the host and URI pattern forms in permissions.mdx. The shipped allow-one-host example 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Network permission rule sets never match; explicit permission objects also bypass the documented merge-over-default

1 participant