Harden detection coverage, provenance hot path, and operator safety#7
Merged
Merged
Conversation
Acts on a security & efficiency review of the sensor. Grouped by theme: Detection coverage - Expand the sensitive-syscall set to modern post-exploitation and evasion primitives: memfd_create, process_vm_read/writev, bpf, seccomp, userfaultfd, setns/unshare/mount, io_uring_setup/enter, sendto/sendmsg/sendmmsg, pidfd_getfd, init_module/finit_module, kexec_load, prctl, chroot, accept4. These only ever escalate a call already coming from injected code (or an opt-in --audit-sensitive breadcrumb), so legitimate programs stay silent. - Track recvmmsg as a first-stage input channel. Robustness / correctness - maps: drop degenerate (start >= end) regions and keep the map sorted, then answer region_at with an O(log n) binary search instead of a linear scan — it runs for rip, rsp, and memory-op targets on every syscall. - tracer: replace panicking HashMap indexing in the wait loop with fallible lookups so a phantom stop can never crash the sensor. - engine: free a process's cached memory map and detector chain state when its last thread exits, bounding memory on long traces of forking targets. Terminal / output safety - Neutralise ANSI escape sequences in attacker-influenced display fields (process comm names, mapped-file labels) before they reach the TTY, in both the log line and the dashboard. - Surface JSON-sink write failures instead of dropping them: warn once on the stream, banner in the TUI. A dropped detection is the worst outcome. - The --json file sink now appends rather than truncates, preserving prior evidence across re-runs. CLI / portability - Add --version, a --max-targets cap for scan, a /proc preflight check, and a warning when --trust-region spans an implausibly large area. - Fail the build with a clear message on non-x86-64 targets. - syscalls::name returns Cow<'static, str>, avoiding a heap allocation per known syscall on the hot path; remove dead is_payload_capable. Adds 12 unit tests; all existing unit and ptrace integration tests still pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ATUW6fbK4Spc3fJKL6se1
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.
Acts on a security & efficiency review of the sensor.
Detection coverage
memfd_create,process_vm_read/writev,bpf,seccomp,userfaultfd,setns/unshare/mount,io_uring_setup/enter,sendto/sendmsg/sendmmsg,pidfd_getfd,init_module/finit_module,kexec_load,prctl,chroot,accept4. These only ever escalate a call already coming from injected code (or an opt-in--audit-sensitivebreadcrumb), so legitimate programs stay silent.recvmmsgas a first-stage input channel.Robustness / correctness
maps: drop degenerate (start >= end) regions and keep the map sorted, then answerregion_atwith an O(log n) binary search instead of a linear scan — it runs forrip,rsp, and memory-op targets on every syscall.tracer: replace panickingHashMapindexing in the wait loop with fallible lookups so a phantom stop can never crash the sensor.engine: free a process's cached memory map and detector chain state when its last thread exits, bounding memory on long traces of forking targets.Terminal / output safety
--jsonfile sink now appends rather than truncates, preserving prior evidence across re-runs.CLI / portability
--version, a--max-targetscap forscan, a/procpreflight check, and a warning when--trust-regionspans an implausibly large area.syscalls::namereturnsCow<'static, str>, avoiding a heap allocation per known syscall on the hot path; remove deadis_payload_capable.Testing
Adds 12 unit tests. All existing unit and ptrace-driven integration tests pass; verified end-to-end against the real binaries (
benign,benign-threads,shellcode-sim) for both false-positive and true-positive behavior, plus the new--version,--jsonappend,--max-targets, and--trust-regionwarning paths.🤖 Generated with Claude Code
https://claude.ai/code/session_016ATUW6fbK4Spc3fJKL6se1
Generated by Claude Code