Repository navigation
feat: filter sandboxed system calls and stop core dumps - #1258
Merged
Merged
Conversation
Deploying edgewatch with
|
| Latest commit: |
98c9e79
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fcb44552.edgewatch-cpd.pages.dev |
| Branch Preview URL: | https://feat-process-hardening.edgewatch-cpd.pages.dev |
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.
What changes
The last layer of the scanner and notification sandboxes: a seccomp filter for the sandboxed processes, and no core dumps or same-identity debugging for any EdgeWatch process.
Seccomp filter
With Landlock,
sandbox-execnow also installs a seccomp filter (--seccomp) on its locked thread, afterno_new_privsand Landlock and before it executes the scanner or the notification child. The program inherits the filter. The filter:EPERMthe calls no scanner or notification process needs:ptrace,process_vm_readv,process_vm_writev,kcmp;userfaultfd,perf_event_open,bpf;unshare,setns,chroot;syslog;uselib.clonewith namespace flags.clone3fails withENOSYS, since a filter cannot read its flags; C libraries then useclone, and Go usesclone3only for cgroup and time namespace options.Docker's default profile already refuses most of these calls. The filter keeps them refused under runtimes or profiles that don't, and it adds
ptraceand io_uring, which recent Docker profiles allow.Implementation notes:
zsysnum_linux_{amd64,arm64}.go, whatever the host architecture.SECCOMP_GET_ACTION_AVAILfor the filter's actions.sandbox-execinstalls it.scanner_sandbox.seccompandnotification_sandbox.seccomp(state,reason) appear inedgewatch healthandGET /api/v1/status, and the logs. The Overview showsEnforced · NET_RAW · Landlock · seccomp.No core dumps
mainnow callssandbox.HardenProcess()first in every EdgeWatch process. It sets the soft and hardRLIMIT_COREto zero and clears the dumpable flag:CAP_SYS_PTRACE. That matters for UID 0 scanners under a pre-v0.27.0compose.yamlon a kernel without Landlock.execveresets dumpability for them, as before;/dev/fdreopen keeps working.Compatibility
scanner.landlock: offalso turns off the filter.seccomp.stateis thenunavailable, with the reason.Validation
gofmt,go vet ./...,go test -race -timeout=25m ./...cloneagainst namespace clones,clone3, another architecture, and x32.ptrace,unshare(CLONE_NEWUSER),clone(CLONE_NEWUSER|CLONE_FS)(which the kernel would refuse withEINVAL, never creating a process) andio_uring_setupgetEPERM, as do x32 calls.clone3getsENOSYS, andgetpidstill works.dumpable 0, core limits0 0../scripts/verify-scanner-sandbox.shon a locally built image now also requires:seccomp:enforcedin health for the base, SYN, legacy and notification sandboxes;0 0;0 0;npm run lint,npm run build,npm run test:coverage,npm run test:e2enpm --prefix docs run build