Skip to content

Commit 0012a57

Browse files
committed
docs(security): reframe the memory cap as operational, not a security boundary
memory_limit_mb prevents a runaway jailed allocation from OOM-killing the host; it is not part of the threat model (which is confidentiality + integrity, not availability). Move it out of the threat-model framing so its per-process/ non-fork-bomb incompleteness reads as by-design, not a gap to close. No behavior change.
1 parent 02eced0 commit 0012a57

2 files changed

Lines changed: 12 additions & 24 deletions

File tree

‎docs/security.md‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,14 @@ where user namespaces are available) the jail:
181181
- Sets `NO_NEW_PRIVS`: the kernel then ignores setuid bits, so `sudo`
182182
and every setuid binary cannot escalate.
183183
- Then `execve`s the requested binary, SIGKILLing the jail's whole
184-
process group at the policy's wall-clock timeout. Two resource limits
185-
apply: that timeout, and a per-process memory cap
186-
(`[sandbox].memory_limit_mb`, default 4096 MiB, `0` disables) set as
187-
`RLIMIT_DATA` on the child before exec and inherited by its
188-
descendants. `RLIMIT_DATA` rather than `RLIMIT_AS` so runtimes that
189-
reserve large address space without committing it (V8, JVM, ASAN)
190-
keep working; a runaway allocation gets ENOMEM (a `MemoryError` the
191-
agent handles as an ordinary failed command) instead of driving the
192-
host to the OOM killer. The cap is per process, not per tree
193-
(bounding the tree takes a cgroup, which an unprivileged launcher
194-
cannot assume): it bounds the common single-runaway case, not a
195-
deliberate fork bomb. Raising the hard limit back needs
196-
`CAP_SYS_RESOURCE` in the initial user namespace, which a jailed
197-
child never has. The jail does not call `capset` (under `strict` the
184+
process group at the policy's wall-clock timeout. A per-process memory
185+
cap (`[sandbox].memory_limit_mb`, default 4096 MiB, `0` disables) is set
186+
as `RLIMIT_DATA` on the child before exec (not `RLIMIT_AS`, so runtimes
187+
that reserve large address space without committing it -- V8, JVM, ASAN
188+
-- keep working). It is an operational guardrail, NOT part of the threat
189+
model: it stops a single runaway allocation from driving the host to the
190+
OOM killer. Its incompleteness (per process, not per tree; no fork-bomb
191+
bound) is by design, not a security gap. The jail does not call `capset` (under `strict` the
198192
child's namespaced-root already maps to your unprivileged uid; under
199193
`hardened` the child keeps the invoking user's capabilities, none for
200194
a normal user).
@@ -632,13 +626,6 @@ not to bound what an attacker can do.
632626
`agent_network = "open"`.
633627
- **seccomp** is required by the jail; on rare hardened kernels that
634628
block seccomp from unprivileged callers, the jail fails closed.
635-
- **Memory cap is per process, not per tree**: `memory_limit_mb` is an
636-
rlimit, so N concurrent children can each commit the cap; a deliberate
637-
fork bomb is out of its scope. For a hard whole-tree bound, run agent6
638-
under a cgroup (`systemd-run -p MemoryMax=…`). Under `strict` the
639-
in-jail `/tmp` tmpfs is capped (64 MB); under `hardened` the child
640-
writes to the host `/tmp`, which on tmpfs hosts is RAM the rlimit does
641-
not count.
642629
- **Devcontainers**: the jail's `hardened` profile is what you get
643630
inside Docker / VS Code dev containers. The container itself becomes
644631
the FS blast radius. Network restrictions still apply via the

‎src/agent6/config/model.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,10 @@ class SandboxConfig(BaseModel):
394394
# with ENOMEM (Python MemoryError) that the agent sees as an ordinary
395395
# failed command, instead of driving the host to the OOM killer. The cap
396396
# is per PROCESS, not per tree; it bounds the common single-runaway case,
397-
# not a fork bomb. 0 disables (opt-out, like every widening). No effect
398-
# under profile `none` (no confinement at all there). Raise it when a
399-
# legitimate build or test suite needs more than 4 GiB in one process.
397+
# not a fork bomb. An operational guardrail, not a security control. 0
398+
# disables. No effect under profile `none` (no confinement at all there).
399+
# Raise it when a legitimate build or test suite needs more than 4 GiB in
400+
# one process.
400401
memory_limit_mb: int = Field(default=4096, ge=0)
401402
# Extra egress destinations the AGENT process may reach under
402403
# `agent_network = "providers"`, on top of the configured provider

0 commit comments

Comments
 (0)