You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add CIS sysctls, migrate prctl to x/sys/unix, add SetNoNewPrivs
Address remaining security review findings:
- Add four CIS-recommended sysctls: perf_event_paranoid,
yama.ptrace_scope, bpf_jit_harden, and sysrq
- Replace raw syscall.Syscall prctl calls with unix.Prctl()
from golang.org/x/sys/unix (already an indirect dep)
- Add SetNoNewPrivs() helper for PR_SET_NO_NEW_PRIVS
- Update SECURITY.md with new sysctls, process privilege
restriction, and filesystem hardening documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/SECURITY.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,6 +229,10 @@ aborting boot, because not all kernels support every sysctl.
229
229
|`kernel.kptr_restrict`|`2`| Hide kernel pointers from all users. Prevents information leaks that aid exploit development. |
230
230
|`kernel.dmesg_restrict`|`1`| Restrict `dmesg` to privileged users. Prevents unprivileged processes from reading kernel log messages that may contain sensitive addresses or operations. |
231
231
|`kernel.unprivileged_bpf_disabled`|`1`| Disable unprivileged BPF. Prevents unprivileged users from loading BPF programs, which have historically been a source of kernel privilege escalation vulnerabilities. |
232
+
|`kernel.perf_event_paranoid`|`3`| Disallow all perf events for unprivileged users. Prevents unprivileged access to performance counters, which can be used for side-channel attacks. |
233
+
|`kernel.yama.ptrace_scope`|`2`| Restrict ptrace to `CAP_SYS_PTRACE` holders. Prevents unprivileged processes from attaching to other processes to inspect memory or inject code. |
234
+
|`net.core.bpf_jit_harden`|`2`| Harden BPF JIT against spraying attacks. Forces constant blinding and disables JIT kallsyms exposure. |
235
+
|`kernel.sysrq`|`0`| Disable magic SysRq key. Prevents unprivileged users from triggering kernel debugging and recovery commands. |
232
236
233
237
### Capability bounding set
234
238
@@ -245,6 +249,32 @@ For a typical SSH-based guest, the minimal keep set is:
245
249
|`CAP_SETGID`| 6 | sshd group switching |
246
250
|`CAP_NET_BIND_SERVICE`| 10 | Binding port 22 (privileged port) |
247
251
252
+
### Process privilege restriction
253
+
254
+
`SetNoNewPrivs()` sets the `PR_SET_NO_NEW_PRIVS` bit on the calling
255
+
process. Once set, the process and all descendants (via fork/exec)
256
+
cannot gain new privileges through `execve` — setuid binaries run
257
+
without elevation and file capabilities are ignored.
258
+
259
+
This is intended to be called after all privileged operations are
0 commit comments