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

Commit 2446c42

Browse files
committed
feat(sandbox): seccomp-notify network enforcement for Platform mode
Add kernel-level connect() interception using SECCOMP_RET_USER_NOTIF for Platform mode. Provides mandatory, syscall-level network enforcement without any capabilities. Components: - DnsPinnedAllowlist: DNS pinning at sandbox creation, frozen IPs - BPF filter with AUDIT_ARCH validation (prevents x32 ABI bypass) - Notification fd ioctls (recv, send, id_valid) - pidfd_open/pidfd_getfd for on-behalf-of connect (TOCTOU-safe) - read_process_memory via /proc/pid/mem with read_exact (no short reads) - sockaddr parser (AF_INET/AF_INET6, correct endianness) - deny/allow_connect response helpers Also fixes from code review: - driver.rs: use typed enum comparison instead of magic integer == 1 - landlock.rs: saturating_sub to prevent underflow in skipped count - landlock.rs: upgrade TCP port failure log from debug to warn 8 tests. Compiles, 949 tests pass, clippy clean. Ref: NVIDIA#899
1 parent 9ec5718 commit 2446c42

4 files changed

Lines changed: 551 additions & 8 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)