Skip to content

Commit a10a600

Browse files
koki-developclaude
andcommitted
fix: add nosuid/nodev to /etc/alternatives mount and block pidfd_getfd syscall
Address security audit findings N-1 and S-1: - N-1: add missing nosuid and nodev flags to /etc/alternatives bind mount for consistency with other bind mounts - S-1: block pidfd_getfd syscall in seccomp policy to prevent cross-process FD duplication within the PID namespace Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 51f879d commit a10a600

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

e2e/tests/security/bind_mount_flags.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,23 @@ tests:
5959
exit_code: 0
6060
status: "OK"
6161
signal: null
62+
63+
- name: "/etc/alternatives is mounted with nosuid and nodev"
64+
requests:
65+
- input:
66+
runtime: bash
67+
files:
68+
- name: main.sh
69+
type: plain
70+
content: |
71+
grep ' /etc/alternatives ' /proc/mounts | tr ' ' '\n' | sed -n '4p' | tr ',' '\n' | grep -E '^(nosuid|nodev)$' | sort
72+
output:
73+
status: 200
74+
body:
75+
run:
76+
stdout: "nodev\nnosuid\n"
77+
stderr: ""
78+
output: "nodev\nnosuid\n"
79+
exit_code: 0
80+
status: "OK"
81+
signal: null

e2e/tests/security/seccomp_process.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,23 @@ tests:
144144
exit_code: 159
145145
status: "SIGNAL"
146146
signal: "SIGSYS"
147+
148+
- name: "pidfd_getfd is blocked by seccomp (ruby)"
149+
requests:
150+
- input:
151+
runtime: ruby
152+
files:
153+
- name: main.rb
154+
type: plain
155+
content: |
156+
syscall(438, -1, 0, 0)
157+
output:
158+
status: 200
159+
body:
160+
run:
161+
stdout: ""
162+
stderr: ""
163+
output: ""
164+
exit_code: 159
165+
status: "SIGNAL"
166+
signal: "SIGSYS"

internal/sandbox/configs/nsjail.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ mount {
135135
src: "/etc/alternatives"
136136
dst: "/etc/alternatives"
137137
is_bind: true
138+
nosuid: true
139+
nodev: true
138140
}
139141

140142
# Device files commonly opened by sandboxed programs.

internal/sandbox/configs/seccomp.kafel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ POLICY blocked {
111111
// process_vm_readv/process_vm_writev.
112112
process_madvise,
113113

114+
// -- Cross-process FD duplication --
115+
// pidfd_getfd (Linux 5.6+): can duplicate file descriptors from other
116+
// processes within the PID namespace, bypassing normal permission checks.
117+
// pidfd_open and pidfd_send_signal are intentionally allowed as they are
118+
// constrained by PID namespace and provide no additional capability
119+
// beyond kill()/waitpid().
120+
pidfd_getfd,
121+
114122
// -- Kernel keyring --
115123
// The kernel keyring is not namespaced and can leak information between
116124
// containers. Also used in kernel exploit chains.

0 commit comments

Comments
 (0)