Files
OpenShell/crates/openshell-supervisor-network
Adel Zaalouk def7da876c fix(ocsf): emit schema-conformant OCSF 1.8 events (#4288)
Native events failed the official OCSF 1.8.0 validator: HTTP Activity
emitted is_src_dst_assignment_known, sandbox Process Activity events had
no actor, connection_info lacked direction_id, and SSH Activity events
named no endpoint. Schema tests missed these because they checked only
top-level, non-profile attributes.

Add a connection direction enum, require an actor on Process Activity
and an endpoint on SSH Activity at compile time, and name the
supervisor's SSH server with svc_name and its socket path.

Validate against OCSF 1.8.0 only. validate_required_fields and
validate_known_fields share one recursive walker that rejects undefined
attributes at every level and, for events, attributes from undeclared
profiles; objects are validated as objects. Records labelled with
another version fail. Vendor tactic and technique so ATT&CK-mapped
findings validate, drop the unused v1.7.0 schemas, and make the
embedded-schema drift test tolerate CRLF checkouts.

Keep it fixed with a per-builder conformance test and a Podman e2e test
that runs an L7 policy against a local server and validates the
supervisor's real Network, HTTP and SSH Activity JSONL. Top-level
container stays unchanged; #4915 tracks it. The schema
downgrade is unchanged.

Closes #4283

Signed-off-by: Adel Zaalouk <azaalouk@redhat.com>
2026-10-28 20:50:57 +00:00
..

Network supervisor

This crate forbids unsafe code, including its local tests. Typed socket APIs provide original-destination lookup for transparent proxying.

Socket attribution tests pass a duplicate connected socket as a spawned child's stdin. Re-executing the test binary checks multiple holders with the same binary identity; executing a different binary checks ambiguous shared-socket identity. The fixture kills and reaps the child when the parent test ends.

The manual proxy performance baseline still counts allocations. Its test-only global allocator uses openshell-driver-vm::allocation_tracking; the unsafe allocator implementation belongs to the VM crate. The VM dependency disables default features, so this instrumentation does not require the compute runtime or Unix-only sandbox library. It is a development dependency only.

Sandbox instance inputs

run_networking takes a SandboxInstanceNetwork with the sandbox identity, the sandbox instance's GatewayEndpoint, the SPIFFE Workload API socket for provider token grants, the policy.local denial source, and proxy CA files. None of these are read from the process environment, so one process can run several sandbox instances. Each instance owns its provider token cache and HTTP client; a token acquired for one sandbox is never served to another. Without a Workload API socket, token grants fail closed. A process hosting several instances serves /v1/denials from a per-instance SandboxInstanceDenialLog instead of the shared shorthand log files.

Reserved destinations

preauthorize_transparent_open matches a staged TCP open against the reserved OTLP relay address (openshell_core::sandbox_env::OTLP_RELAY_ADDR) before host mapping, policy evaluation, and SSRF checks. The address is an unroutable label, so the proxy never dials it. When run_networking receives a ReservedDestination, the proxy hands the workload stream to its ReservedStreamHandler; a handler that refuses, for example at its connection cap, turns the open into a resource-exhausted denial. Without a handler, the proxy denies the open at once. It logs the first attempt at warn and later ones at debug, and emits no OCSF denial event: a standard OpenTelemetry SDK retries for the life of the agent, and one event per retry would flood the OCSF log. The supervisor installs its OTLP relay receiver as the handler while the agent trace relay is active.