Files
ARTEX/hardening/apply-intercept-rules.sh
T
Luis 264d6360cc fix(hardening): address review on the approval gate
- Priority 95-96 -> 70-72, below the built-in destructive denies (80/90/100),
  so 'pip install x && curl -X DELETE ...' still hits the DELETE deny instead of
  being downgraded to an approval (intercept.Match is priority-DESC).
- apply-intercept-rules.sh no longer sources .env as shell (code execution / $
  expansion). It reads POSTGRES_USER/DB from the postgres container's own env.
- Add a 'deny' rule for reading /app/keys, /proc/<pid>/environ and the DSN, so
  the key/DSN prohibition is enforced, not prose.
- Close named regex bypasses (pip3.12, git -c, bash -c "$(curl)", curl | tar);
  document the remaining open bypasses, the false positive, and the target-only
  limitation in the skill.
- Add hardening/rulecheck: compiles the patterns from the SQL (RE2) and asserts
  positives, closed bypasses, and documented open cases (18 cases, 0 failures).
2026-11-22 10:16:45 +01:00

24 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Applies the [hardening] intercept rules and skill visibility (idempotent),
# then restarts the artex service so the interceptor reloads its rule cache.
#
# This script does NOT source .env. Sourcing it (`set -a; . ./.env`) runs any
# value containing $(...) as a command and expands $VARs, which can execute code
# or leak a secret in an error. POSTGRES_USER / POSTGRES_DB are read from the
# postgres container's own environment instead, with no host-side evaluation.
set -euo pipefail
cd "$(dirname "$0")/.."
# psql runs inside the container; $POSTGRES_USER/$POSTGRES_DB are the container's
# env (set by compose), expanded by the container shell, never by this host shell.
docker compose exec -T postgres sh -c \
'exec psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"' \
< hardening/intercept-rules.sql
docker compose restart artex
docker compose exec -T postgres sh -c 'exec psql -U "$POSTGRES_USER" -d "$POSTGRES_DB"' <<'SQL'
SELECT id, name, action, priority, timeout_seconds, timeout_action
FROM intercept_rules WHERE name LIKE '[hardening]%' ORDER BY priority DESC;
SQL