diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b05f2..7171ad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/agentsec/__init__.py b/agentsec/__init__.py index f4a76c0..9aac781 100644 --- a/agentsec/__init__.py +++ b/agentsec/__init__.py @@ -1,2 +1,2 @@ """agentsec-pack: adversarial tests for AI agent deployments.""" -__version__ = "0.4.0" +__version__ = "0.5.0.dev0" diff --git a/agentsec/scoring.py b/agentsec/scoring.py index 648e831..8735957 100644 --- a/agentsec/scoring.py +++ b/agentsec/scoring.py @@ -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.")) @@ -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) @@ -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) diff --git a/docs/CAPTURING.md b/docs/CAPTURING.md index 5dca97e..825ef84 100644 --- a/docs/CAPTURING.md +++ b/docs/CAPTURING.md @@ -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. diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index 418cd8e..7f09757 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -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. diff --git a/docs/MEASUREMENTS.md b/docs/MEASUREMENTS.md index f43db56..1e4b2ac 100644 --- a/docs/MEASUREMENTS.md +++ b/docs/MEASUREMENTS.md @@ -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. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index f13b784..a29961d 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -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 @@ -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 @@ -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. diff --git a/examples/modal/modal-sandbox-block-network.json b/examples/modal/modal-sandbox-block-network.json index 1db3ce9..f2bd4d2 100644 --- a/examples/modal/modal-sandbox-block-network.json +++ b/examples/modal/modal-sandbox-block-network.json @@ -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, @@ -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": [ @@ -368,20 +369,23 @@ { "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": [ @@ -389,7 +393,7 @@ "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)" }, { @@ -402,7 +406,9 @@ "CAP_SETUID", "CAP_SYS_CHROOT", "CAP_SYS_PTRACE" - ] + ], + "severity_on_shared_kernel": "high", + "user_space_kernel": "gvisor" }, "id": "PRIV-003", "owasp": [ @@ -410,20 +416,22 @@ "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" }, { @@ -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.", diff --git a/examples/modal/modal-sandbox-block-network.md b/examples/modal/modal-sandbox-block-network.md index 0f81b02..758fa57 100644 --- a/examples/modal/modal-sandbox-block-network.md +++ b/examples/modal/modal-sandbox-block-network.md @@ -1,7 +1,7 @@ # Sandbox blast radius: modal-sandbox-block-network -**Score: 97 / 100** (0 = fully contained; higher = larger blast radius) -Findings: 12 (critical 1, high 3, medium 3, low 1) +**Score: 31 / 100** (0 = fully contained; higher = larger blast radius) +Findings: 12 (critical 0, high 1, medium 2, low 0) ## Target (reproduce with this) - kind: `captured` @@ -17,22 +17,22 @@ Findings: 12 (critical 1, high 3, medium 3, low 1) - fix: No action: nothing the probe tried could leave this sandbox over the network. ### PRIV-007 · INFO · The kernel seen here is a user-space kernel -- evidence: `{'kernel': 'gvisor'}` +- evidence: `{'kernel': 'gvisor', 'applied_to_score': True}` - OWASP agentic: ASI02 Tool Misuse & Exploitation -- fix: 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. +- fix: 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. -### PRIV-001 · HIGH · Agent runs as real root (uid 0, not in a user namespace) -- evidence: `{'euid': 0}` +### PRIV-001 · INFO · Agent runs as real root (uid 0, not in a user namespace) +- evidence: `{'euid': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI03 Agent Identity & Privilege Abuse, ASI05 Unexpected Code Execution - fix: Run as an unprivileged user (docker --user) or inside a user namespace. -### PRIV-003 · HIGH · Dangerous Linux capabilities in the effective set -- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE']}` +### PRIV-003 · INFO · Dangerous Linux capabilities in the effective set +- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE'], 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI05 Unexpected Code Execution, ASI03 Agent Identity & Privilege Abuse - fix: docker --cap-drop ALL, then add back only what the workload needs. -### PRIV-004 · MEDIUM · No seccomp filter applied -- evidence: `{'seccomp_mode': 0}` +### PRIV-004 · INFO · No seccomp filter applied +- evidence: `{'seccomp_mode': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'medium'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: 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. @@ -60,12 +60,13 @@ Findings: 12 (critical 1, high 3, medium 3, low 1) - OWASP agentic: ASI02 Tool Misuse & Exploitation, ASI05 Unexpected Code Execution - fix: Mount only the working tree, read-only where possible; never mount the host root. -### FS-005 · CRITICAL · /proc/sysrq-trigger writable +### FS-005 · INFO · /proc/sysrq-trigger writable +- evidence: `{'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'critical'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: Mask /proc/sysrq-trigger; do not run privileged. -### RES-001 · LOW · No memory or PID limits on the sandbox -- evidence: `{'memory_limit_v1': '353061625856'}` +### RES-001 · INFO · No memory or PID limits on the sandbox +- evidence: `{'memory_limit_v1': '353061625856', 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'low'}` - OWASP agentic: ASI08 Cascading Agent Failures - fix: docker --memory and --pids-limit. @@ -76,16 +77,10 @@ This target is not a container, so the flags below are the docker/podman spellin A starting point, not a policy: each entry closes at least one finding observed here. Anything in parentheses is a change to how the sandbox is composed rather than a flag. A workload that genuinely needs the network or a dropped capability will break under these, and that is the operator's call to make deliberately. ``` ---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 ``` ## What the probe does not do diff --git a/examples/modal/modal-sandbox-cidr-allowlist.json b/examples/modal/modal-sandbox-cidr-allowlist.json index d8b8fbc..e9f2860 100644 --- a/examples/modal/modal-sandbox-cidr-allowlist.json +++ b/examples/modal/modal-sandbox-cidr-allowlist.json @@ -1,5 +1,6 @@ { - "generated_at": 1793944888, + "agentsec_version": "0.5.0.dev0", + "generated_at": 1794296285, "label": "modal-sandbox-cidr-allowlist", "probe": { "duration_ms": 12069, @@ -344,11 +345,11 @@ "schema_version": 1, "summary": { "by_severity": { - "critical": 1, - "high": 3, - "info": 3, - "low": 1, - "medium": 4 + "critical": 0, + "high": 1, + "info": 8, + "low": 0, + "medium": 3 }, "finding_count": 12, "findings": [ @@ -376,20 +377,23 @@ { "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": [ @@ -397,7 +401,7 @@ "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)" }, { @@ -410,7 +414,9 @@ "CAP_SETUID", "CAP_SYS_CHROOT", "CAP_SYS_PTRACE" - ] + ], + "severity_on_shared_kernel": "high", + "user_space_kernel": "gvisor" }, "id": "PRIV-003", "owasp": [ @@ -418,20 +424,22 @@ "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" }, { @@ -529,44 +537,43 @@ }, { "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": "728677150720" + "memory_limit_v1": "728677150720", + "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": 105, + "raw_score": 39, "recommended_flags": [ "(keep the proxy allowlist to the hosts the agent needs)", - "--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": 100 + "score": 39 }, "target": { "how": "modal client 1.5.3, modal.Sandbox.create with Image.debian_slim(python_version=3.12), outbound_cidr_allowlist=[1.1.1.1/32]. 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.", diff --git a/examples/modal/modal-sandbox-cidr-allowlist.md b/examples/modal/modal-sandbox-cidr-allowlist.md index 8c779f7..1db791e 100644 --- a/examples/modal/modal-sandbox-cidr-allowlist.md +++ b/examples/modal/modal-sandbox-cidr-allowlist.md @@ -1,7 +1,7 @@ # Sandbox blast radius: modal-sandbox-cidr-allowlist -**Score: 100 / 100** (capped; raw 105) (0 = fully contained; higher = larger blast radius) -Findings: 12 (critical 1, high 3, medium 4, low 1) +**Score: 39 / 100** (0 = fully contained; higher = larger blast radius) +Findings: 12 (critical 0, high 1, medium 3, low 0) ## Target (reproduce with this) - kind: `captured` @@ -17,22 +17,22 @@ Findings: 12 (critical 1, high 3, medium 4, low 1) - fix: These hosts were reached directly and the control host, example.com, was not, so the network is filtered and these are what an injected command can reach at least. Keep the list to what the agent needs; a host that accepts uploads, such as a code host or a package index, is an exfiltration route. ### PRIV-007 · INFO · The kernel seen here is a user-space kernel -- evidence: `{'kernel': 'gvisor'}` +- evidence: `{'kernel': 'gvisor', 'applied_to_score': True}` - OWASP agentic: ASI02 Tool Misuse & Exploitation -- fix: 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. +- fix: 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. -### PRIV-001 · HIGH · Agent runs as real root (uid 0, not in a user namespace) -- evidence: `{'euid': 0}` +### PRIV-001 · INFO · Agent runs as real root (uid 0, not in a user namespace) +- evidence: `{'euid': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI03 Agent Identity & Privilege Abuse, ASI05 Unexpected Code Execution - fix: Run as an unprivileged user (docker --user) or inside a user namespace. -### PRIV-003 · HIGH · Dangerous Linux capabilities in the effective set -- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE']}` +### PRIV-003 · INFO · Dangerous Linux capabilities in the effective set +- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE'], 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI05 Unexpected Code Execution, ASI03 Agent Identity & Privilege Abuse - fix: docker --cap-drop ALL, then add back only what the workload needs. -### PRIV-004 · MEDIUM · No seccomp filter applied -- evidence: `{'seccomp_mode': 0}` +### PRIV-004 · INFO · No seccomp filter applied +- evidence: `{'seccomp_mode': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'medium'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: 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. @@ -60,12 +60,13 @@ Findings: 12 (critical 1, high 3, medium 4, low 1) - OWASP agentic: ASI02 Tool Misuse & Exploitation, ASI05 Unexpected Code Execution - fix: Mount only the working tree, read-only where possible; never mount the host root. -### FS-005 · CRITICAL · /proc/sysrq-trigger writable +### FS-005 · INFO · /proc/sysrq-trigger writable +- evidence: `{'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'critical'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: Mask /proc/sysrq-trigger; do not run privileged. -### RES-001 · LOW · No memory or PID limits on the sandbox -- evidence: `{'memory_limit_v1': '728677150720'}` +### RES-001 · INFO · No memory or PID limits on the sandbox +- evidence: `{'memory_limit_v1': '728677150720', 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'low'}` - OWASP agentic: ASI08 Cascading Agent Failures - fix: docker --memory and --pids-limit. @@ -77,16 +78,10 @@ A starting point, not a policy: each entry closes at least one finding observed ``` (keep the proxy allowlist to the hosts the agent needs) ---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 ``` ## What the probe does not do diff --git a/examples/modal/modal-sandbox-default.json b/examples/modal/modal-sandbox-default.json index 4165f85..9e160ca 100644 --- a/examples/modal/modal-sandbox-default.json +++ b/examples/modal/modal-sandbox-default.json @@ -1,5 +1,6 @@ { - "generated_at": 1793944868, + "agentsec_version": "0.5.0.dev0", + "generated_at": 1794296286, "label": "modal-sandbox-default", "probe": { "duration_ms": 2237, @@ -344,11 +345,11 @@ "schema_version": 1, "summary": { "by_severity": { - "critical": 1, - "high": 4, - "info": 3, - "low": 1, - "medium": 3 + "critical": 0, + "high": 2, + "info": 8, + "low": 0, + "medium": 2 }, "finding_count": 12, "findings": [ @@ -374,20 +375,23 @@ { "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": [ @@ -395,7 +399,7 @@ "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)" }, { @@ -408,7 +412,9 @@ "CAP_SETUID", "CAP_SYS_CHROOT", "CAP_SYS_PTRACE" - ] + ], + "severity_on_shared_kernel": "high", + "user_space_kernel": "gvisor" }, "id": "PRIV-003", "owasp": [ @@ -416,20 +422,22 @@ "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" }, { @@ -527,44 +535,43 @@ }, { "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": "353059282944" + "memory_limit_v1": "353059282944", + "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": 112, + "raw_score": 46, "recommended_flags": [ "--network none", - "--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": 100 + "score": 46 }, "target": { "how": "modal client 1.5.3, modal.Sandbox.create with Image.debian_slim(python_version=3.12), no other options. 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.", diff --git a/examples/modal/modal-sandbox-default.md b/examples/modal/modal-sandbox-default.md index 405e926..97491cb 100644 --- a/examples/modal/modal-sandbox-default.md +++ b/examples/modal/modal-sandbox-default.md @@ -1,7 +1,7 @@ # Sandbox blast radius: modal-sandbox-default -**Score: 100 / 100** (capped; raw 112) (0 = fully contained; higher = larger blast radius) -Findings: 12 (critical 1, high 4, medium 3, low 1) +**Score: 46 / 100** (0 = fully contained; higher = larger blast radius) +Findings: 12 (critical 0, high 2, medium 2, low 0) ## Target (reproduce with this) - kind: `captured` @@ -17,22 +17,22 @@ Findings: 12 (critical 1, high 4, medium 3, low 1) - fix: Run the agent with no network (docker --network none) or an allowlisting egress proxy. ### PRIV-007 · INFO · The kernel seen here is a user-space kernel -- evidence: `{'kernel': 'gvisor'}` +- evidence: `{'kernel': 'gvisor', 'applied_to_score': True}` - OWASP agentic: ASI02 Tool Misuse & Exploitation -- fix: 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. +- fix: 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. -### PRIV-001 · HIGH · Agent runs as real root (uid 0, not in a user namespace) -- evidence: `{'euid': 0}` +### PRIV-001 · INFO · Agent runs as real root (uid 0, not in a user namespace) +- evidence: `{'euid': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI03 Agent Identity & Privilege Abuse, ASI05 Unexpected Code Execution - fix: Run as an unprivileged user (docker --user) or inside a user namespace. -### PRIV-003 · HIGH · Dangerous Linux capabilities in the effective set -- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE']}` +### PRIV-003 · INFO · Dangerous Linux capabilities in the effective set +- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE'], 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI05 Unexpected Code Execution, ASI03 Agent Identity & Privilege Abuse - fix: docker --cap-drop ALL, then add back only what the workload needs. -### PRIV-004 · MEDIUM · No seccomp filter applied -- evidence: `{'seccomp_mode': 0}` +### PRIV-004 · INFO · No seccomp filter applied +- evidence: `{'seccomp_mode': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'medium'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: 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. @@ -60,12 +60,13 @@ Findings: 12 (critical 1, high 4, medium 3, low 1) - OWASP agentic: ASI02 Tool Misuse & Exploitation, ASI05 Unexpected Code Execution - fix: Mount only the working tree, read-only where possible; never mount the host root. -### FS-005 · CRITICAL · /proc/sysrq-trigger writable +### FS-005 · INFO · /proc/sysrq-trigger writable +- evidence: `{'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'critical'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: Mask /proc/sysrq-trigger; do not run privileged. -### RES-001 · LOW · No memory or PID limits on the sandbox -- evidence: `{'memory_limit_v1': '353059282944'}` +### RES-001 · INFO · No memory or PID limits on the sandbox +- evidence: `{'memory_limit_v1': '353059282944', 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'low'}` - OWASP agentic: ASI08 Cascading Agent Failures - fix: docker --memory and --pids-limit. @@ -77,16 +78,10 @@ A starting point, not a policy: each entry closes at least one finding observed ``` --network none ---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 ``` ## What the probe does not do diff --git a/examples/modal/modal-sandbox-domain-allowlist.json b/examples/modal/modal-sandbox-domain-allowlist.json index d76f51e..95a208a 100644 --- a/examples/modal/modal-sandbox-domain-allowlist.json +++ b/examples/modal/modal-sandbox-domain-allowlist.json @@ -1,5 +1,6 @@ { - "generated_at": 1793944875, + "agentsec_version": "0.5.0.dev0", + "generated_at": 1794296286, "label": "modal-sandbox-domain-allowlist", "probe": { "duration_ms": 4166, @@ -347,11 +348,11 @@ "schema_version": 1, "summary": { "by_severity": { - "critical": 1, - "high": 3, - "info": 3, - "low": 1, - "medium": 4 + "critical": 0, + "high": 1, + "info": 8, + "low": 0, + "medium": 3 }, "finding_count": 12, "findings": [ @@ -379,20 +380,23 @@ { "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": [ @@ -400,7 +404,7 @@ "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)" }, { @@ -413,7 +417,9 @@ "CAP_SETUID", "CAP_SYS_CHROOT", "CAP_SYS_PTRACE" - ] + ], + "severity_on_shared_kernel": "high", + "user_space_kernel": "gvisor" }, "id": "PRIV-003", "owasp": [ @@ -421,20 +427,22 @@ "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" }, { @@ -532,44 +540,43 @@ }, { "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": "353061609472" + "memory_limit_v1": "353061609472", + "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": 105, + "raw_score": 39, "recommended_flags": [ "(keep the proxy allowlist to the hosts the agent needs)", - "--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": 100 + "score": 39 }, "target": { "how": "modal client 1.5.3, modal.Sandbox.create with Image.debian_slim(python_version=3.12), outbound_domain_allowlist=[pypi.org]. 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.", diff --git a/examples/modal/modal-sandbox-domain-allowlist.md b/examples/modal/modal-sandbox-domain-allowlist.md index 7e26dc9..27b244d 100644 --- a/examples/modal/modal-sandbox-domain-allowlist.md +++ b/examples/modal/modal-sandbox-domain-allowlist.md @@ -1,7 +1,7 @@ # Sandbox blast radius: modal-sandbox-domain-allowlist -**Score: 100 / 100** (capped; raw 105) (0 = fully contained; higher = larger blast radius) -Findings: 12 (critical 1, high 3, medium 4, low 1) +**Score: 39 / 100** (0 = fully contained; higher = larger blast radius) +Findings: 12 (critical 0, high 1, medium 3, low 0) ## Target (reproduce with this) - kind: `captured` @@ -17,22 +17,22 @@ Findings: 12 (critical 1, high 3, medium 4, low 1) - fix: These hosts were reached directly and the control host, example.com, was not, so the network is filtered and these are what an injected command can reach at least. Keep the list to what the agent needs; a host that accepts uploads, such as a code host or a package index, is an exfiltration route. ### PRIV-007 · INFO · The kernel seen here is a user-space kernel -- evidence: `{'kernel': 'gvisor'}` +- evidence: `{'kernel': 'gvisor', 'applied_to_score': True}` - OWASP agentic: ASI02 Tool Misuse & Exploitation -- fix: 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. +- fix: 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. -### PRIV-001 · HIGH · Agent runs as real root (uid 0, not in a user namespace) -- evidence: `{'euid': 0}` +### PRIV-001 · INFO · Agent runs as real root (uid 0, not in a user namespace) +- evidence: `{'euid': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI03 Agent Identity & Privilege Abuse, ASI05 Unexpected Code Execution - fix: Run as an unprivileged user (docker --user) or inside a user namespace. -### PRIV-003 · HIGH · Dangerous Linux capabilities in the effective set -- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE']}` +### PRIV-003 · INFO · Dangerous Linux capabilities in the effective set +- evidence: `{'capabilities': ['CAP_DAC_OVERRIDE', 'CAP_MKNOD', 'CAP_SETGID', 'CAP_SETUID', 'CAP_SYS_CHROOT', 'CAP_SYS_PTRACE'], 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'high'}` - OWASP agentic: ASI05 Unexpected Code Execution, ASI03 Agent Identity & Privilege Abuse - fix: docker --cap-drop ALL, then add back only what the workload needs. -### PRIV-004 · MEDIUM · No seccomp filter applied -- evidence: `{'seccomp_mode': 0}` +### PRIV-004 · INFO · No seccomp filter applied +- evidence: `{'seccomp_mode': 0, 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'medium'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: 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. @@ -60,12 +60,13 @@ Findings: 12 (critical 1, high 3, medium 4, low 1) - OWASP agentic: ASI02 Tool Misuse & Exploitation, ASI05 Unexpected Code Execution - fix: Mount only the working tree, read-only where possible; never mount the host root. -### FS-005 · CRITICAL · /proc/sysrq-trigger writable +### FS-005 · INFO · /proc/sysrq-trigger writable +- evidence: `{'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'critical'}` - OWASP agentic: ASI05 Unexpected Code Execution - fix: Mask /proc/sysrq-trigger; do not run privileged. -### RES-001 · LOW · No memory or PID limits on the sandbox -- evidence: `{'memory_limit_v1': '353061609472'}` +### RES-001 · INFO · No memory or PID limits on the sandbox +- evidence: `{'memory_limit_v1': '353061609472', 'user_space_kernel': 'gvisor', 'severity_on_shared_kernel': 'low'}` - OWASP agentic: ASI08 Cascading Agent Failures - fix: docker --memory and --pids-limit. @@ -77,16 +78,10 @@ A starting point, not a policy: each entry closes at least one finding observed ``` (keep the proxy allowlist to the hosts the agent needs) ---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 ``` ## What the probe does not do diff --git a/pyproject.toml b/pyproject.toml index 2a53255..d6e1017 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "agentsec-pack" -version = "0.4.0" +version = "0.5.0.dev0" description = "Measure what an AI agent's sandbox lets it reach: network, secrets, host filesystem, privileges and processes, from inside the sandbox." readme = "README.md" requires-python = ">=3.10" diff --git a/tests/test_compatibility.py b/tests/test_compatibility.py index 506a5eb..453edb3 100644 --- a/tests/test_compatibility.py +++ b/tests/test_compatibility.py @@ -219,3 +219,46 @@ def test_the_action_keeps_its_inputs_and_outputs(): assert names(inputs) == ["image", "preset", "engine", "flags", "max-score", "baseline", "label", "redact", "out", "upload"] assert names(outputs) == ["score", "report"] + + +def _modal_probe(): + return json.loads((ROOT / "examples" / "modal" / "modal-sandbox-default.json").read_text())["probe"] + + +def _by_id(findings): + return {f.id: f for f in findings} + + +def test_the_documented_kernel_scoped_findings_are_the_scored_ones(): + doc = (ROOT / "docs" / "COMPATIBILITY.md").read_text() + line = next(l for l in doc.splitlines() if l.startswith("- Under a user-space kernel")) + documented = re.findall(r"\b((?:PRIV|FS|RES)-\d{3})\b", line.split(" are info")[0]) + assert documented[0] == "PRIV-007" + assert tuple(documented[1:]) == scoring.KERNEL_SCOPED + + +def test_under_a_user_space_kernel_its_grants_are_info_and_exposure_keeps_its_severity(): + probe = _modal_probe() + under = _by_id(scoring.analyze(probe)) + shared_probe = copy.deepcopy(probe) + del shared_probe["identity"]["user_space_kernel"] + shared = _by_id(scoring.analyze(shared_probe)) + scoped = [i for i in scoring.KERNEL_SCOPED if i in shared] + assert scoped, "the Modal probe should exercise the rule" + for i in scoped: + assert under[i].severity == "info" + assert under[i].evidence["severity_on_shared_kernel"] == shared[i].severity != "info" + assert under[i].evidence["user_space_kernel"] == "gvisor" + for i in shared: + if i not in scoring.KERNEL_SCOPED and i != "PRIV-007": + assert under[i].severity == shared[i].severity, i + assert under["PRIV-007"].evidence["applied_to_score"] is True + + +@pytest.mark.parametrize("target", ["/proc/version", "/proc"]) +def test_a_mount_over_proc_version_keeps_the_usual_severities(target): + probe = _modal_probe() + probe["filesystem"]["bind_mounts"].append({"source": "/x", "target": target, "fstype": "ext4", "rw": False}) + found = _by_id(scoring.analyze(probe)) + assert found["PRIV-001"].severity == "high" + assert found["PRIV-007"].evidence["applied_to_score"] is False diff --git a/tests/test_probe_tls.py b/tests/test_probe_tls.py index e4be6f3..021a96e 100644 --- a/tests/test_probe_tls.py +++ b/tests/test_probe_tls.py @@ -73,9 +73,11 @@ def test_a_report_from_before_the_control_existed_scores_as_it_did(): assert "NET-001" in found and "NET-005" not in found -def test_a_user_space_kernel_is_flagged_and_does_not_change_the_score(): +def test_a_user_space_kernel_is_flagged_and_root_inside_it_counts_as_info(): plain = ids(network(), {"uid": 0, "euid": 0}) flagged = ids(network(), {"uid": 0, "euid": 0, "user_space_kernel": "gvisor"}) assert "PRIV-007" in flagged and "PRIV-007" not in plain assert flagged["PRIV-007"].weight == 0 - assert "PRIV-001" in flagged + assert plain["PRIV-001"].severity == "high" + assert flagged["PRIV-001"].severity == "info" + assert flagged["PRIV-001"].evidence["severity_on_shared_kernel"] == "high"