feat(sandbox): add --permissive flag for audit2allow-style policy discovery#1856
feat(sandbox): add --permissive flag for audit2allow-style policy discovery#1856russellb wants to merge 1 commit into
Conversation
…covery Add permissive mode to sandboxes, enabling a single-pass onboarding workflow for discovering what network policy a workload needs. When `openshell sandbox create --permissive` is used, the proxy logs but does not enforce network policy denials at both L4 (TCP connect) and L7 (HTTP method/path) layers. Denied connections succeed with full credential injection, and each denial feeds the existing DenialAggregator → mechanistic mapper → draft proposal pipeline. Users review all discovered endpoints at once with `openshell policy draft get`, approve them, and export the learned policy. Filesystem (Landlock) restrictions are skipped in permissive mode. Seccomp, process identity, and SSRF guards remain enforced. Permissive mode is threaded through all enforcement paths: CONNECT L4, forward-proxy L4, single-route and multi-route L7 relay, forward-proxy L7 path selection, and WebSocket/GraphQL message-level inspection. The permissive flag flows from SandboxSpec (proto) through the gateway's GetSandboxConfigResponse to the sandbox supervisor, which sets it on ProxyPolicy and L7EvalContext. Closes NVIDIA#1839 Signed-off-by: Russell Bryant <rbryant@redhat.com>
5cb3448 to
69ed2d0
Compare
|
We've had a lot of feedback and requests for something like this. My overall question is if we need to think about this more of an e2e system feature that doesn't require users to jump back in with the CLI to auto-approve everything and export a profile. My concern is that I don't have a concrete answer to the product experience here but just don't want the spirit of this turning into a way to launch sandboxes that are wide-open indefinitely. Some thoughts:
Curious on thoughts from @zredlined on the right UX we want to have. My gut says we want some system-owned experience here vs leaving it to users to "do the right thing." I could also imagine enterprises may not want this capability at all so also am curious if this should be a setting in the gateway to even have something like this available to users. |
|
Thanks for the UX discussion! I'm happy to completely redo this for whatever experience we can land on (or don't). I just found it easiest to start with something that works, so we have something to look at and pick on. I agree that "just run in permissive" is not ideal, but that made me think about a possible user view. What if someone thinks, "I value the credential management in OpenShell, but I'm not interested in network access control, because I already handle that elsewhere." Someone in that frame of mind could find OpenShell's UX too restrictive and not adopt it at all. This isn't the persona I had in mind at all when doing this, but it's a thought. I like these ideas: enforcing a configurable maximum timeout, allowing this feature to be turned off completely. I know I intended to mark pending rules as "permissive generated," but I think I forgot to add it in the end. |
Summary
Add permissive mode to sandboxes, enabling a single-pass onboarding workflow for discovering what network policy a workload needs. Instead of iteratively hitting denials, approving proposals one at a time, and rerunning, users create a permissive sandbox where the agent runs to completion. All would-be-denied connections succeed and generate draft proposals. Users review and approve the full set at once, then export the learned policy.
Related Issue
Closes #1839
Changes
proto/openshell.proto,proto/sandbox.proto: Addbool permissivetoSandboxSpecandGetSandboxConfigResponsecrates/openshell-cli/src/main.rs,run.rs: Add--permissiveflag tosandbox createwith startup hint when no L7 protocol endpoints are declaredcrates/openshell-server/src/grpc/policy.rs: Returnpermissivefrom stored sandbox spec in config responsecrates/openshell-sandbox/src/lib.rs,grpc_client.rs,policy.rs: Read flag from config response, thread to proxy and Landlock paths viaProxyPolicy.permissivecrates/openshell-sandbox/src/proxy.rs: Log-but-allow on L4 deny (CONNECT and forward-proxy), L7 path-selection deny, and forward-proxy L7 enforcement. EmitDenialEventwithAllowed/LoggedOCSF disposition. Usequery_l7_route_snapshot_with_permissiveto query endpoint configs for denied decisions so protocol hints drive L7 learning.crates/openshell-sandbox/src/l7/relay.rs: Addpermissiveanddenial_txtoL7EvalContext. Honor permissive in single-route and multi-route enforcement decisions. EmitDenialEventwithl7_method/l7_pathfor denied requests.crates/openshell-sandbox/src/l7/websocket.rs: Honor permissive in WebSocket text-message and GraphQL-over-WebSocket enforcement, emittingDenialEventinstead of returning errors.crates/openshell-sandbox/src/sandbox/linux/mod.rs: Addskip_landlock()toPreparedSandboxcrates/openshell-sandbox/src/process.rs,ssh.rs: Callskip_landlock()when permissive. Seccomp always enforced.docs/sandboxes/policies.mdx: Add "Discover Policy with Permissive Mode" section with quick start examplee2e/python/test_sandbox_policy.py: 8 e2e tests covering L4 CONNECT, forward-proxy, L7 enforcement bypass, SSRF guardrails, L4 proposal generation, L7 proposal generation with method/path assertions, and no false proposals for allowed trafficTesting
mise run pre-commitpassesopenshell sandbox create --permissive, curl public APIs, verify proposals viaopenshell rule getChecklist