An open API service indexing awesome lists of open source software.

https://github.com/gr455/contain

BPF based per-process per-container egress filter
https://github.com/gr455/contain

Last synced: 3 months ago
JSON representation

BPF based per-process per-container egress filter

Awesome Lists containing this project

README

          

# Contain
BPF based per-process per-container egress filter.

Filters outgoing traffic from containers based on the container and the process the traffic originated from. Once containd is running, it automatically detects any new containers.

## Run

**Requires cgroup v2**

1. Update `blacklist.json` with your own allow list.

2. To start Contain daemon, run
```
python3 containd.py
```

When the daemon is running, it detects any newly started containers and applies policies to them.

Once started, the allow list

```json
[
{
"container_name": "curler", // Only add a single object per container
"policy": [
{
"process": "curl", // Only add a single object per process, add one/multiple objects per container
"allow": [
{
"cidr4": "1.1.1.0/24",
"ports": [80, 443]
}
]
}
]
}
]

```

Gives

![Result](images/example.png)

This BPF filter uses `BPF_PROG_TYPE_CGROUP_SKB` and a kretprobe to kernel function `net/socket/sock_alloc_file` for per-process, per-container socket filtering.

Tested on Linux 5.19.0 - 6.2.0