Repository navigation
Phase 3: Hermetic Network & Kernel Sandbox Hardening (WS4.1-WS4.3) - #83
Merged
Merged
Conversation
…osed AppContainer sandbox - Remove blanket loopback/control-port allowlists in wfp.rs and scope WFP/BFE permits to KillSwitch AppID, exact localhost, and sanitized bound control ports - Block 127.0.0.2-127.255.255.255 loopback aliases, cloud IMDS 169.254.169.254, local proxy ports, lateral SMB/WinRM ports, and DNS/DoT/DHCP - Extend iphlpapi.dll teardown and peer counting to IPv6 TCP, 127.0.0.2+ aliases, proxy ports, and tracked-agent UDP sockets - Remove fake usermode-session-contract fallback in WindowsWfpIsolator and require in-process or CI-scoped KILLSWITCH_SELF_DIAGNOSTIC authorization - Implement WindowsAppContainerSandbox and spawn_sandboxed_agent_process with capabilityless SECURITY_CAPABILITIES, CREATE_SUSPENDED, pre-resume Job Object + TokenIsAppContainer verification, and DeleteAppContainerProfile cleanup - Update empirical_challenge_m1_2, empirical_challenge_m2_2, verify.rs, and killchain.rs for fail-closed quarantine contracts
…_DESTROY containment (WS4.2)
- Harden Linux Landlock add_path_rule (dir vs file access flags, ABI>=2 REFER, ABI>=3 TRUNCATE) and enforce pre-fork async-signal-safe PreparedLinuxSandbox (Landlock + PR_SET_NO_NEW_PRIVS + seccomp-bpf blocking ptrace/mount/unshare/setns/bpf/io_uring_setup and restricting non-network sockets to AF_UNIX) via CommandExt::pre_exec in spawn_sandboxed_agent_process and spawn_confined_process
- Add generate_linux_nftables_quarantine_script, install_linux_nftables_quarantine (atomic inet killswitch_quarantine table + readback verify), and remove_linux_nftables_quarantine, removing blanket loopback/discovery allows
- Extend Netlink SOCK_DESTROY (build_sock_destroy_msg_for_proto) and /proc/net/{udp,udp6,raw,raw6} parsers to destroy non-localhost TCP, UDP, RAW, 127.0.0.2+ alias, and loopback proxy sockets with fail-closed privilege gating
- Update lib.rs exports and WS4.2 integration/unit tests
…tbelt sandbox (WS4.3) - Harden pf.rs generate_quarantine_rules removing blanket lo0/127.0.0.1/::1 catch-alls, explicitly blocking IMDS (169.254.0.0/16, fe80::/10), DNS/DoT/DHCP/QUIC, loopback proxy ports (1080/3128/8080/8888/9050), lateral SMB/WinRM, and 127.0.0.2+ aliases while permitting ONLY sanitized exact 127.0.0.1<->127.0.0.1 and ::1<->::1 control ports on lo0 - Update MacOsPfIsolator to drive /sbin/pfctl -a com.apple/<anchor> atomically with pfctl -E token management, mandatory pfctl -sr readback verification, pfctl -k / tracked-PID state severing, fail-closed privilege checks, and cross-PID socket inspection (lsof/netstat/proc_fdinfo) - Implement generate_macos_seatbelt_profile and wire /usr/bin/sandbox-exec into spawn_sandboxed_agent_process on macOS with SBPL deny default and deny network* - Export generate_macos_seatbelt_profile in lib.rs and update macOS PF/Seatbelt tests
…s, and MibTcp6Row size assertion - Drop DashMap read guard on tainted_descendants before cache_tainted_descendant() writes back in agent_registry.rs, preventing intra-thread shard self-deadlock on child chains, and add pigeonhole shard-collision regression test - Fix MibTcp6Row size assertion in wfp.rs to match 52-byte _MIB_TCP6ROW Windows SDK ABI and assert MibTcp6RowOwnerPid is 56 bytes - Guard Windows-only tracing::warn and IPv4/IPv6 localhost/proxy helpers with cfg(windows)/cfg(any(windows, test)) in wfp.rs - Replace manual loop in landlock.rs find_nft_binary with Iterator::find for clippy::manual-find - Pass process name argument to crate::killchain::is_critical_system_pid in pf.rs - Guard Mutex/OnceLock imports and mut bindings in job_sandbox.rs for macOS clean builds - Guard Duration and debug imports in exec_sensor.rs for macOS clean builds
…-OS warnings - Add file-map-executable across read-only system/executable subpaths, process-info-pidinfo, dev ioctl, cryptex/select/homebrew read paths, and scoped syslog/libinfo mach-lookup in pf.rs generate_macos_seatbelt_profile so /bin/sh and /usr/bin/python3 execute cleanly under (deny default) while preserving write/network confinement - Scope is_blocked_proxy_port in wfp.rs strictly with #[cfg(windows)] so Linux/macOS Clippy -D warnings passes cleanly - Join worker_handle cleanly in MacOsProcessSensor::stop and guard detected_host_kernel_filters mutability in ring0_driver_loader.rs for warning-free macOS builds
…arden macOS Seatbelt SBPL execution - Add workspace crate killswitch-kernel-patcher with OS/kernel CPE 2.3 discovery (Windows RtlGetVersion + Registry, Linux /etc/os-release + uname, macOS sysctlbyname), NVD API 2.0 client (runtime env NVD_API_KEY only, zero secret persistence), CISA KEV prioritization & CVSS sorting, fail-closed privilege gating (IsElevated / geteuid), OS-native patch orchestration (UsoClient, canonical-livepatch/apt-get/dnf, softwareupdate), and multi-tier offline/live test suites - Wire `killswitch patch-kernel` CLI subcommand and periodic server NVD/KEV background scanner (with KernelScanSummary caching and dry-run/non-root safety) - Harden macOS Seatbelt SBPL profile in pf.rs (`(import "system.sb")` baseline plus explicit executable/path isolation and `(deny network*)`), resolve bare command names via PATH before entering sandbox-exec, and report Unix signal termination accurately (128 + sig) in job_sandbox.rs - Protect `.env` / `.env.*` in .gitignore cleanly
…ng, and macOS python3 Seatbelt CWD scan - Guard Windows-only imports in discovery/windows.rs with #[cfg(windows)] so Linux Clippy passes with zero unused-import errors - Filter empty/whitespace NVD_API_KEY values in patcher.rs before setting the HTTP apiKey header - Set readable sandboxed current_dir and isolated mode (-I) on the Seatbelt test subprocesses in job_sandbox.rs so Apple python3 importlib does not stat restricted workspace directories before loading stdlib sockets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3: Hermetic Network & Kernel Sandbox Hardening (WS4.1, WS4.2, WS4.3)
Summary
Closes network egress, loopback-proxy, link-local IMDS, DNS/QUIC, and process escape gaps across Windows, Linux, and macOS:
crates/killswitch-core/src/wfp.rsto strip blanket loopback/discovery port allowances, enforce AppID + exact127.0.0.1/::1control-port rules, block127.0.0.2..=127.255.255.254aliases (FWP_MATCH_RANGE), IMDS169.254.169.254, proxy/lateral/discovery ports, and fail closed outside authorized CI self-diagnostic mode (is_authorized_self_diagnostic()).iphlpapi.dll(GetTcp6Table,SetTcp6Entry,GetExtendedTcpTable,GetExtendedUdpTable).WindowsAppContainerSandboxandspawn_sandboxed_agent_processincrates/killswitch-core/src/job_sandbox.rsusingCreateAppContainerProfile(zero capabilities),EXTENDED_STARTUPINFO_PRESENT | CREATE_SUSPENDED, fail-closedAssignProcessToJobObject,IsProcessInJob, andTokenIsAppContainerchecks beforeResumeThread, withDeleteAppContainerProfilerollback/cleanup.add_path_ruledir vs regular-file flags (includingLANDLOCK_ACCESS_FS_EXECUTE,ABI>=2 REFER,ABI>=3 TRUNCATE) and added pre-fork async-signal-safePreparedLinuxSandbox(Landlock+PR_SET_NO_NEW_PRIVS+seccomp-bpfblocking 20 container/kernel breakout syscalls and restricting non-network sockets toAF_UNIX) wired intoCommandExt::pre_execonspawn_sandboxed_agent_processandspawn_confined_process.nftablesinet killswitch_quarantinegeneration, installation, mandatorynft list tablereadback verification, and removal alongside NetlinkRTN_BLACKHOLEroutes and TCP/UDP/RAWSOCK_DESTROY(build_sock_destroy_msg_for_proto,/proc/net/{udp,udp6,raw,raw6}parsers).crates/killswitch-core/src/pf.rsgenerate_quarantine_rulesto drop blanketlo0/127.0.0.1/::1catch-alls, block IMDS/link-local/DNS/DoT/DHCP/QUIC/proxy/lateral/127.0.0.2+ traffic, and permit only sanitized exact127.0.0.1<->127.0.0.1and::1<->::1control ports onlo0.MacOsPfIsolatorto load/sbin/pfctl -a com.apple/<anchor> -f -atomically withpfctl -Etoken tracking, mandatory-srreadback verification, cross-PID socket discovery,pfctl -k/ tracked-PID socket termination, and fail-closed privilege checks.generate_macos_seatbelt_profileand/usr/bin/sandbox-execwrapper inspawn_sandboxed_agent_process(macos_seatbelt_sandbox).Verification Plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningswindows-latest,ubuntu-latest, andmacos-latest(killswitch-coreLandlock/seccomp-bpf, Seatbelt, Windows AppContainer, PF/nftables/WFP tests, Clippy, Binary Integrity, Auto-Review Bot)