Repository navigation
Description
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 …vsL7_REQUEST allow …). A consumer that filters onseverity_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: audithas 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
Mediumdeny (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/python3Behavior:
- Allowed values:
informational,low,medium,high,critical. An unknown value fails validation and the whole policy is rejected, the same way an unknownenforcementvalue is today. - Only
severity_id/severitychange.action,disposition,status, and the message stay as they are.policy.localselects denial lines by theDENIEDaction, not by severity, so/v1/denialsand 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 lowQuestions for maintainers:
- Scalar
violation_severity, or a{deny, audit}pair? Endpoint level, or the policy (network_policies.<name>) level? - Should audit violations keep
Informationalas the default, or is this the time to make them distinguishable by default (aLowseverity, or an OCSF disposition such asLogged)? That would change default output, so I have left it out of the proposal. - Should the Cedar policy path get an equivalent annotation (alongside
@enforcement)? - Is the L4 setting above wanted, and if so, in the same change or separately?
- Provider profiles declare endpoints with their own
enforcement. Should they acceptviolation_severitytoo, or should it live only in the policy document?
Acceptance Criteria
- A policy without
violation_severityproduces OCSF JSON and shorthand log lines identical to today's for allowed, audit, and denied requests. - With
violation_severity: highon anenforceendpoint, a rule violation is logged as[HIGH] … DENIED …withaction_idDenied anddisposition_idBlocked, and still appears in the recent denials returned bypolicy.local. - With
violation_severity: mediumon anauditendpoint, a rule violation is logged withseverity_id3 andaction_idAllowed; allowed requests on the same endpoint stayInformational. - 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.namehelps 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
enforcementalready 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 mapsdenyto Denied / Blocked / Medium and bothallowandauditto 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, andproxy.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 samedenydecision, so an implementation has to tell them apart to leave hard denials atMedium. policy.localselects denial lines by theDENIEDaction 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, andproxy.rsto 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
u0324020 commentedon Nov 27, 2026
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:
violation_severityfield to an L7 endpoint:informational,low,medium,highorcritical. Endpoints withprotocol: tcpreject it, like the other L7-only fields.enforceandauditmode. The action, disposition and the other fields stay the same.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 lintandpolicy 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.