Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions .github/workflows/security-scan-codex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ jobs:
ENDOR_API_CREDENTIALS_KEY: ${{ secrets.ENDOR_API_CREDENTIALS_KEY }}
ENDOR_API_CREDENTIALS_SECRET: ${{ secrets.ENDOR_API_CREDENTIALS_SECRET }}
run: |
# Shards that run out of memory lose the runner before later steps can
# upload diagnostics, so sample memory here, in the worker step.
(
while sleep 60; do
echo "runner-resources $(date -u +%T) $(free -m | awk '/^Mem:/ {printf "mem_used_mb=%s mem_total_mb=%s", $3, $2} /^Swap:/ {printf " swap_used_mb=%s", $3}') root_disk_used=$(df --output=pcent / | tail -1 | tr -d ' ')"
docker stats --no-stream --format 'runner-resources container={{.Name}} mem={{.MemUsage}}' 2>/dev/null || true
sudo -n dmesg 2>/dev/null | grep -i 'killed process' | tail -2 | sed 's/^/runner-resources oom: /' || true
done
) &
sampler=$!
trap 'kill "$sampler" 2>/dev/null || true' EXIT
bun scripts/security/run-codex-scan-worker.ts \
--batch-limit "$CODEX_SECURITY_SCAN_LIMIT" \
--lane "$CODEX_SECURITY_SCAN_LANE" \
Expand Down
1 change: 1 addition & 0 deletions scripts/security/endor/fixtures/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set -eu
# docker run --rm --network bridge --cap-drop ALL \
# --cap-add NET_ADMIN --cap-add SETUID --cap-add SETGID --cap-add SETPCAP \
# --cap-add CHOWN --security-opt no-new-privileges:true --read-only \
# --memory 3g --memory-swap 3g \
# --tmpfs /tmp:rw,nosuid,nodev,exec --tmpfs /output:rw,mode=1777 \
# --mount type=bind,source="$PWD/scripts/security/endor/fixtures",target=/fixture,readonly \
# --mount type=bind,source="$PWD/scripts/security/endor/scan.sh",target=/scan.sh,readonly \
Expand Down
2 changes: 2 additions & 0 deletions scripts/security/run-endor-plugin-scan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ describe("runEndorPluginScan", () => {
);
const runArgs = await dockerRunArgs(workspace);
expect(runArgs).toContain("--rm");
// Without a cap, concurrent large scans exhaust the hosted runner's memory.
expect(runArgs.join(" ")).toContain("--memory 3g --memory-swap 3g");
expect(runArgs).toContain(
`type=bind,source=${join(workspace, "endor-artifact")},target=/workspace,readonly`,
);
Expand Down
10 changes: 10 additions & 0 deletions scripts/security/run-endor-plugin-scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const CHILD_RUNTIME_ENV_KEYS = [
] as const;
const DEFAULT_ENDOR_TIMEOUT_MS = 20 * 60 * 1000;
const DOCKER_REMOVE_TIMEOUT_MS = 10_000;
// Hosted ubuntu-22.04 runners have 16 GB, and a shard runs up to 4 scans at once.
const ENDOR_CONTAINER_MEMORY = "3g";
// Community packages with large dependency trees produce reports over 8 MiB.
// Only the bounded summary is kept; diagnostics are capped separately.
const MAX_ENDOR_REPORT_BYTES = 64 * 1024 * 1024;
Expand Down Expand Up @@ -281,6 +283,14 @@ export async function runEndorPluginScan(input: {
"--security-opt",
"no-new-privileges:true",
"--read-only",
// The npm tree, npm cache and call graph all live in the /tmp tmpfs, which
// counts against this cap. Uncapped, concurrent scans of large packages
// exhausted the hosted runner and the kernel killed the worker or the VM.
// With the cap, only this scan is killed and its report fails.
"--memory",
ENDOR_CONTAINER_MEMORY,
"--memory-swap",
ENDOR_CONTAINER_MEMORY,
"--entrypoint",
"/usr/local/bin/clawhub-endor-entrypoint",
"--tmpfs",
Expand Down
5 changes: 5 additions & 0 deletions specs/endor-plugin-scans.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ Endor runs with `docker run --rm` from a digest-pinned image built by the manual
- installs firewall rules blocking private, link-local and special-use IPv4/IPv6
destinations, then drops all capabilities and runs as the unprivileged `node`
user (it uses public DNS resolvers because the firewall blocks private ones);
- is capped at 3 GB of memory with no extra swap. The `/tmp` tmpfs, which
holds the npm tree, npm cache and call graph, counts against the cap. Before
the cap, concurrent scans of large packages exhausted the 16 GB hosted runner
from 2026-11-07, and the kernel killed the worker or the whole VM. Now an
oversized scan is killed on its own and only its report fails;
- runs npm and Yarn through shims that strip Endor credentials and disable
dependency scripts. The image pins an npm version that also suppresses Git
dependency `prepare` scripts; the isolation proof below checks this.
Expand Down
Loading