Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and two reports are only comparable when it matches or the difference is known.

## Unreleased

- Under a user-space kernel such as gVisor, findings that describe what that kernel grants the process (PRIV-001 to PRIV-005, FS-005, FS-006 and RES-001) are reported at info, with their usual severity kept in the evidence, because that kernel is the sandbox's boundary and not the host's. Findings about what the sandbox exposes beyond it keep their severity. The rule does not apply when something is mounted over `/proc` or `/proc/version`. This is an exception, made before 1.0, to the compatibility policy's rule that an existing finding's severity changes only in a new major version.
- Modal's four reports were rescored from the same probe output and now read 46, 39, 39 and 31, where they read 100, 100, 100 and 97. A Modal baseline taken before this change has no `agentsec_version`, so `--baseline` shows the drop without a version note. Nothing fails, since a drop is not a regression.
- The version on `main` is 0.5.0.dev0, so a report written from it says which scorer produced it.
- `docs/COMPATIBILITY.md` states what stays the same from one version to the next: the commands, flags and exit codes, the report format, the scoring and the GitHub Action's inputs and outputs. `tests/test_compatibility.py` checks each of those. `verify`, `submit` and `benchmark` are marked experimental in their help text.
- Reports now record `agentsec_version`, the version that wrote and scored them, beside the probe's `probe_version`. `--baseline` and `agentsec history` note when it differs, as they already did for the probe. JSON Schemas for the blast-radius report and the `assert` result ship in `agentsec/data/`.
- `agentsec --version` prints the package and probe versions.
Expand Down
2 changes: 1 addition & 1 deletion agentsec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""agentsec-pack: adversarial tests for AI agent deployments."""
__version__ = "0.4.0"
__version__ = "0.5.0.dev0"
48 changes: 44 additions & 4 deletions agentsec/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,16 @@ def analyze(probe: dict[str, Any]) -> list[Finding]:

# --- Identity / privilege ----------------------------------------------
if ident.get("user_space_kernel"):
trusted = user_space_kernel(probe) is not None
findings.append(_f("PRIV-007", "The kernel seen here is a user-space kernel", "info", "privilege",
{"kernel": ident["user_space_kernel"]}, ["ASI02"],
"Privilege, capability, seccomp, /proc and resource findings in this report describe what the process "
"gets from this kernel, not from the host's. The score still counts them, so it overstates what they "
"show. This probe does not test whether a process can leave this kernel."))
{"kernel": ident["user_space_kernel"], "applied_to_score": trusted}, ["ASI02"],
("The score treats this kernel as the sandbox boundary. Root, capability, seccomp, no_new_privs, "
"setuid, /proc/sysrq-trigger and resource findings describe what the process gets from this kernel, "
"not from the host's, so they are reported at info. Network, secret, mount and file findings keep "
"their severity. This probe does not test whether a process can leave this kernel.")
if trusted else
("Something is mounted over /proc/version or /proc, so the probe cannot tell whether this kernel is "
"real, and every finding keeps its usual severity.")))
if ident.get("euid") == 0 and not ident.get("in_user_namespace"):
findings.append(_f("PRIV-001", "Agent runs as real root (uid 0, not in a user namespace)", "high", "privilege",
{"euid": 0}, ["ASI03", "ASI05"], "Run as an unprivileged user (docker --user) or inside a user namespace."))
Expand Down Expand Up @@ -392,9 +397,42 @@ def _ev(items):
if res and res.get("memory_max", "max") == "max" and res.get("pids_max", "max") == "max":
findings.append(_f("RES-001", "No memory or PID limits on the sandbox", "low", "resources", dict(res), ["ASI08"],
"docker --memory and --pids-limit."))

# --- A user-space kernel is the boundary --------------------------------
# These findings measure what a process gets from the kernel it talks to. Under a
# user-space kernel that is the sandbox's own kernel, not the host's, so they say
# nothing about the boundary and are reported at info. What the sandbox exposes
# beyond that kernel (network, secrets, mounts, files) keeps its severity.
kernel = user_space_kernel(probe)
if kernel:
for f in findings:
if f.id in KERNEL_SCOPED:
f.evidence = {**f.evidence, "user_space_kernel": kernel, "severity_on_shared_kernel": f.severity}
f.severity = "info"
return findings


# Findings that describe the kernel's grant to the process rather than what the sandbox exposes.
KERNEL_SCOPED = ("PRIV-001", "PRIV-002", "PRIV-003", "PRIV-004", "PRIV-005", "FS-005", "FS-006", "RES-001")


def user_space_kernel(probe: dict[str, Any]) -> str | None:
"""The user-space kernel the probe saw, unless something is mounted over what it read.

The probe reads /proc/version. A bind mount over /proc or /proc/version could make a
shared kernel look like a user-space one, so the claim is not trusted when the
probe's own mount list shows one. Mounts of types the probe does not list, such as
tmpfs, are not seen.
"""
kernel = (probe.get("identity") or {}).get("user_space_kernel")
if not kernel:
return None
mounts = (probe.get("filesystem") or {}).get("bind_mounts") or []
if any(m.get("target") in ("/proc", "/proc/version") for m in mounts if isinstance(m, dict)):
return None
return kernel


def raw_score(findings: list[Finding]) -> int:
"""Uncapped sum of finding weights. Distinguishes two sandboxes that both cap out."""
return sum(f.weight for f in findings)
Expand Down Expand Up @@ -447,6 +485,8 @@ def recommended_flags(findings: list[Finding]) -> list[str]:
"""Ordered, de-duplicated flag suggestions closing the observed findings."""
out: list[str] = []
for f in findings:
if f.severity == "info":
continue
for flag in FINDING_FLAGS.get(f.id, []):
if flag not in out:
out.append(flag)
Expand Down
3 changes: 2 additions & 1 deletion docs/CAPTURING.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,5 @@ settings for both.

`scripts/measure_modal.py` runs the probe in a `modal.Sandbox` under your Modal login, with
the Python that has the `modal` package. Each sandbox is terminated when its probe finishes.
Modal uses gVisor, so read PRIV-007 in the report before comparing the score with anything.
Modal uses gVisor, and PRIV-007 in the report says so. Findings that describe what gVisor's kernel
grants are reported at info, so the score counts what the sandbox exposes beyond gVisor.
5 changes: 3 additions & 2 deletions docs/COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ From 1.0 on, the promises below hold for every 1.x release, and anything that br

Both carry `schema_version` 1. A field can be added without changing it, so a reader should ignore fields it does not know. Removing, renaming or changing the type of a field raises `schema_version`, and only in a new major version. The `probe` block inside a report belongs to the probe. Its contents are versioned by `probe_version`, and only `probe_version` itself is covered here.

**Scoring.** Each finding has a severity with a fixed weight: critical 25, high 15, medium 8, low 3, info 0. The score is the sum of the weights, capped at 100, and `raw_score` is the uncapped sum. A finding ID is never reused or given a different meaning. Most findings have one severity. Two take theirs from the evidence by a fixed rule:
**Scoring.** Each finding has a severity with a fixed weight: critical 25, high 15, medium 8, low 3, info 0. The score is the sum of the weights, capped at 100, and `raw_score` is the uncapped sum. A finding ID is never reused or given a different meaning. Most findings have one severity. These rules set the others from the evidence:

- FS-001 is high when `/`, `/etc`, `/usr/bin` or `/usr/local/bin` is writable, and medium for other system paths.
- PRIV-003 takes the severity of the most dangerous Linux capability in the effective set.
- Under a user-space kernel such as gVisor (PRIV-007), PRIV-001, PRIV-002, PRIV-003, PRIV-004, PRIV-005, FS-005, FS-006 and RES-001 are info, and their evidence records the severity they would have on a shared kernel. They describe what that kernel grants the process, and that kernel is the sandbox's boundary rather than the host's. The rule does not apply when the probe sees something mounted over `/proc` or `/proc/version`. The probe does not list tmpfs mounts, so a tmpfs file mounted there is not seen.

Changing a weight, the severity of an existing finding, or either of those rules needs a new major version.
Changing a weight, the severity of an existing finding, or any of these rules needs a new major version.

**The GitHub Action.** The inputs and outputs in `action.yml` keep their names and meaning. A new input is optional, and its default keeps the earlier behavior.

Expand Down
12 changes: 7 additions & 5 deletions docs/MEASUREMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,14 @@ The 30 points are two things the editor brought in. SEC-007 is the SSH agent, re

| Options | Score | Raw | Network finding |
|---|---:|---:|---|
| None | 100 | 112 | NET-001, every target reached |
| `outbound_domain_allowlist=[pypi.org]` | 100 | 105 | NET-005, only `pypi` reached |
| `outbound_cidr_allowlist=[1.1.1.1/32]` | 100 | 105 | NET-005, only `1.1.1.1` reached |
| `block_network=True` | 97 | 97 | NET-003, nothing reached |
| None | 46 | 46 | NET-001, every target reached |
| `outbound_domain_allowlist=[pypi.org]` | 39 | 39 | NET-005, only `pypi` reached |
| `outbound_cidr_allowlist=[1.1.1.1/32]` | 39 | 39 | NET-005, only `1.1.1.1` reached |
| `block_network=True` | 31 | 31 | NET-003, nothing reached |

**These scores overstate what they show.** Modal runs these containers under gVisor: `/proc/version` reads `4.19.0-gvisor`. The process is root with dangerous capabilities, no seccomp filter and a writable `/proc/sysrq-trigger`, but it gets all of that from gVisor's user-space kernel and not the host's. PRIV-001, PRIV-003, PRIV-004, SEC-004, FS-005 and RES-001 add up to 74 raw points, and the probe does not test whether a process can leave gVisor. The rows would be 38, 31, 31 and 23 without those six, but those totals are not measured scores, and the 100s do not compare with a 100 where those findings describe the host's kernel. The probe now reports this as PRIV-007, without changing the score.
**The score treats gVisor as the boundary.** Modal runs these containers under gVisor: `/proc/version` reads `4.19.0-gvisor`. The process is root with dangerous capabilities, no seccomp filter and a writable `/proc/sysrq-trigger`, but it gets all of that from gVisor's user-space kernel and not the host's. Those findings, PRIV-001, PRIV-003, PRIV-004, FS-005 and RES-001, are reported at info with their usual severity kept in the evidence, and count 0. What the sandbox exposes beyond gVisor keeps its severity: the network, PID 1's environment (SEC-004), the writable system paths of the container's own filesystem (FS-001) and the read-write mounts `/dev` and `/__modal/mounts` (FS-003). The score does not measure gVisor's own strength, and the probe does not test whether a process can leave it.

The reports were rescored on 2026-11-10 by agentsec 0.5.0.dev0 from the same probe output, which is unchanged. Scored before this rule, the rows read 100, 100, 100 and 97, because 66 raw points described gVisor's kernel. The rule applies only when nothing is mounted over `/proc` or `/proc/version`, since a process that could mount there could make a shared kernel look like gVisor. The probe does not list tmpfs mounts, so a tmpfs file mounted there would not be seen.

**The network rows are the useful part, and they found a bug in the probe.** Under the domain allowlist, TCP connections to any host on port 443 succeed. Probe 0.6.0 counted that as reached and reported open internet. A direct check showed otherwise: `pypi.org` answered HTTP 200, the other four hosts tried were reset during TLS, and port 80 timed out. Probe 0.7.0 counts a connection refused at TLS as not reached, and tries `example.com` directly as a control. Any earlier report of a sandbox that filters this way would have overstated its egress. Earlier reports were not re-run.

Expand Down
8 changes: 5 additions & 3 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ that is not the implementer's to make.
The rule that governs every measurement item still applies: a number goes in
only from a run that was actually made, and says how it was made.

Last revised 2026-11-07.
Last revised 2026-11-10.

## Next

Expand All @@ -33,8 +33,6 @@ Any result that contradicts a vendor's documentation is raised with the vendor b

Still open: E2B, Daytona and Docker's own sandboxes. Each must say what it does not reproduce, and each recipe must come from a live run. *Needs the maintainer's accounts for E2B and Daytona, and a machine with Docker Desktop.*

**Scoring under a user-space kernel.** Modal's 74 raw points for root, capabilities and `/proc` describe gVisor's kernel, and the score still counts them, so it does not compare with a score where those findings describe the host's. PRIV-007 flags this. Done when the score separates the two, or the docs state why it does not. Needs a way to show what a process can do past that kernel, not only that the kernel is there.

**What an editor forwards.** A dev container with VS Code attached adds git credential and IPC sockets that the probe does not test. Done when the probe says whether a command can get a credential through them, from a run with a throwaway credential.

### 4. A community benchmark from opt-in submissions
Expand All @@ -59,6 +57,10 @@ The rules `agentsec benchmark` enforces:

## Done

**Unreleased, on main**
- Scoring under a user-space kernel: findings that describe what gVisor's kernel grants are reported at info, so Modal's scores count what the sandbox exposes beyond gVisor.
- A written compatibility policy, with a test for each promise, and JSON Schemas for reports.

**0.4.0, 2026-11-07**
- Probe 0.7.0, which no longer reports an allowlist that filters at TLS as open internet, and flags gVisor.
- Antigravity CLI's sandbox and Gemini CLI measured, with a local stand-in for the model.
Expand Down
59 changes: 33 additions & 26 deletions examples/modal/modal-sandbox-block-network.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"generated_at": 1793944869,
"agentsec_version": "0.5.0.dev0",
"generated_at": 1794296285,
"label": "modal-sandbox-block-network",
"probe": {
"duration_ms": 28,
Expand Down Expand Up @@ -344,11 +345,11 @@
"schema_version": 1,
"summary": {
"by_severity": {
"critical": 1,
"high": 3,
"info": 4,
"low": 1,
"medium": 3
"critical": 0,
"high": 1,
"info": 9,
"low": 0,
"medium": 2
},
"finding_count": 12,
"findings": [
Expand All @@ -368,28 +369,31 @@
{
"category": "privilege",
"evidence": {
"applied_to_score": true,
"kernel": "gvisor"
},
"id": "PRIV-007",
"owasp": [
"ASI02"
],
"remediation": "Privilege, capability, seccomp, /proc and resource findings in this report describe what the process gets from this kernel, not from the host's. The score still counts them, so it overstates what they show. This probe does not test whether a process can leave this kernel.",
"remediation": "The score treats this kernel as the sandbox boundary. Root, capability, seccomp, no_new_privs, setuid, /proc/sysrq-trigger and resource findings describe what the process gets from this kernel, not from the host's, so they are reported at info. Network, secret, mount and file findings keep their severity. This probe does not test whether a process can leave this kernel.",
"severity": "info",
"title": "The kernel seen here is a user-space kernel"
},
{
"category": "privilege",
"evidence": {
"euid": 0
"euid": 0,
"severity_on_shared_kernel": "high",
"user_space_kernel": "gvisor"
},
"id": "PRIV-001",
"owasp": [
"ASI03",
"ASI05"
],
"remediation": "Run as an unprivileged user (docker --user) or inside a user namespace.",
"severity": "high",
"severity": "info",
"title": "Agent runs as real root (uid 0, not in a user namespace)"
},
{
Expand All @@ -402,28 +406,32 @@
"CAP_SETUID",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE"
]
],
"severity_on_shared_kernel": "high",
"user_space_kernel": "gvisor"
},
"id": "PRIV-003",
"owasp": [
"ASI05",
"ASI03"
],
"remediation": "docker --cap-drop ALL, then add back only what the workload needs.",
"severity": "high",
"severity": "info",
"title": "Dangerous Linux capabilities in the effective set"
},
{
"category": "privilege",
"evidence": {
"seccomp_mode": 0
"seccomp_mode": 0,
"severity_on_shared_kernel": "medium",
"user_space_kernel": "gvisor"
},
"id": "PRIV-004",
"owasp": [
"ASI05"
],
"remediation": "Docker and podman apply a default seccomp profile unless you pass --security-opt seccomp=unconfined; seeing mode 0 means the sandbox is running without one. bubblewrap needs --seccomp with a compiled BPF filter.",
"severity": "medium",
"severity": "info",
"title": "No seccomp filter applied"
},
{
Expand Down Expand Up @@ -521,43 +529,42 @@
},
{
"category": "filesystem",
"evidence": {},
"evidence": {
"severity_on_shared_kernel": "critical",
"user_space_kernel": "gvisor"
},
"id": "FS-005",
"owasp": [
"ASI05"
],
"remediation": "Mask /proc/sysrq-trigger; do not run privileged.",
"severity": "critical",
"severity": "info",
"title": "/proc/sysrq-trigger writable"
},
{
"category": "resources",
"evidence": {
"memory_limit_v1": "353061625856"
"memory_limit_v1": "353061625856",
"severity_on_shared_kernel": "low",
"user_space_kernel": "gvisor"
},
"id": "RES-001",
"owasp": [
"ASI08"
],
"remediation": "docker --memory and --pids-limit.",
"severity": "low",
"severity": "info",
"title": "No memory or PID limits on the sandbox"
}
],
"raw_score": 97,
"raw_score": 31,
"recommended_flags": [
"--user 65534:65534",
"--cap-drop ALL",
"(do not disable the engine's default seccomp profile)",
"(own PID namespace: avoid --pid=host)",
"--read-only",
"--tmpfs /tmp",
"(mount the working tree only, :ro where possible)",
"(do not run --privileged)",
"--pids-limit 256",
"--memory 512m"
"(mount the working tree only, :ro where possible)"
],
"score": 97
"score": 31
},
"target": {
"how": "modal client 1.5.3, modal.Sandbox.create with Image.debian_slim(python_version=3.12), block_network=True. The probe ran through Sandbox.exec, by scripts/measure_modal.py. No agent was involved, and the container holds no personal credentials. Modal runs this under gVisor, so privilege, capability, seccomp, /proc and resource findings describe gVisor's kernel, not the host's, and escaping gVisor was not tested.",
Expand Down
Loading
Loading