fix(sandbox): validate always-blocked IPs at load time, enrich denial logs, and filter un-fixable proposals#815
Open
johntmyers wants to merge 1 commit intomainfrom
Open
Conversation
… logs, and filter un-fixable proposals (#814) Policies with allowed_ips entries targeting loopback, link-local, or unspecified ranges now fail at connection time instead of being silently blocked at runtime. The shorthand log format for DENIED events includes a [reason:...] suffix so operators can distinguish 'allowlist miss' from 'structurally un-allowable'. The mechanistic mapper skips proposals for always-blocked destinations, preventing the infinite TUI notification loop. The gateway validates proposed rules on approval as defense-in-depth. - Extract shared IP helpers (is_always_blocked_ip, is_always_blocked_net, is_internal_ip) to openshell_core::net - Reject always-blocked entries in parse_allowed_ips with hard error - Skip implicit allowed_ips synthesis for always-blocked literal IP hosts - Add status_detail to HttpActivityBuilder for denial reason propagation - Enrich NET and HTTP shorthand with [reason:...] for DENIED events - Add engine: tag to HTTP shorthand (consistency with NET shorthand) - Filter always-blocked proposals in mechanistic mapper generate_proposals - Add validate_rule_not_always_blocked server-side defense-in-depth - Update architecture docs, published docs, and E2E test assertions
|
🌿 Preview your docs: https://nvidia-preview-pr-815.docs.buildwithfern.com/openshell |
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.
What changes for users
Policies with always-blocked
allowed_ipsnow fail to load. If your policy YAML containsallowed_ipsentries targeting loopback (127.0.0.0/8), link-local (169.254.0.0/16), unspecified (0.0.0.0), or0.0.0.0/0, the proxy rejects them with a clear error naming the offending entry and citing SSRF hardening. Previously these were silently accepted but never actually worked.Literal IP hosts that are always-blocked are also caught. A policy with
host: '127.0.0.1'no longer silently synthesizes anallowed_ipsentry that would be blocked at runtime.Denial logs now explain why traffic was blocked. The shorthand log format for DENIED events includes a
[reason:...]suffix:Previously "allowlist miss" and "structurally un-allowable" denials looked identical in
openshell logs.HTTP shorthand now shows
[engine:]tag. Consistent with NET shorthand — was previously omitted.The TUI stops showing un-fixable proposals. The policy advisor no longer generates proposals for always-blocked destinations, ending the infinite 10-second notification loop.
Server rejects always-blocked entries on approval. Defense-in-depth: if a draft chunk with always-blocked
allowed_ipssomehow reaches the gateway,ApproveDraftChunkreturnsINVALID_ARGUMENTinstead of silently merging an un-enforceable rule.Related Issue
Closes #814
Changes
Shared helpers (
openshell-core)crates/openshell-core/src/net.rswithis_always_blocked_ip,is_always_blocked_net,is_internal_ip— eliminates duplication between proxy, mapper, and serverSandbox proxy (
openshell-sandbox)parse_allowed_ipsrejects entries overlapping always-blocked ranges (hard error, not warning)implicit_allowed_ips_for_ip_hostreturns empty for always-blocked literal IPs.status_detail(&reason)onHttpActivityBuilderOCSF logging (
openshell-ocsf)HttpActivityBuildergainsstatus_detailfield and builder method[reason:{status_detail}]for DENIED events (truncated at 80 chars)[engine:]tag in[policy:X engine:Y](was[policy:X]only)Mechanistic mapper (
openshell-sandbox)generate_proposalsskips always-blocked destinations viais_always_blocked_destinationresolve_allowed_ips_if_privatefilters always-blocked IPs from resolved resultsGateway server (
openshell-server)validate_rule_not_always_blockedcalled inmerge_chunk_into_policy— rejects literal always-blocked hosts,localhost, and always-blockedallowed_ipsentries withINVALID_ARGUMENTDocumentation
architecture/security-policy.md— SSRF validation flow, load-time rejection, server-side defensearchitecture/policy-advisor.md— mapper filtering, gateway validation, known behaviorarchitecture/sandbox.md— shared helper mentiondocs/security/best-practices.mdx— user-facing SSRF sectiondocs/reference/policy-schema.mdx— added missingallowed_ipsfield to endpoint tabledocs/observability/logging.mdx— shorthand examples with[reason:]and[engine:]docs/observability/ocsf-json-export.mdx—status_detailin JSON exampleE2E tests
[reason:]tag in denied event shorthandTesting
cargo fmt --checkpassesmise run pre-commit— blocked by pre-existing z3.h environment issue (unrelated)mise run e2e— requires running clusterChecklist