Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

Commit 6078a8e

Browse files
committed
feat(sandbox): seccomp-notify network enforcement for Platform mode
Add kernel-level network syscall interception using SECCOMP_RET_USER_NOTIF for Platform mode. Provides mandatory, syscall-level enforcement without any capabilities. DnsPinnedAllowlist: resolve domains to IPs at sandbox creation, freeze for session lifetime (DNS rebinding prevention). BPF filter intercepts: connect, sendto, sendmsg, recvfrom, recvmsg, bind. Validates AUDIT_ARCH to prevent x32/compat ABI bypass. Linux syscall wrappers: notification fd ioctls, pidfd_open/pidfd_getfd for on-behalf-of operations (TOCTOU-safe), read_process_memory with read_exact (no short reads), sockaddr parser (correct endianness for sa_family, port, flowinfo), verify_socket_fd (mitigates fd-swap race), deny/allow_connect response helpers. Code review fixes applied across all PRs: - PR #15: gateway propagates network_enforcement to DriverSandboxSpec - PR #15: driver uses typed enum comparison (not magic integer) - PR #16: saturating_sub prevents underflow in Landlock skipped count - PR #16: warn!() on TCP port restriction failure (was debug) - PR #17: BPF arch check, recvfrom/recvmsg/bind interception, verify_socket_fd, read_exact, allow_connect rename, flowinfo endianness, safety comments on all unsafe blocks 8 tests. Compiles, 949 tests pass, clippy clean. Ref: NVIDIA#899
1 parent 179d108 commit 6078a8e

5 files changed

Lines changed: 590 additions & 12 deletions

File tree

‎crates/openshell-driver-kubernetes/src/driver.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ impl KubernetesComputeDriver {
330330
enable_user_namespaces: self.config.enable_user_namespaces,
331331
workspace_default_storage_size: &self.config.workspace_default_storage_size,
332332
sa_token_ttl_secs: self.config.effective_sa_token_ttl_secs(),
333-
is_platform_mode: sandbox
334-
.spec
335-
.as_ref()
336-
.is_some_and(|s| s.network_enforcement == 1),
333+
is_platform_mode: sandbox.spec.as_ref().is_some_and(|s| {
334+
use openshell_core::proto::NetworkEnforcementMode;
335+
s.network_enforcement() == NetworkEnforcementMode::NetworkEnforcementPlatform
336+
}),
337337
};
338338
obj.data = sandbox_to_k8s_spec(sandbox.spec.as_ref(), &params);
339339
let api = self.api();

‎crates/openshell-sandbox/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub mod procfs;
2323
mod provider_credentials;
2424
pub mod proxy;
2525
mod sandbox;
26+
pub mod seccomp_notify;
2627
mod secrets;
2728
mod skills;
2829
mod ssh;

‎crates/openshell-sandbox/src/sandbox/linux/landlock.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,11 @@ pub fn prepare(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<Option<P
238238
rules_applied += 1;
239239
}
240240
Err(e) => {
241-
debug!(
241+
tracing::warn!(
242242
error = %e,
243-
"Landlock TCP port restriction unavailable (ABI v4 required), \
244-
falling back to cooperative proxy enforcement"
243+
"Landlock TCP port restriction unavailable (ABI v4 required). \
244+
Network enforcement degraded: agent can bypass proxy via direct \
245+
connect(). Upgrade to RHEL 9.6+ for kernel-enforced TCP port restriction."
245246
);
246247
}
247248
}
@@ -255,7 +256,7 @@ pub fn prepare(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<Option<P
255256
));
256257
}
257258

258-
let skipped = total_paths - rules_applied;
259+
let skipped = total_paths.saturating_sub(rules_applied);
259260
openshell_ocsf::ocsf_emit!(
260261
openshell_ocsf::ConfigStateChangeBuilder::new(crate::ocsf_ctx())
261262
.severity(openshell_ocsf::SeverityId::Informational)

0 commit comments

Comments
 (0)