All Projects → antitree → syscall2seccomp

antitree / syscall2seccomp

Licence: other
Build custom Docker seccomp profiles for containers by finding syscalls it uses.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to syscall2seccomp

dockerfiles
A collection of Docker recipes.
Stars: ✭ 31 (-56.34%)
Mutual labels:  docker-container
drupal-dev-docker
An opinionated Drupal development environment based on Docker.
Stars: ✭ 22 (-69.01%)
Mutual labels:  docker-container
larawell
Monolithic docker container to run your Laravel apps: MariaDB/Redis/Nginx/PHP7.0-Fpm with properly configured cron and queue
Stars: ✭ 14 (-80.28%)
Mutual labels:  docker-container
yupe-docker
Yupe! CMF in Docker containers
Stars: ✭ 15 (-78.87%)
Mutual labels:  docker-container
docker-controller-scala
No description or website provided.
Stars: ✭ 12 (-83.1%)
Mutual labels:  docker-container
GeoServer-Docker
Docker container for installing Geoserver
Stars: ✭ 62 (-12.68%)
Mutual labels:  docker-container
multi-site-docker
A multi-site-docker configuration featuring nginx, php and mysql
Stars: ✭ 85 (+19.72%)
Mutual labels:  docker-container
another-ldap-auth
LDAP Authentication for Nginx, Nginx ingress controller (Kubernetes), and HAProxy via a subrequest.
Stars: ✭ 30 (-57.75%)
Mutual labels:  docker-container
multirun
A minimalist init process designed for Docker
Stars: ✭ 85 (+19.72%)
Mutual labels:  docker-container
wkhtmltopdf-flask-aas
Wkhtmltopdf Flask As a Service
Stars: ✭ 17 (-76.06%)
Mutual labels:  docker-container
network-tools
Network Tools
Stars: ✭ 27 (-61.97%)
Mutual labels:  docker-container
docker-lidarr-lad
Official docker for LAD bash enhancement script
Stars: ✭ 22 (-69.01%)
Mutual labels:  docker-container
dockupdater
Automatically keep your docker services and your docker containers up-to-date with the latest version
Stars: ✭ 76 (+7.04%)
Mutual labels:  docker-container
nftables-example
A playground ruleset to get to know nftables syntax
Stars: ✭ 19 (-73.24%)
Mutual labels:  docker-container
docker-omnidb
OmniDB installed into a Docker container
Stars: ✭ 30 (-57.75%)
Mutual labels:  docker-container
strider-docker-runner
Strider runner that uses Docker
Stars: ✭ 33 (-53.52%)
Mutual labels:  docker-container
jira-grafana-json-datasource
Connect Grafana to Jira cloud to retrieve metrics on your Jira issues.
Stars: ✭ 68 (-4.23%)
Mutual labels:  docker-container
yii2-laradock
Laradock pre-configured for Yii2 Framework (https://github.com/LaraDock/laradock)
Stars: ✭ 16 (-77.46%)
Mutual labels:  docker-container
minicon
Minimization of the filesystem for containers
Stars: ✭ 70 (-1.41%)
Mutual labels:  docker-container
docker-monitoring-windows
Monitor your Docker containers using prometheus, cAdvisor , node-exported and grafana on Windows
Stars: ✭ 49 (-30.99%)
Mutual labels:  docker-container

syscall2seccomp

A tool to help build custom Docker seccomp profile by extracting syscalls from various tools and outputting them to the Docker custom seccomp profiles JSON format. In theory, this would let you come up with a customized whitelist of only the required syscalls and block/error/crash* all other syscall attempts.

Usage:

With sysdig

python3 ./syscall2seccomp.py -s path-to-sysdig-output

With strace

python3 ./strace2seccomp.py path-to-strace-output

Example with Sysdig

Start sysdig

sudo sysdig container.name=myawesomecontainer > myawesomecontainer.sysdig

Start your container

docker run --name myawesomecontainer nginx

Perform all the normal activities of the container and then shut it down.

Convert the output to a seccomp profile

python3 syscall2seccomp.py -s myawesomecontainer.sysdig > myawesomecontainer.json

Start your container with the seccomp filtering enabled

docker run \
       --security-opt seccomp=$PWD/myawesomecontainer.json \
       nginx

Example with Strace

Run strace on an application and save the output:

strace -o wget.strace wget https://www.antitree.com 

Convert output to a Docker profile:

python3 ./syscall2seccomp.py wget.strace > wget.seccomp

NOTE: I've omitted the step of spending 2-300 hours of debugging why strace didn't include one of the syscalls you needed.

Start a docker container with the custom profile applied:

docker run -it \
       --security-opt seccomp=$PWD/wget.seccomp \
       busybox wget https://www.antitree.com

FAQ

Sysdig or Strace? Sysdig is rad for containers. Go check it out.

I ran through the example and it says "operation not permitted"

Right. By using a custom seccomp profile, you're also removing the default seccomp profile and there's no guarantee that you've got every single syscall that the application made. That's the nature of the beast. In practice I've found that sysdig is better at catching container-level syscalls besides the syscalls that your application needs after starting.

Why use a custom seccomp profile?

Seccomp BPF is a powerful tool to prevent potentially malicious system calls from being sent insides your container. Minimizing the syscalls that should be allowed minimizes the attack surface and could prevent a container breakout.

That's the idea.

Should you use custom seccomp profiles for each of your containers? Probably not. Managing so many custom profiles, deploying them consistently, and integrating it into unit testing is most likely more effort (and risk) than it's worth.

So you don't recommend custom seccomp profiles, why make this tool?

The use case is individuals that want to play with custom seccomp profiles and apply it to a few of the Docker containers they run. In that scenario, where they spend the time customizing the profile to be more secure than the default one, it adds some value.

For enterprises with major deployments and orchestration involved, I just wanted to make it as easy as possible to see how annoying it was to manage custom seccomp profiles.

Maybe Docker will address this by letting you apply multiple seccomp profiles (right now, the last profile to be applied, wins) or aid in managing profiles in Swarm but at this point, there's more value in working to build custom AppArmor profiles.

Why do you add a bunch of syscals automatically?

Syscalls.py contains a list of requisit syscalls by any container because reasons. See: moby/moby#22252

What about seccomp BPF arguments? Isn't that the point of BPF?

Good luck with that. That would require real reviewing of strace output but this is at least a simple starting point.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].