Skip to content
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

feat: add a syscall allow list in the SPOD configuration #913

Merged
merged 12 commits into from
May 3, 2022
4 changes: 4 additions & 0 deletions api/spod/v1alpha1/spod_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ type SPODSpec struct {
// SPO's webhooks
// +optional
WebhookOpts []WebhookOptions `json:"webhookOptions,omitempty"`
// AllowedSyscalls if specified, a list of system calls which are allowed
// in seccomp profiles.
// +optional
AllowedSyscalls []string `json:"allowedSyscalls,omitempty"`
}

// SPODState defines the state that the spod is in.
Expand Down
5 changes: 5 additions & 0 deletions api/spod/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ spec:
spec:
description: SPODStatus defines the desired state of SPOD.
properties:
allowedSyscalls:
description: AllowedSyscalls if specified, a list of system calls
which are allowed in seccomp profiles.
items:
type: string
type: array
enableAppArmor:
description: tells the operator whether or not to enable AppArmor
support for this SPOD instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ rules:
- seccompprofiles
verbs:
- create
- delete
- get
- list
- patch
Expand Down
6 changes: 6 additions & 0 deletions deploy/base/crds/securityprofilesoperatordaemon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ spec:
spec:
description: SPODStatus defines the desired state of SPOD.
properties:
allowedSyscalls:
description: AllowedSyscalls if specified, a list of system calls
which are allowed in seccomp profiles.
items:
type: string
type: array
enableAppArmor:
description: tells the operator whether or not to enable AppArmor
support for this SPOD instance.
Expand Down
1 change: 1 addition & 0 deletions deploy/base/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ rules:
- seccompprofiles
verbs:
- create
- delete
- get
- list
- patch
Expand Down
7 changes: 7 additions & 0 deletions deploy/namespace-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,12 @@ spec:
spec:
description: SPODStatus defines the desired state of SPOD.
properties:
allowedSyscalls:
description: AllowedSyscalls if specified, a list of system calls
which are allowed in seccomp profiles.
items:
type: string
type: array
enableAppArmor:
description: tells the operator whether or not to enable AppArmor
support for this SPOD instance.
Expand Down Expand Up @@ -1505,6 +1511,7 @@ rules:
- seccompprofiles
verbs:
- create
- delete
- get
- list
- patch
Expand Down
7 changes: 7 additions & 0 deletions deploy/openshift-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,12 @@ spec:
spec:
description: SPODStatus defines the desired state of SPOD.
properties:
allowedSyscalls:
description: AllowedSyscalls if specified, a list of system calls
which are allowed in seccomp profiles.
items:
type: string
type: array
enableAppArmor:
description: tells the operator whether or not to enable AppArmor
support for this SPOD instance.
Expand Down Expand Up @@ -1505,6 +1511,7 @@ rules:
- seccompprofiles
verbs:
- create
- delete
- get
- list
- patch
Expand Down
7 changes: 7 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,12 @@ spec:
spec:
description: SPODStatus defines the desired state of SPOD.
properties:
allowedSyscalls:
description: AllowedSyscalls if specified, a list of system calls
which are allowed in seccomp profiles.
items:
type: string
type: array
enableAppArmor:
description: tells the operator whether or not to enable AppArmor
support for this SPOD instance.
Expand Down Expand Up @@ -1505,6 +1511,7 @@ rules:
- seccompprofiles
verbs:
- create
- delete
- get
- list
- patch
Expand Down
17 changes: 17 additions & 0 deletions examples/seccompprofile-allowed-syscalls-change.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: security-profiles-operator.x-k8s.io/v1beta1
kind: SeccompProfile
metadata:
name: profile-allowed-syscalls
annotations:
description: "profile with allowed syscalls"
spec:
defaultAction: SCMP_ACT_ERRNO
architectures:
- SCMP_ARCH_X86_64
syscalls:
- action: SCMP_ACT_ALLOW
names:
- exit
- exit_group
- futex
- nanosleep
58 changes: 58 additions & 0 deletions examples/seccompprofile-allowed-syscalls-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: security-profiles-operator.x-k8s.io/v1beta1
kind: SeccompProfile
metadata:
name: profile-allowed-syscalls
annotations:
description: "profile with allowed syscalls"
spec:
defaultAction: SCMP_ACT_ERRNO
architectures:
- SCMP_ARCH_X86_64
syscalls:
- action: SCMP_ACT_ALLOW
names:
- exit
- exit_group
- futex
- nanosleep
---
apiVersion: security-profiles-operator.x-k8s.io/v1beta1
kind: SeccompProfile
metadata:
name: profile-denied-syscalls
annotations:
description: "profile with denied syscalls"
spec:
defaultAction: SCMP_ACT_ERRNO
architectures:
- SCMP_ARCH_X86_64
syscalls:
- action: SCMP_ACT_ALLOW
names:
- exit
- exit_group
- futex
- nanosleep
- bpf
- action: SCMP_ACT_ERRNO
names:
- acct
- add_key
---
apiVersion: security-profiles-operator.x-k8s.io/v1beta1
kind: SeccompProfile
metadata:
name: profile-allow-all-syscalls
annotations:
description: "profile with all syscalls allowed"
spec:
defaultAction: "SCMP_ACT_ALLOW"
---
apiVersion: security-profiles-operator.x-k8s.io/v1beta1
kind: SeccompProfile
metadata:
name: profile-block-all-syscalls
annotations:
description: "Blocks all syscalls."
spec:
defaultAction: "SCMP_ACT_ERRNO"
18 changes: 18 additions & 0 deletions installation-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Installation using OLM using upstream catalog and bundle](#installation-using-olm-using-upstream-catalog-and-bundle)
- [Set logging verbosity](#set-logging-verbosity)
- [Configure the SELinux type](#configure-the-selinux-type)
- [Restrict the allowed syscalls in seccomp profiles](#restrict-the-allowed-syscalls-in-seccomp-profiles)
- [Create Profile](#create-profile)
- [Apply profile to pod](#apply-profile-to-pod)
- [Base syscalls for a container runtime](#base-syscalls-for-a-container-runtime)
Expand Down Expand Up @@ -151,6 +152,23 @@ The `ds/spod` should now be updated by the manager with the new SELinux type, an
type: unconfined_t
```

## Restrict the allowed syscalls in seccomp profiles

The operator doesn't restrict by default the allowed syscalls in the seccomp profiles. This means that any
syscall can be allowed in a seccomp profile installed via the operator. This can be changed by defining the
list of allowed syscalls in the spod configuration as follows:

```
kubectl -n security-profiles-operator patch spod spod --type merge -p
'{"spec":{"allowedSyscalls": ["exit", "exit_group", "futex", "nanosleep"]}}'
```

From now on, the operator will only install the seccomp profiles which have only a subset of syscalls defined
into the allowed list. All profiles not complying with this rule, it will be rejected.

Also every time when the list of allowed syscalls is modified in the spod configuration, the operator will
automatically identify the already installed profiles which are not compliant and remove them.

## Create Profile

Use the `SeccompProfile` kind to create profiles. Example:
Expand Down
Loading