Skip to content

[PoC] SECCOMP profiles #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[PoC] SECCOMP profiles #198

wants to merge 2 commits into from

Conversation

lukehinds
Copy link

@lukehinds lukehinds commented Apr 16, 2025

Don't feel you have to merge this, I got time to play a lot with toolhive last night and hacked up a way of injecting seccomp profiles during container runtime init

To be honest docker and podman have a good set of defaults, but I was thinking about how limited the scope of MCP servers tends to be (most are limited to specialised jobs) and so custom seccomp profiles seemed worth exploring

I really have not had much time to test this and so please don't feel a need to merge quickly if at all, I don't want to introduce a security risk from me hacking away with curiosity.

iirc correctly, the order is:

  1. Server-specific overrides: Individual configuration in each server's permissions.seccomp section in registry.json

  2. Global defaults: From seccomp_defaults section in registry.json

  3. Fallback defaults: Hardcoded in NewProfile() function, used only if registry.json is missing and to make sure a footgun does not happen

You can see the rules applied using inspect

docker inspect --format '{{.HostConfig.SecurityOpt}}' ffdcb25d76cf
[seccomp={"defaultAction":"SCMP_ACT_ERRNO","syscalls":[{"names":["ptrace","reboot","kexec_load"],"action":"SCMP_ACT_ERRNO"},{"names":["read","write","exit","open","close"],"action":"SCMP_ACT_ALLOW"}]}]

Don't feel you have to merge this, I got time to play a lot with
toolhive last night and hacked up a way of injecting seccomp profiles
during container runtime init

To be honest docker and podman have a good set of defaults, but
I was thinking about how limited the scope of MCP servers tends to
be (most are limited to specialised jobs) and so customer seccomp
profiles seemed worth exploring

I really have not had much time to test this and so please don't feel
a need to merge quickly if at all, I don't want to introduce a security
risk from me hacking away with curiosity.

iirc correctly, the order is:

1. Server-specific overrides: Individual configuration in each server's
   `permissions.seccomp` section in registry.json

2. Global defaults: From `seccomp_defaults` section in registry.json

3. Fallback defaults: Hardcoded in `NewProfile()` function, used only if
   registry.json is missing and to make sure a footgun does not happen

You can see the rules applied using inspect

```
docker inspect --format '{{.HostConfig.SecurityOpt}}' ffdcb25d76cf
[seccomp={"defaultAction":"SCMP_ACT_ERRNO","syscalls":[{"names":["ptrace","reboot","kexec_load"],"action":"SCMP_ACT_ERRNO"},{"names":["read","write","exit","open","close"],"action":"SCMP_ACT_ALLOW"}]}]
```
case "trace":
defaultAction = "SCMP_ACT_TRACE"
default:
logger.Log.Warn(fmt.Sprintf("Warning: Unknown seccomp default action: %s, using SCMP_ACT_ERRNO", profile.Seccomp.DefaultAction))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have logger.Log.Warnf in main now, should enable you to avoid using fmt.Sprintf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants