{"id":29230487,"url":"https://github.com/mikuchi9/bpfsbox","last_synced_at":"2026-05-19T02:01:33.900Z","repository":{"id":300575582,"uuid":"1006520025","full_name":"mikuchi9/bpfsbox","owner":"mikuchi9","description":"A small eBPF-based sandboxing tool designed to block any attempt by a process or its descendants to escalate to root with setuid() / setreuid() / setresuid().","archived":false,"fork":false,"pushed_at":"2025-09-04T09:13:29.000Z","size":716,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-04T11:23:40.045Z","etag":null,"topics":["cgroup-v2","ebpf","pid","sandbox","syscalls"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikuchi9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-22T13:06:20.000Z","updated_at":"2025-09-04T09:13:32.000Z","dependencies_parsed_at":"2025-06-22T14:28:00.184Z","dependency_job_id":"9dc95c2b-70b4-45cb-9e37-cc0c21da9a76","html_url":"https://github.com/mikuchi9/bpfsbox","commit_stats":null,"previous_names":["mikuchi9/safesetid-bpf","mikuchi9/bpfsbox"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mikuchi9/bpfsbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikuchi9%2Fbpfsbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikuchi9%2Fbpfsbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikuchi9%2Fbpfsbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikuchi9%2Fbpfsbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikuchi9","download_url":"https://codeload.github.com/mikuchi9/bpfsbox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikuchi9%2Fbpfsbox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33198811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"online","status_checked_at":"2026-05-19T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgroup-v2","ebpf","pid","sandbox","syscalls"],"created_at":"2025-07-03T14:00:49.408Z","updated_at":"2026-05-19T02:01:33.878Z","avatar_url":"https://github.com/mikuchi9.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bpfsbox\n\n**bpfsbox** is a minimal eBPF-based sandbox enforcement tool that monitors and restricts privilege escalation syscalls (e.g. `setuid()`, `setreuid()`, `setresuid()`) by killing processes that violate sandbox rules. It uses Linux cgroups and eBPF tracepoints to provide lightweight, in-kernel process isolation and monitoring.\n\n---\n\n### ✨ Features\n\n- Monitors syscalls: `setuid()`, `setreuid()`, `setresuid()` using eBPF tracepoints.\n- Restricts privilege elevation for processes in specified cgroups.\n- Kills offending processes automatically from inside the kernel.\n- Written in C using `libbpf`.\n\n---\n\n### 📦 Prerequisites\n\n- Linux kernel with eBPF support\n- Clang/LLVM and libbpf-dev\n- bpftool\n- Root privileges\n- cgroup v2\n\n---\n\n### 🧠 How It Works\n\n1. The parent process is placed into a dedicated cgroup.\n2. All child processes inherit the cgroup.\n3. A pinned eBPF map stores the cgroup ID.\n4. An eBPF program is attached to syscall tracepoints: `sys_enter_setuid`, `sys_enter_setreuid`, `sys_enter_setresuid`.\n5. When a monitored syscall is triggered, the BPF program:\n   - Checks if the process is in the target cgroup.\n   - If so, it kills the process immediately using `bpf_send_signal(SIGKILL)`.\n\n---\n\n### 🛠️ Build and Run\n\n```\nmake all\nsudo ./bpfsbox \u003ccgroup_name\u003e \u003cprocess_pid\u003e\n```\n### 🧪 Example Usage\n\nRun your program with:\n`sudo ./bpfsbox \u003ccgroup_name\u003e \u003cprocess_pid\u003e \u0026`\nThis will:\n- Create a new cgroup under `/sys/fs/cgroup/\u003ccgroup_name\u003e/`\n- Add the specified `process_pid` to the new cgroup by writing it to `cgroup.procs`\n\nTo manually add other processes (not descendants of the initial one) to the same sandboxed group:\n`echo \u003cother_process_pid\u003e | sudo tee /sys/fs/cgroup/\u003ccgroup_name\u003e/cgroup.procs`.\nYou can also daemonize `bpfsbox`.\n\n### 🧪 Simulated Privilege Escalation\n\u003e A helper program's source code, `setuid.c`, is included to simulate privilege escalation using `setuid()`. When run inside the sandboxed cgroup, your eBPF program detects and kills it using `bpf_send_signal(SIGKILL)`.\n\n🔍 This helps validate that the sandbox logic correctly intercepts and handles dangerous system calls.\n\n### 🧾 Header provenance\nThe bundled `vmlinux.h` was generated on Ubuntu 22.04.04 LTS (kernel 6.5.0, BTF enabled)\nusing `bpftool v7.3.0`. Regenerate with `make headers` if you need an exact match\nfor a custom kernel.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikuchi9%2Fbpfsbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikuchi9%2Fbpfsbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikuchi9%2Fbpfsbox/lists"}