Skip to content

feat(network): let policy authors set the OCSF severity of L7 rule violations #6036

Backlog

Description

@u0324020

User Story

I'm a senior engineer at VicOne. We run OpenShell on Kubernetes to sandbox a long-running agent, and the supervisor's OCSF events go to our security team's log pipeline.

When I reported the first results to management, the question that came back was whether we can adjust the severity OpenShell assigns to these events. We can't: a request that violates an L7 rule is always Medium under enforcement: enforce, whichever endpoint it hit, and under enforcement: audit it is emitted as Allowed / Informational, the same as a permitted request.

The severity is fixed in the supervisor code, so today the grading is redone downstream by our security team. I'd like to set the severity of a violation in the policy, next to the rule that defines it.

Problem Statement

The OCSF severity of sandbox network events is fixed in code. Nothing in the policy document or in gateway/sandbox settings changes it. For request-level (L7) decisions every relay path uses the same mapping:

Request outcome action / disposition severity
Matches the endpoint's rules Allowed / Allowed Informational
Breaks the rules, enforcement: audit Allowed / Allowed Informational
Breaks the rules, enforcement: enforce Denied / Blocked Medium

One exception to the first row: an allowed request that carries an Upgrade header (a WebSocket handshake) is reported as Other / Other, still Informational.

  • An audit-mode violation differs from an allowed request only in the message text (L7_REQUEST audit … vs L7_REQUEST allow …). A consumer that filters on severity_id, action_id, or the OTLP severity band cannot tell them apart.
  • Every enforced violation is Medium. A policy author cannot mark violations on one endpoint (for example, a write API with side effects) as more serious than violations on another.
  • The event enricher is documented to add context only and preserve classification, so there is no supported way to change severity after the fact.

Impact / Why This Matters

  • Without this, anyone running an endpoint in enforcement: audit has to parse the message string to find its violations in a SIEM. Severity and action, the fields SIEM rules are built on, carry no signal.
  • Grading ends up maintained in two places: the endpoints and rules in the OpenShell policy, and the re-grading logic in the downstream system. The two can drift when an endpoint is added, renamed, or switched from audit to enforce.
  • Teams that can't maintain re-grading logic either alert on every Medium deny (noisy) or on none (blind). Both weaken the point of exporting OCSF.
  • OTLP export already maps OCSF severity to OTLP severity bands, so a severity the author chose would flow through unchanged to collectors that route by band.

Proposed Design

Add an optional per-endpoint field, violation_severity, next to enforcement. It sets the severity of the event emitted when a request breaks that endpoint's rules, in whichever mode the endpoint is in. Unset means today's behavior, byte for byte. Older releases don't understand the field: endpoint fields are parsed with deny_unknown_fields, so an older CLI rejects a policy file that sets it, and an older gateway or supervisor that receives the policy over the API skips the unknown field and keeps today's severity. The docs should name the first release that honors it.

version: 1
network_policies:
  ticketing_api:
    endpoints:
      - host: tickets.example.com
        port: 443
        protocol: rest
        enforcement: audit
        violation_severity: medium   # audit violations are reported as Medium instead of Informational
        rules:
          - allow:
              method: GET
              path: "/api/v2/**"
    binaries:
      - path: /usr/bin/curl
  payments_api:
    endpoints:
      - host: payments.example.com
        port: 443
        protocol: rest
        enforcement: enforce
        violation_severity: high     # denied requests are reported as High instead of Medium
        rules:
          - allow:
              method: GET
              path: "/v1/**"
    binaries:
      - path: /usr/bin/python3

Behavior:

  • Allowed values: informational, low, medium, high, critical. An unknown value fails validation and the whole policy is rejected, the same way an unknown enforcement value is today.
  • Only severity_id / severity change. action, disposition, status, and the message stay as they are. policy.local selects denial lines by the DENIED action, not by severity, so /v1/denials and the policy advisor flow that reads it still list the violation; the only difference is the severity tag inside the line.
  • Out of scope, unchanged: allowed requests, requests whose path matches no L7 endpoint, requests rejected because they cannot be processed safely (malformed GraphQL / JSON-RPC, MCP protocol-version, metadata, and schema rejections), L7 evaluation errors, TLS and credential-safety refusals, SSRF blocks, middleware events, and Landlock findings.
  • If two endpoints that can match the same request set different values, that is reported as a conflict, as it is for enforcement.

Possible follow-up (could be a separate issue, raising it here for scope): L4 denials with no matching policy (CONNECT denied, FORWARD denied, transparent TCP) have no rule to carry a field. These can be a large share of the volume, for example an agent's built-in background calls (catalog refresh, version checks) to hosts that are deliberately left out. A registered setting could cover them:

openshell settings set --global --key ocsf_unmatched_deny_severity --value low

Questions for maintainers:

  1. Scalar violation_severity, or a {deny, audit} pair? Endpoint level, or the policy (network_policies.<name>) level?
  2. Should audit violations keep Informational as the default, or is this the time to make them distinguishable by default (a Low severity, or an OCSF disposition such as Logged)? That would change default output, so I have left it out of the proposal.
  3. Should the Cedar policy path get an equivalent annotation (alongside @enforcement)?
  4. Is the L4 setting above wanted, and if so, in the same change or separately?
  5. Provider profiles declare endpoints with their own enforcement. Should they accept violation_severity too, or should it live only in the policy document?

Acceptance Criteria

  • A policy without violation_severity produces OCSF JSON and shorthand log lines identical to today's for allowed, audit, and denied requests.
  • With violation_severity: high on an enforce endpoint, a rule violation is logged as [HIGH] … DENIED … with action_id Denied and disposition_id Blocked, and still appears in the recent denials returned by policy.local.
  • With violation_severity: medium on an audit endpoint, a rule violation is logged with severity_id 3 and action_id Allowed; allowed requests on the same endpoint stay Informational.
  • The setting takes effect on REST, JSON-RPC/MCP, GraphQL, WebSocket, and plaintext forward-proxy requests.
  • Malformed-request hard denials and the other events listed as out of scope keep their current severity on an endpoint that sets violation_severity.
  • An invalid value is rejected with a clear validation error; YAML ↔ proto round-trip preserves the field.
  • The policy schema reference and the network-rules guide document the field.

Alternatives Considered

  • Re-grade downstream (what we do today): works, but the grading then lives in a second system, apart from the policy that defines the rule, and audit violations can only be found by parsing the message, since severity and action match allowed traffic. Re-grading by firewall_rule.name helps for enforced denies but breaks when a policy is renamed.
  • Event enricher hook: its contract is to add context and preserve classification, and it is a single process-wide slot already used for request correlation. Using it to rewrite severity would go against its stated purpose.
  • Middleware: middleware only sees requests that policy admits, so it never sees an enforced denial and cannot re-grade one. For audit-mode violations it can emit its own finding with a severity, but that does not change the severity of the policy decision event; it adds a service and a second event per violation.
  • Gateway interceptors: they govern gateway API operations (policy and provider changes), not runtime events from the sandbox, so they do not apply.
  • A general severity-mapping table (by event class, host, path, or message): larger surface, and RFC 0005 lists OCSF severity among the compatibility surfaces, so a per-endpoint opt-in seemed the smallest safe change.
  • Per-deny-rule severity: more precise, but the Rego evaluation does not currently report which deny rule matched; the endpoint level matches where enforcement already lives.

Agent Investigation

Code references are against main at 9996a59e9.

  • crates/openshell-supervisor-network/src/l7/relay.rs:2298-2320 (build_l7_request_event): the decision maps deny to Denied / Blocked / Medium and both allow and audit to Allowed / Allowed / Informational. The same deny / allow-or-audit mapping is repeated at six other sites: l7/relay.rs:2828, 3405, 3783, 4341, l7/websocket.rs:2061, and proxy.rs:6561.
  • proto/sandbox.proto:152,188: NetworkEndpoint.enforcement (NetworkEnforcementMode) already travels per endpoint from the policy YAML to the supervisor's L7 endpoint config. A severity field can follow the same path: policy schema, YAML ↔ proto conversion, validation, conflict detection, runtime config.
  • Under enforce, malformed-request hard denials and rule violations reach the event builder with the same deny decision, so an implementation has to tell them apart to leave hard denials at Medium.
  • policy.local selects denial lines by the DENIED action label in the shorthand line (policy_local.rs:579-581), not by the severity tag, so a violation with a changed severity still shows up in /v1/denials.
  • No registered gateway or sandbox setting changes event severity today.
  • feat(observability): record policy generation on allow and deny decisions #5534 (open) touches the same event-building sites in l7/relay.rs, l7/websocket.rs, and proxy.rs to record the policy generation, so a change here would need to be sequenced with it.

Checklist

  • I've reviewed existing issues and the published docs
  • This is a design proposal, not a "please build this" request

Activity

  1. added
    state:triage-needed
    on Nov 27, 2026
  2. u0324020 commented on Nov 27, 2026

    @u0324020
    ContributorAuthor

    I put together a prototype on a branch in our fork, so the change can be discussed against real code:
    https://github.com/VicOne-OSS-TW/OpenShell/tree/feat/6036-l7-violation-severity/u0324020

    What it does:

    • Adds an optional violation_severity field to an L7 endpoint: informational, low, medium, high or critical. Endpoints with protocol: tcp reject it, like the other L7-only fields.
    • When the field is unset, the events are the same as today. The first commit adds tests that pin the current severities; their assertions are unchanged at the branch head and still pass.
    • When it is set, it changes only the severity of the events for requests that violate that endpoint's rules, in both enforce and audit mode. The action, disposition and the other fields stay the same.
    • Requests that match no endpoint, and requests rejected because they cannot be parsed safely, keep their current severity. L4 denials are out of scope, as noted in the issue.

    I also ran it end to end on my machine with the Docker driver (gateway, supervisor, sandbox and CLI all built from the branch). 13 scenarios through the CLI: unset vs set, enforce vs audit, an unknown value rejected by both policy lint and policy set, and two endpoints for the same host and port with different values rejected as a conflict.

    I'll wait for triage before opening a PR. Happy to change the field name, where it lives, or the scope based on your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions