Add security doctor and downstream lockdown workflow for protected CLI isolation #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally filed by @coilysiren on 2026-05-22T00:36:42Z - https://github.com/coilysiren/agent-guard/issues/28
Context
agent-guardis the shipped binary for repo-facing agent safety workflows: it is Homebrew-distributed, owns the executable contract, and already consumescli-guardprimitives.cli-guardremains the reusable Go framework/library. Downstream repos should be able to adopt this with config plus thin shell wrappers, without carrying Go code or checked-in binaries.The operator goal is to make it difficult for Codex/Claude/other semi-trusted agents to run privileged or sensitive host tools directly, while still giving humans a clean path through audited wrappers.
This should be implementable clean-room from this issue plus the existing repo. Do not invent a new config scheme: downstream repos already use
.agent-guard/agent-guard.yaml, parsed throughcli-guard/repocfg.Current state
In this repo today:
.agent-guard/agent-guard.yamldeclares allowed repo commands.cmd/agent-guard/repocfg.godiscovers config by walking up from cwd:.agent-guard/agent-guard.yaml.coily/coily.yamlagent-guard exec <verb>runs configured repo commands.agent-guard lintvalidates the config/Makefile contract.agent-guard hook pre-tool-useexists for Claude CodeBashPreToolUse payloads.agent-guard install-hooksregisters that hook.cli-guard/hookalready provides segment splitting, route hints, binary path integrity rules, interpreter denies, and scratch-dir exec denies.cli-guard/lockdown/defaults.yamldemonstrates the intended inversion: deny bare privileged binaries and route privileged operations through a wrapper binary.Desired architecture
Use this split:
cli-guardagent-guarddownstream repo/tooling
agent-guardat the repo config path when neededagent-guardAdd explicit config path support
Add an env-var override so downstream shell wrappers do not need to run from the config repo.
Suggested name:
Behavior:
--config <path>flag is present on commands that load repo config, use it.AGENT_GUARD_CONFIGis set, use it.Apply this consistently to commands that need config:
agent-guard execagent-guard lintValidation:
repocfg.Load--config,AGENT_GUARD_CONFIG, or discoveryAdd security policy fields to the existing config
Do not replace the current
commands:scheme. Extend the existing YAML with an optional security section.Example shape:
The exact field names can change, but preserve the existing config-file pattern and keep this declarative.
Add
agent-guard doctor securityAdd a new doctor command focused on host readiness and agent lockout posture.
Suggested command:
Checks:
--config,AGENT_GUARD_CONFIG, or discovery.agent-guardbinary resolves to a canonical trusted install path.sudo -n truesucceeds and policy forbids passwordless sudoOutput:
pass,warn,fail.Important security stance:
Add
agent-guard verify securityor make doctor CI-friendlyThere should be a non-interactive mode suitable for pre-commit/CI:
or:
Expected behavior:
failwarnwith--strictThis lets downstream repos add a pre-commit or CI check that validates the security config without committing generated binaries.
Hook behavior
For v1, deny configured protected binaries wholesale when invoked directly. Route users toward configured wrapper commands.
Consider expanding current hook matching so route and deny checks handle these spellings consistently:
The existing
cli-guard/hookalready stripsenvandsudo, and it already detects interpreter basenames by path. If route matching currently keys only on the full leading token, add basename-aware matching for protected binaries so absolute paths do not bypass hook hints/denies.Codex note:
PreToolUseis already wired.Downstream integration target
A downstream wrapper should be able to look like this:
Contributors should not need to see or edit Go code in the downstream repo.
No downstream binary check-in is required for v1. Prefer Homebrew-installed
agent-guardplus version/checksum reporting. If a future issue chooses checked-in binaries, require reproducible build verification and checksum/signature metadata.Pre-commit recommendation
Do not have ordinary downstream pre-commit hooks compile and check in a binary.
Instead:
agent-guardrepo owns build/test/release checks.If the config changes, the check should prove the installed/pinned
agent-guardunderstands it.Suggested implementation slices
Add config-path resolution helper
--configAGENT_GUARD_CONFIGExtend config parsing
security:sectioncommands:behavior unchangedAdd doctor command tree
agent-guard doctor security--json--checkImplement host checks
Wire hook policy from config
Docs
docs/FEATURES.mdAcceptance criteria
agent-guard exec,lint,hook, andinstall-hooksbehavior keeps working with the current.agent-guard/agent-guard.yaml.AGENT_GUARD_CONFIG=/abs/path/file.yaml agent-guard lintworks outside the repo tree.agent-guard doctor security --config /abs/path/file.yaml --checkexits non-zero when protected binaries or sudo posture violate policy.agent-guard doctor security --jsonemits machine-readable findings with stable severity fields.cli-guardpackages.Non-goals
agent-guarduser.