Skip to content

Commit 491af97

Browse files
committed
Remove PR_SET_SECCOMP from blocked prctl options
Signed-off-by: Cong Wang <cwang@multikernel.io>
1 parent 427d7c6 commit 491af97

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/sandlock/_seccomp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@
9090
# Dangerous prctl(2) options — these allow a sandboxed process to
9191
# weaken its own confinement.
9292
PR_SET_DUMPABLE = 4 # re-enable /proc/pid/mem writes
93-
PR_SET_SECCOMP_OPT = 22 # change seccomp mode from within sandbox
9493
PR_SET_SECUREBITS = 28 # alter LSM security bits
9594
PR_SET_PTRACER = 0x59616d61 # allow arbitrary ptrace attach
95+
# Note: PR_SET_SECCOMP is intentionally NOT blocked — seccomp filters
96+
# can only tighten (never loosen) when NO_NEW_PRIVS is set, and the
97+
# sandbox itself needs to stack filters via prctl(PR_SET_SECCOMP).
9698
_DANGEROUS_PRCTL_OPS = (
9799
PR_SET_DUMPABLE,
98-
PR_SET_SECCOMP_OPT,
99100
PR_SET_SECUREBITS,
100101
PR_SET_PTRACER,
101102
)

tests/test_seccomp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ def test_prctl_in_syscall_map(self):
114114
assert "prctl" in _SYSCALL_NR
115115

116116
def test_dangerous_prctl_ops_defined(self):
117-
assert len(_DANGEROUS_PRCTL_OPS) == 4
117+
assert len(_DANGEROUS_PRCTL_OPS) == 3
118118
assert 4 in _DANGEROUS_PRCTL_OPS # PR_SET_DUMPABLE
119-
assert 22 in _DANGEROUS_PRCTL_OPS # PR_SET_SECCOMP
120119
assert 28 in _DANGEROUS_PRCTL_OPS # PR_SET_SECUREBITS
121120
assert 0x59616d61 in _DANGEROUS_PRCTL_OPS # PR_SET_PTRACER
121+
assert 22 not in _DANGEROUS_PRCTL_OPS # PR_SET_SECCOMP — safe under NO_NEW_PRIVS
122122

123123

124124
class TestBuildFilter:

0 commit comments

Comments
 (0)