Repository navigation
feat(hardening): opt-in operator approval for acquiring third-party code - #417
Conversation
BaaRai
left a comment
There was a problem hiding this comment.
Request changes. The idea is right, the gate is not.
- These ask rules outrank the built-in refusals.
intercept/intercept.goMatchreturns the first rule in priority order, the built-in DELETE and bulk-clear denies are priority 80, and these rules are 95-96.pip install x && curl -X DELETE ...now becomes an approval instead of a refusal. Set these below 80. hardening/apply-intercept-rules.shsources.envas shell (set -a; . ./.env). A value containing$(...)executes, and a$in a secret expands and can leak in an error. ParseKEY=VALUEwithout evaluation, or usedocker compose --env-file.skills/third-party-code-review/SKILL.mdsays downloads are gated, but in target-only mode onlyMatchBuiltinruns, so these rules are never consulted and agit clonepasses without a request. Either apply them in that mode or state the limitation in the skill.- The regexes are a safety net, not a gate: tabs, JSON escapes,
git -c,pip3.12,curl | tarandbash -c "$(curl ...)"pass, whilegrep 'npm install' docs/waits 30 minutes. Say that in the skill and add a test for each bypass you close. - The sha256 blocklist and the
/app/keysand DSN prohibition are prose only. Nothing enforces them.
Good: the skill cannot auto-approve, and the SQL structure is correct.
|
Addressed in the follow-up commit.
|
There was a problem hiding this comment.
Thanks for addressing the five original review points: the priority drop to 70-72, the container-env psql (no .env sourcing), the target-only documentation, the closed bypasses, and the enforced deny rule are all solid.
Four small items to close before merge:
-
/proc/self/environgap in rule 5.hardening/intercept-rules.sqlmatches/proc/[0-9]+/environ, which misses/proc/self/environand/proc/thread-self/environ. Change it to/proc/(?:[0-9]+|self|thread-self)/environand add a case for it. -
Match
agents.keyinstead ofa.name.agent_skill_visibilitycurrently filtersWHERE a.name IN ('Main', 'Worker', 'Auto', 'Penetration Testing', 'Vulnerability Retest'). Matching on display name silently matches 0 rows if an agent is renamed or localized. Match onagents.keyinstead. -
Wire
rulecheckintogo testand CI.hardening/rulecheck/main.gois a standalonepackage main, sogo test ./...in CI never runs the 18 assertions. Convert it into a*_test.goso CI executes them on every PR. -
Priority-precedence test through
intercept.Match. Add a test that runs the loaded rules alongside the built-in rules throughintercept.Matchand asserts thatpip install x && curl -X DELETE ...hits the built-in priority-80 deny rather than the priority-70 ask.
Once those are in, this is ready as an opt-in candidate for the next release.
Add opt-in intercept rules (action ask, timeout -> deny) that pause the agent before it downloads from code/exploit hosts, runs git clone, installs packages, or pipes remote content into a shell, plus a third-party-code-review skill (hash, blocklist-check, read and summarize the code before running it). Nothing is seeded: the rules change no behavior until hardening/apply-intercept-rules.sh is run, and code the agent writes itself is not gated -- only the point where untrusted code enters. Regex patterns are RE2 (verified to compile); the apply script is idempotent.
- 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).
…check_test into go test (BaaRai#417)
86ab9dd to
9028dfe
Compare
|
Thanks @ldevbr. Merged. The approval rules, the review skill and the rulecheck test are in, with the priority below the built-in denies so a destructive command is never downgraded to an approval. The review fixes are included. |
The skill told the agent to append to /app/data/third-party-blocklist.txt, but under agent isolation the data directory is not writable by the executor uid. HOME points at the executor home in both modes and is writable there. Follow-up to BaaRai#417.
…check_test into go test (BaaRai#417)
The skill told the agent to append to /app/data/third-party-blocklist.txt, but under agent isolation the data directory is not writable by the executor uid. HOME points at the executor home in both modes and is writable there. Follow-up to BaaRai#417.
Add opt-in intercept rules (action ask, timeout -> deny) that pause the agent before it downloads from code/exploit hosts, runs git clone, installs packages, or pipes remote content into a shell, plus a third-party-code-review skill (hash, blocklist-check, read and summarize the code before running it).
Nothing is seeded: the rules change no behavior until hardening/apply-intercept-rules.sh is run, and code the agent writes itself is not gated -- only the point where untrusted code enters. Regex patterns are RE2 (verified to compile); the apply script is idempotent.