Skip to content

feat(policy): let inspected endpoints specify allowed transports - #6138

Draft
freeqaz-openai wants to merge 13 commits into
ai-openshell:mainfrom
freeqaz-openai:feat/allowed-transports/freeqaz-openai
Draft

freeqaz-openai wants to merge 13 commits into
ai-openshell:mainfrom
freeqaz-openai:feat/allowed-transports/freeqaz-openai

Conversation

@freeqaz-openai

@freeqaz-openai freeqaz-openai commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Choose which transport an inspected HTTP endpoint accepts, independently of which requests it allows. For example, this rule requires HTTPS on port 8443 and permits reads.

- host: api.example.com
  port: 8443
  transport: tls
  protocol: rest
  access: read-only
  enforcement: enforce

Related Issue

No linked issue.

Changes

  • transport: tls requires client TLS and verified upstream TLS. A failed handshake never falls back to plaintext.
  • transport: plaintext requires plaintext HTTP on both hops. Credentials sent to that endpoint can travel in cleartext.
  • Opaque TCP and tls: skip keep their existing behavior. The CLI shows the effective transport per port.
  • Inspected rules sharing a host and port must have a transport in common. Transport restrictions apply in audit mode too.

Release Notes

On an upgraded Supervisor, omitting transport requires TLS for inspected HTTP on port 443 and on credentialed endpoints on any port. Other inspected HTTP endpoints accept either transport. Review clients that use plaintext before upgrading Supervisors.

During a Gateway-first upgrade, older Supervisors can still receive policies that omit transport and retain their previous behavior. For the YAML network policy shown above, an upgraded Gateway refuses to deliver an explicit transport requirement to a Supervisor that lacks support. Upgrade the Gateway before authoring the field.

Testing

  • On 30229380 and its integration with 33521815, 43 tests matching the transport filter passed on each tree. These included CONNECT, direct HTTP, upstream certificate verification, and raw TCP refusal. The reduced Linux workspace omitted unused Kubernetes dependencies and retained the locked versions of the dependencies it built.
  • At 5bfddf3, eight library suites in a reduced workspace passed 3,260 tests with two ignored and one failure in connect_handler_tls_skip_route_is_not_refused. Unmodified main at e9650a0 failed the same assertion on that host.
  • The full locked workspace cannot resolve curve25519-dalek 5.1.0 from the configured registry. Full Gateway, CLI, and deployment E2E validation remain outstanding.

Checklist

  • Conventional commit and DCO sign-off
  • Policy reference and migration guidance
  • Full workspace and integration checks

Separate connection transport from request protocol. Resolve TLS defaults per destination port and credential scope, enforce them for CONNECT and forward HTTP, and negotiate supervisor support before delivering the policy.

Signed-off-by: Free Wortley <freeqaz@openai.com>
…elivery

Signed-off-by: Free Wortley <freeqaz@openai.com>
@sjenning

sjenning commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

This part of the rule schema is kinda clunky imho.

We changed tls in #544 but maybe not for the better. It was more clear/explicit what the field did in the past with terminate or passthrough. With skip (and nil) being the values now, what the field does is more ambiguous. Someone could mistake it for "don't verify TLS certs" or something.

There are two questions

  • Terminate or Passthrough
  • What scheme should be allowed, https or http

We have a protocol field, but that is the L7 protocol (websocket, graphql, etc)

Having thought about it for a grand total of 5 minutes, I think I prefer a scheme field with https (default) and http as values. This doesn't allow both schemes in a single rule, but I think that is desirable. If someone wants to pass http, it should be explicit in the rule set so their shame intent is obvious.

scheme would mutually exclusive with protocol: tcp or tls: skip.

@johntmyers @drew would be interested in your thoughts

@EmilienM EmilienM 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.

Another iteration needed: 2 blocking, 9 major (inline, 2 below)

The transport-agreement check retroactively rejects stored policies that were valid before and disagrees with the Cedar engine on the same shape, and the TLS-by-default change fails closed every 443 endpoint during a gateway-first upgrade with no ordering story.

Outside the diff:

  • Blocking: the PR fails the PR Issue Acceptance check: community PRs must link an issue with state:accepted via Closes #NNN, and the body says "No linked issue".
  • Major: crates/openshell-policy-cedar-runtime/src/cedar_provider_rules.rs:163, the load-time ambiguity check compares provider endpoints only against each other, so a provider transport list that disagrees with a Cedar-derived default composes cleanly and then errors every connection at runtime.
How this was reviewed
  • Commit 1b34173, round 1
  • Deep review, because the change touches gateway policy delivery, supervisor proxy transport enforcement, and the public policy schema
  • Passes: architecture, performance, security, scalability, rust, kubernetes, kernel, supply-chain, then correctness, then a defensive review
  • Independent skeptics checked each candidate finding (2 for the architecture candidates, 3 with a reproducer for the rest); 7 of 9 held up
  • Repo rules read from main: AGENTS.md, CONTRIBUTING.md, docs/CONTRIBUTING.mdx
  • Not covered: e2e and the full workspace suite (Branch Checks and Helm Lint await maintainer approval; the locked local build is blocked by a missing registry artifact, per the PR description)

let mut conflicts = connection_conflicts(left.endpoint, right.endpoint);
// Transport is fixed before the request path is known. A bare L4
// grant contributes no HTTP settings when an inspected rule matches.
for &port in &overlapping_ports {

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.

Blocking: The transport-agreement check runs before the path-overlap gate, so two inspected endpoints that share only a host and port now fail the whole config when their effective transports differ (credentialed defaults to TLS, a plain sibling to both). Stored policies with this shape were valid before and now get a configuration error on every delivery, while the Cedar runtime handles the same shape by tightening everything to TLS (cedar_only/routes.rs:226). Either resolve the overlap to the stricter transport at compose time as Cedar does, or scope the conflict to endpoints that share request selectors.

true
}

fn requires_endpoint_transport_support(policy: &ProtoSandboxPolicy) -> Result<bool, Status> {

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.

Major: This re-derives the supervisor's transport-enforcement predicate with a parallel heuristic that will drift from the runtime's view. Compute "requires transport enforcement" once next to the credential-provenance stamping and consume it here.

return Ok(Some(transports));
}
Ok(protocol.filter(|p| p.is_http()).map(|_| {
if port == 443 || credentialed {

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.

Major: This flips every existing inspected HTTP endpoint on 443 or with credentials to TLS-only with no opt-in, and ties them all to a synchronized gateway and supervisor upgrade through one capability bit. If the tightening stands, the docs need to say the default alone triggers it.

if policy.is_cedar() {
// Cedar derives HTTP inspection from its source, including on a
// provider endpoint whose own protocol need not be HTTP.
let inspections = openshell_policy::cedar_http_endpoint_selectors(policy.cedar_source())

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.

Major: A full CedarEngine is built from the policy source on every capability check, and this runs on every config poll. Cache the result keyed by the deterministic policy hash the snapshot build already computes.

}
if let Err(error) = validate_uninspected_credentialed_endpoints(effective_policy) {
configuration_error = bounded_configuration_diagnostic(error.message());
} else if let Err(error) = validate_endpoint_ambiguities(effective_policy) {

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.

Major: The ambiguity scan is quadratic in endpoints and now runs on every snapshot build (poll, session bootstrap, token refresh); it only ran on the mutation path before. Memoize it keyed by policy hash and provider revisions, or keep it on the mutation path.

or request signing. Other inspected HTTP endpoints accept both transports.
The default applies separately to each port in `ports`.

Upgrade the gateway and supervisors before relying on this field. An older

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.

Major: In a gateway-first rolling upgrade, every sandbox with an inspected HTTP endpoint on 443 (the default shape, no allowed_transports authored) gets a fail-closed unadmitted config until its supervisor upgrades. "Before relying on this field" reads as opt-in, but the default alone triggers the refusal, and the chart rolls gateway and supervisor with no ordering. State the required order and confirm the mixed-version window is intended.

.collect(),
path: endpoint.path.clone(),
tls: TlsSetting::from_proto(endpoint.tls),
allowed_transports: endpoint.allowed_transports.clone(),

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.

Major: provider_config copies the provider's allowed_transports but leaves the protocol unset on routes Cedar doesn't inspect, so allowed_transports_for_port rejects the list and query_allowed_transports drops every permitted connection to that authority, with no 403 and no load-time diagnostic. Don't carry an explicit list into a config with no covering inspection.

return Ok(());
}

if query_allowed_transports(&decision)?.is_some() {

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.

Major: This denies every direct TCP connection to an inspected HTTP endpoint (query_allowed_transports is Some for all of them, default-both included), so transparent-mode sandboxes that bypass the proxy lose those endpoints outright with no way to allow them back; they were raw-relayed before. If the fail-close is intended, document it and add a test.

// the relay for a connection with an inspected HTTP transport policy.
route
.configs
.retain(|snapshot| snapshot.config.protocol != crate::l7::L7Protocol::Sql);

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.

Major: When any sibling at a host:port has transport policy, this drops the SQL config from the route and the transparent adapter denies the same traffic, yet admission passes silently because a sql endpoint never yields transports. Reject the sql+http shared-port combination at admission, or keep the SQL config.

freeqaz and others added 11 commits December 2, 2026 03:33
…suite

Signed-off-by: freeqaz <me@freeqaz.com>
…http shared ports

Use transport-set intersection across overlapping host:port endpoints so a credentialed path (default TLS) tightens plain siblings to TLS instead of retroactively rejecting previously valid stored policies, while still rejecting disjoint TLS vs plaintext combinations.

Also reject sql+HTTP combinations sharing a host and port at admission, add unit coverage for raw transparent TCP fail-close on inspected HTTP endpoints, and fix pre-dial stale-policy and missing-TLS telemetry in the CONNECT handler.

Signed-off-by: freeqaz <me@freeqaz.com>
… check load-time conflicts

Apply provider allowed_transports only when Cedar inspects the route so uninspected L4 or unmatched provider routes never fail allowed_transports_for_port and drop permitted connections at runtime.

Add a shared Cedar/provider transport analyzer in openshell-policy-cedar-adapter and run it during LoadedPolicy::from_proto so provider transport lists that are disjoint from Cedar-derived defaults fail at load time instead of silently composing and erroring every connection. Also intersect authority transports before tightening sibling routes so an explicit plaintext credentialed route on a non-443 port does not stamp TLS onto empty siblings.

Signed-off-by: freeqaz <me@freeqaz.com>
…dmission errors

- Memoize effective-policy ambiguity and transport-capability analysis per
  canonical policy_hash in ServerState so polling and stream delivery do not
  repeatedly rebuild Cedar engines or rescan endpoint pairs.
- Validate Cedar + provider transport conflicts in both effective-policy
  write validation (including operator merge writes) and snapshot delivery.
- Preserve existing configuration_error diagnostics on unadmitted snapshots
  instead of overwriting them with ENDPOINT_TRANSPORT_SUPPORT_REQUIRED for
  legacy supervisors.
- Remove the unused cedar_http_endpoint_selectors adapter helper, update
  existing server capability test fixtures, and remove unused_qualifications
  warnings.

Signed-off-by: freeqaz <me@freeqaz.com>
…sparent TCP fail-close

Signed-off-by: freeqaz <me@freeqaz.com>
… tests

- Replace BTreeMap<String, IgnoredAny> in deserialize_credential_binding with
  a zero-allocation serde Visitor to satisfy clippy::zero_sized_map_values.
- Clean up redundant_clone, single_match_else, match_same_arms,
  useless_let_if_seq, redundant_pub_crate, needless_raw_string_hashes, and
  iter_on_single_items lints across modified crates and tests.

Signed-off-by: freeqaz <me@freeqaz.com>
…rt field

- Replace repeated NetworkTransport allowed_transports with a single scalar
  NetworkTransport transport field (tls | plaintext) on NetworkEndpoint in
  proto, YAML/JSON schema, provider profiles, Rego/OPA data, Cedar runtime,
  merge/ambiguity validators, CLI provider details, prover, e2e, and test
  suites.
- Preserve existing defaults when omitted: port 443 and credentialed
  inspected HTTP endpoints require TLS; other uncredentialed inspected HTTP
  endpoints continue to accept either TLS or plaintext.
- Eliminate dual-transport list authoring on a single rule (making plaintext
  opt-in explicit and avoiding https/wss naming mismatch on WebSocket and
  future non-HTTP protocols).
- Update reviewed storage_proto schema SHA-256 fingerprints.

Signed-off-by: freeqaz <me@freeqaz.com>
…t is explicit

- Gate POLICY_ENDPOINT_TRANSPORTS_V1 only on endpoints that explicitly set
  transport (tls or plaintext) in YAML/proto or Cedar provider rules.
- Prevents gateway-first rolling upgrades (such as Helm/Docker deployments
  with long-lived sandboxes) from fail-closing existing sandboxes whose
  policies omit transport on port 443 or credentialed endpoints, while newly
  created/upgraded supervisors still enforce TLS by default and explicit
  transport policies still fail closed on incompatible supervisors.

Signed-off-by: freeqaz <me@freeqaz.com>
…ility gating

Signed-off-by: freeqaz <me@freeqaz.com>
…rmance

Signed-off-by: Free Wortley <freeqaz@openai.com>
Account for scoped endpoint settings when checking the transport shared by Cedar and provider routes. Use the same host matching at admission and runtime, and keep compatible provider paths available.

Signed-off-by: Free Wortley <freeqaz@openai.com>

This branch has not been deployed

No deployments
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.

4 participants