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
16 changes: 0 additions & 16 deletions .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ jobs:
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor == 'Patrick-Erichsen' &&
github.event.pull_request.head.sha != '') ||
(github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/codex/endor-plugin-scan-main-20261001' &&
github.actor == 'Patrick-Erichsen' &&
inputs.branch_test_confirm == 'deploy-endor-to-permanent-test' &&
inputs.expected_sha == github.sha) ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push')
runs-on: ubuntu-latest
Expand All @@ -85,9 +80,6 @@ jobs:
}}

- name: Resolve deployment revision
env:
ENDOR_TEST_CONFIRM: ${{ inputs.branch_test_confirm }}
ENDOR_TEST_SHA: ${{ inputs.expected_sha }}
id: revision
run: |
set -euo pipefail
Expand All @@ -96,14 +88,6 @@ jobs:
main_sha="$(git rev-parse origin/main)"
if [[ "$deploy_sha" != "$main_sha" ]]; then
branch_test_allowed=false
if [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]] &&
[[ "$GITHUB_REF" == refs/heads/codex/endor-plugin-scan-main-20261001 ]] &&
[[ "$GITHUB_ACTOR" == Patrick-Erichsen ]] &&
[[ "$ENDOR_TEST_CONFIRM" == deploy-endor-to-permanent-test ]] &&
[[ "$ENDOR_TEST_SHA" == "$deploy_sha" ]]
then
branch_test_allowed=true
fi
if [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]] &&
[[ "$GITHUB_REF" == refs/heads/pe/claw-563-skills-sh-mirror-10k ]] &&
[[ "$GITHUB_ACTOR" == Patrick-Erichsen ]] &&
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/security-scan-codex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ jobs:
CODEX_SECURITY_SCAN_ASSIGNED_JOBS: ${{ inputs['assigned-jobs'] || '' }}
CODEX_SECURITY_SCAN_LANE: ${{ matrix.lane }}
CODEX_SECURITY_SCAN_CLAWSCAN_TIMEOUT_MS: ${{ vars.CODEX_SECURITY_SCAN_CLAWSCAN_TIMEOUT_MS || '900000' }}
# Report-only Endor analysis for code-plugin releases; set to 0 to stop it.
CODEX_SECURITY_SCAN_ENDOR_ENABLED: ${{ vars.CODEX_SECURITY_SCAN_ENDOR_ENABLED || '0' }}
# Select Production first so an empty Test cohort remains empty.
CODEX_SECURITY_SCAN_ENDOR_PACKAGES: ${{ !(inputs.environment == 'Test' || github.event.client_payload.environment == 'test') && '@openclaw/*' || vars.CODEX_SECURITY_SCAN_ENDOR_PACKAGES }}
CODEX_SECURITY_SCAN_ENDOR_JUDGE_ENABLED: ${{ (inputs.environment == 'Test' || github.event.client_payload.environment == 'test') && vars.CODEX_SECURITY_SCAN_ENDOR_JUDGE_ENABLED || '0' }}
CODEX_SECURITY_SCAN_ENDOR_IMAGE: ${{ vars.CODEX_SECURITY_SCAN_ENDOR_IMAGE }}
# The runner is disposable and installs the reviewed, source-pinned host scanners below.
CODEX_SECURITY_SCAN_CLAWSCAN_SANDBOX: "off"
Expand Down
2 changes: 1 addition & 1 deletion docs/security-audits.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ additional inspected-file array, and binds the returned path, hash and challenge
to the final native attempt's provenance. Unsupported versions, mixed fields and
inconsistent or missing native provenance fail closed. Prepublication uses this
same validator, strips both progress opt-ins, and keeps inspection diagnostics out
of the stored public policy output. Legacy Endor profiles deliberately remain v1.
of the stored public policy output.

## Risk analysis

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"ci:types:packages": "bunx tsc -p packages/schema/tsconfig.json --noEmit && bunx tsc -p packages/clawhub/tsconfig.json --noEmit && bun run --cwd packages/clawhub-admin typecheck",
"ci:unit": "SITE_URL= VITE_SITE_URL= VITE_CONVEX_URL=https://example.invalid bun run coverage",
"clawscan:local": "bun scripts/local-clawscan-dry-run.ts",
"clawscan:plugins": "bun scripts/security/scan-local-plugins.ts",
"convex:deploy": "bunx convex deploy --typecheck=disable --yes",
"coverage": "vitest run --coverage",
"crabbox:hydrate": "node scripts/crabbox-wrapper.mjs actions hydrate",
Expand Down
75 changes: 0 additions & 75 deletions scripts/security/clawHubEndorProfile.test.ts

This file was deleted.

76 changes: 0 additions & 76 deletions scripts/security/clawHubEndorProfile.ts

This file was deleted.

70 changes: 63 additions & 7 deletions scripts/security/endor/fixtures/run.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
#!/bin/sh
set -eu
# Manual isolation proof for the scanner image's real npm and Yarn. A stand-in
# endorctl installs registry and Git dependencies through scan.sh's shims and
# fails if a synthetic secret or dependency script escapes. Run it inside the
# image with this directory at /fixture and ENDOR_FIXTURE_OUTPUT=/output,
# passing the installed clawhub-endor-scan path as the only argument.
# Manual isolation proof for the scanner image. Run it before changing the
# image, npm/Yarn, scan.sh or the egress guard. Inside the real container and
# behind the real entrypoint, it checks that the scan runs unprivileged, that
# private-network destinations are rejected, and that the real npm and Yarn
# neither send a synthetic secret to a registry nor run dependency scripts. A
# stand-in endorctl does the installs, so no Endor credentials are needed.
#
# From the repository root, with IMAGE set to the pinned scanner image, start a
# private listener and then run the scan with the worker's container flags:
# docker run -d --rm --name endor-fixture-listener --entrypoint python3 \
# "$IMAGE" -m http.server 8000
# listener=$(docker inspect -f \
# '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' endor-fixture-listener)
# 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 \
# --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 \
# --env ENDOR_FIXTURE_OUTPUT=/output \
# --env ENDOR_FIXTURE_PRIVATE_LISTENER="$listener:8000" \
# --entrypoint /usr/local/bin/clawhub-endor-entrypoint \
# "$IMAGE" sh /fixture/run.sh /scan.sh
# docker stop endor-fixture-listener
# It prints fixture-ok on success. Pass /usr/local/bin/clawhub-endor-scan as
# the last argument to test the scan.sh already in the image instead.

scan_script=$1

if test "$(id -u)" = 0; then
echo "Endor scan ran as root" >&2
exit 1
fi
# No private destination may accept a connection. ENDOR_FIXTURE_PRIVATE_LISTENER
# (host:port) should be a listener that is reachable without the egress guard,
# so a passing run proves the guard, not an unreachable address.
node - <<'EGRESS_PROBE'
const net = require("node:net");
const targets = ["169.254.169.254:80", "10.0.0.1:80", "172.17.0.1:80"];
if (process.env.ENDOR_FIXTURE_PRIVATE_LISTENER) targets.push(process.env.ENDOR_FIXTURE_PRIVATE_LISTENER);
const probes = targets.map(
(target) =>
new Promise((resolve) => {
const [host, port] = target.split(":");
const socket = net.connect({ host, port: Number(port), timeout: 5000 });
socket.on("connect", () => resolve(`${target} connected`));
socket.on("timeout", () => resolve(`${target} blocked (timed out)`));
socket.on("error", (error) => resolve(`${target} blocked (${error.code})`));
}).then((result) => {
console.error(`egress ${result}`);
return result;
}),
);
Promise.all(probes).then((results) => {
process.exit(results.some((result) => result.endsWith("connected")) ? 1 : 0);
});
EGRESS_PROBE
work=$(mktemp -d)
mkdir -p "$work/bin" "$work/source"
printf '%s\n' '{"name":"endor-fixture","private":true}' > "$work/source/package.json"
Expand Down Expand Up @@ -51,7 +101,13 @@ cleanup_server() {
wait "$server_pid" 2>/dev/null || true
}
trap cleanup_server EXIT
while test ! -s "$ENDOR_FIXTURE_OUTPUT/port"; do sleep 0.05; done
while test ! -s "$ENDOR_FIXTURE_OUTPUT/port"; do
if ! kill -0 "$server_pid" 2>/dev/null; then
echo "Probe registry server exited before listening" >&2
exit 1
fi
sleep 0.05
done
port=$(cat "$ENDOR_FIXTURE_OUTPUT/port")

cat > "$probe/gitdep/package.json" <<'PACKAGE_JSON'
Expand Down Expand Up @@ -186,6 +242,6 @@ export ENDOR_API_CREDENTIALS_SECRET=synthetic-endor-secret
export VIRUSTOTAL_API_KEY=synthetic-virustotal-key
export UNKNOWN_ADDITIONAL_SECRET=synthetic-unknown-secret
mkdir -p "$ENDOR_FIXTURE_OUTPUT"
scan_output=$(/bin/sh "$scan_script" "$work/source")
scan_output=$(/bin/sh "$scan_script" "$work/source" https://clawhub.ai/fixture plugin:fixture,version:1.0.0)
test "$scan_output" = '{"all_findings":[],"blocking_findings":[],"warning_findings":[]}'
printf '%s\n' fixture-ok
37 changes: 14 additions & 23 deletions scripts/security/endor/scan.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/bin/sh
set -eu
source_url=${2:-https://example.invalid/clawscan/scan-target.git}
if [ "$#" -eq 3 ]; then
set -- "$1" --exit-on-policy-warning=false --project-tags "$3" --tags "$3"
else
set -- "$1" --dry-run
if [ "$#" -ne 3 ]; then
echo "Usage: clawhub-endor-scan TARGET SOURCE_URL TAGS" >&2
exit 2
fi
target=$1
source_url=$2
tags=$3
# The worker mounts the normalized package read-only. All writes stay in the container.
if [ ! -f "$1/package.json" ]; then
if [ ! -f "$target/package.json" ]; then
echo "Endor requires package.json at the target root" >&2
exit 1
fi
if [ -n "$(find "$1" -name .npmrc -print -quit)" ]; then
if [ -n "$(find "$target" -name .npmrc -print -quit)" ]; then
echo "Endor cannot safely scan targets containing .npmrc" >&2
exit 1
fi
Expand Down Expand Up @@ -64,7 +65,7 @@ write_resolver_shim yarn "$yarn_executable"
"$resolver_bin/yarn" --version >/dev/null
export PATH="$resolver_bin:$PATH"
scan_root=$(mktemp -d)
cp -R "$1"/. "$scan_root"/
cp -R "$target"/. "$scan_root"/
# Never reuse submitted Git hooks/config or installed dependencies.
find "$scan_root" \( -name .git -o -name node_modules \) -prune -exec rm -rf {} +
export GIT_CONFIG_COUNT=1
Expand All @@ -79,19 +80,18 @@ git -C "$scan_root" add --all --force
git -C "$scan_root" commit -q --allow-empty -m "ClawScan scan snapshot"
git -C "$scan_root" remote add origin "$source_url"
cd "$scan_root"
shift
report=$(mktemp)
diagnostic=$(mktemp)
status_file=$(mktemp)
# Stream diagnostics so a timeout does not erase the last completed scan stage.
# Keep the scanner's status separately: POSIX pipelines return tee's status.
{
status=0
endorctl scan "$@" --dependencies --languages=javascript,typescript --call-graph-languages=javascript,typescript --build=false --output-type=json --path "$scan_root" >"$report" || status=$?
endorctl scan --exit-on-policy-warning=false --project-tags "$tags" --tags "$tags" --dependencies --languages=javascript,typescript --call-graph-languages=javascript,typescript --build=false --output-type=json --path "$scan_root" >"$report" || status=$?
printf '%s\n' "$status" >"$status_file"
} 2>&1 | tee "$diagnostic" >&2
status=$(cat "$status_file")
# The worker requires JSON, including for a successful empty scan.
# A successful scan with no findings can emit nothing; the worker requires JSON.
# Endor's 128 means policy findings; analysis failures must still fail the scanner.
node - "$status" "$report" "$diagnostic" <<'JS'
const fs = require("node:fs");
Expand All @@ -105,16 +105,7 @@ if (status !== "0" && status !== "128") fail(`Endor exited ${status}`);
if (diagnostic.includes("ERROR ") || /\b[1-9][0-9]* (scan failure|call graph error)\(s\)/.test(diagnostic)) {
fail("Endor reported one or more analysis errors");
}
let raw = fs.readFileSync(reportPath, "utf8");
if (raw === "" && status === "0") {
raw = '{"all_findings":[],"blocking_findings":[],"warning_findings":[]}';
}
let report;
try { report = JSON.parse(raw); } catch { fail("Endor returned invalid findings JSON"); }
for (const name of ["all_findings", "blocking_findings", "warning_findings"]) {
if (!Array.isArray(report?.[name]) || report[name].some(value => value === null || typeof value !== "object" || Array.isArray(value))) {
fail("Endor returned invalid findings JSON");
}
}
process.stdout.write(raw);
const raw = fs.readFileSync(reportPath, "utf8");
// The worker validates the report shape.
process.stdout.write(raw === "" && status === "0" ? '{"all_findings":[]}' : raw);
JS
Loading
Loading