Skip to content

Commit 7fe0a36

Browse files
CopilotMossaka
andauthored
feat: add no-new-privileges and ptrace syscall blocking (#139)
* Initial plan * feat(security): add no-new-privileges and ptrace syscall blocking Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
1 parent dbf9279 commit 7fe0a36

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

containers/agent/seccomp-profile.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
"SCMP_ARCH_AARCH64"
77
],
88
"syscalls": [
9+
{
10+
"names": [
11+
"ptrace",
12+
"process_vm_readv",
13+
"process_vm_writev"
14+
],
15+
"action": "SCMP_ACT_ERRNO",
16+
"errnoRet": 1,
17+
"comment": "Block process inspection/modification"
18+
},
919
{
1020
"names": [
1121
"kexec_load",

src/docker-manager.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ describe('docker-manager', () => {
206206
// Verify seccomp profile is configured
207207
expect(agent.security_opt).toContain('seccomp=/tmp/awf-test/seccomp-profile.json');
208208

209+
// Verify no-new-privileges is enabled to prevent privilege escalation
210+
expect(agent.security_opt).toContain('no-new-privileges:true');
211+
209212
// Verify resource limits
210213
expect(agent.mem_limit).toBe('4g');
211214
expect(agent.memswap_limit).toBe('4g');

src/docker-manager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,11 @@ export function generateDockerCompose(
326326
'SYS_RAWIO', // Prevents raw I/O access
327327
'MKNOD', // Prevents device node creation
328328
],
329-
// Apply seccomp profile to restrict dangerous syscalls
330-
security_opt: [`seccomp=${config.workDir}/seccomp-profile.json`],
329+
// Apply seccomp profile and no-new-privileges to restrict dangerous syscalls and prevent privilege escalation
330+
security_opt: [
331+
'no-new-privileges:true',
332+
`seccomp=${config.workDir}/seccomp-profile.json`,
333+
],
331334
// Resource limits to prevent DoS attacks (conservative defaults)
332335
mem_limit: '4g', // 4GB memory limit
333336
memswap_limit: '4g', // No swap (same as mem_limit)

0 commit comments

Comments
 (0)