{"id":51184481,"url":"https://github.com/dfa1/ebpf-sensor","last_synced_at":"2026-06-27T09:04:06.281Z","repository":{"id":352451969,"uuid":"1215191260","full_name":"dfa1/ebpf-sensor","owner":"dfa1","description":"a toy sensor based on ebpf","archived":false,"fork":false,"pushed_at":"2026-05-05T19:18:21.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-05T21:21:12.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dfa1.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":"2026-04-19T15:47:31.000Z","updated_at":"2026-05-05T19:18:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dfa1/ebpf-sensor","commit_stats":null,"previous_names":["dfa1/ebpf-sensor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dfa1/ebpf-sensor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfa1%2Febpf-sensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfa1%2Febpf-sensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfa1%2Febpf-sensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfa1%2Febpf-sensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfa1","download_url":"https://codeload.github.com/dfa1/ebpf-sensor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfa1%2Febpf-sensor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34847288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"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":[],"created_at":"2026-06-27T09:04:04.536Z","updated_at":"2026-06-27T09:04:06.276Z","avatar_url":"https://github.com/dfa1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ebpf-sensor\n\neBPF event pipeline with pluggable sources and sinks.\nCompanion for [this article about BPF](https://dfa1.github.io/articles/from-bpf-to-ebpf-twenty-years-later).\n\n\n## Requirements\n\n- Python 3.12+\n- [uv](https://docs.astral.sh/uv/)\n\n## Setup\n\n```bash\nuv sync\n```\n\n## Usage\n\n```python\nfrom sources.ebpf import EBPFEventSource\nfrom sinks.kafka import KafkaEventSink\n\nsource = EBPFEventSource(bpf_prog=open(\"prog.c\").read())\nsink = KafkaEventSink(bootstrap_servers=\"localhost:9092\", topic=\"events\")\nfor event in source.events():\n    sink.write(event)\n```\n\n## Development\n\n```bash\nuv run python -m pytest  # tests\nuv run python -m .       # type check\nuv run ruff format .     # format\nuv run ruff check .      # lint\n```\n\n## TODO\n\n- Detect [Copy Fail 2: Electric Boogaloo](https://github.com/0xdeadbeefnetwork/Copy_Fail2-Electric_Boogaloo) — unprivileged LPE via xfrm ESP-in-UDP `MSG_SPLICE_PAGES` no-COW fast path (same class as CVE-2026-31431). Sensor ideas:\n  - kprobe `esp4_input` / `esp6_input` correlated with unprivileged UID\n  - xfrm_user netlink socket activity from non-root userns\n  - auto-load of `esp4` / `xfrm_user` / `xfrm_algo` from unprivileged context\n  - page-cache writes to `/etc/passwd` (and other sensitive files) following ESP traffic on loopback\n- Detect the **Copy Fail class** generically — `MSG_SPLICE_PAGES` / `splice()` / `sendfile()` fast paths that bypass copy-on-write and let unprivileged writers reach page cache of read-only-mapped files. Sensor ideas:\n  - kprobe `splice_to_pipe`, `iov_iter_extract_pages`, `skb_splice_from_iter`, `__splice_from_pipe` — flag when source skb/iter originates from unprivileged socket and target inode is world-readable + root-owned\n  - tracepoint on `MSG_SPLICE_PAGES` flag in `sendmsg` (`sock_sendmsg` kprobe, inspect `msg_flags`)\n  - correlate `mark_page_accessed` / `set_page_dirty` on `address_space` of sensitive inodes (`/etc/passwd`, `/etc/shadow`, suid binaries) with non-root `current_uid()`\n  - LSM `file_permission` deny-bypass: write-effect on inode without preceding `vfs_write` / `vfs_writev` from same task\n- Detect tampering and privilege abuse around setuid binaries and credential files. Avoid alerting on bare `open` (world-readable files = huge noise; open ≠ modify; misses page-cache writes that bypass VFS). Layered approach:\n  - **Credential-file tamper**: kprobe `vfs_write` / `notify_change` / LSM `security_inode_setattr` on inode set `{/etc/passwd, /etc/shadow, /etc/gshadow, /etc/sudoers, /etc/sudoers.d/*}` with `current_uid() != 0` → high-signal alert. Match by `(dev, ino)` captured at boot, not path string (survives bind-mounts, distro variance).\n  - **Setuid exec**: LSM `bprm_check_security` (or kprobe `exec_binprm`) where `binprm-\u003efile-\u003ef_inode-\u003ei_mode \u0026 (S_ISUID|S_ISGID)`. Log caller uid, target inode, argv[0]. Cheap inode-mode check, distro-independent.\n  - **Privilege transition**: kretprobe `commit_creds`, compare `old-\u003eeuid` vs `new-\u003eeuid`. Flag non-root → root transitions; correlate with recent setuid-exec event for context.\n  - **Page-cache tamper (covers Copy Fail class)**: kprobe `set_page_dirty` / `mark_buffer_dirty` where `page-\u003emapping-\u003ehost` ∈ sensitive inode set and no `vfs_write` from `current` task in last N ms. Catches `MSG_SPLICE_PAGES` no-COW writes that never hit `file_open` / `vfs_write`.\n  - **Skip**: open-only hooks, static path lists, parent-comm allowlists (rot under `systemd-run`, `tmux`, container runtimes), `(inode, pid)` rate-limits (useless for one-shot exploits).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfa1%2Febpf-sensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfa1%2Febpf-sensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfa1%2Febpf-sensor/lists"}