Agentf includes a dedicated SECURITY agent that runs in every workflow (aside from pure exploration) to surface potential risks early. The agent leverages Agentf::Commands::SecurityScanner, which performs lightweight detection for:
- Hard-coded secrets (API keys, private keys, password assignments)
- Prompt-injection attempts that try to exfiltrate environment variables or override instructions
While this provides a safety net, you should pair it with additional "shift-left" security measures:
-
Pre-commit secret scanning
- Install tools such as Gitleaks or TruffleHog
- Wire them into Git hooks (e.g., via pre-commit) so sensitive strings are blocked before a push. A starter
.pre-commit-config.yamlwith a Gitleaks hook ships with this repository. Install pre-commit withbrew install pre-commit(orpipx install pre-commit) and then runpre-commit install.
-
Push protection
- Enable GitHub's Secret Scanning Push Protection under repository settings to block commits containing known secret patterns
-
Log sanitisation
- Ensure verbose agent logs strip response headers/bodies to avoid storing API keys returned from upstream providers
-
Memory hygiene
- Avoid saving raw secrets in Redis episodic memory; use references, masked values, or encrypted blobs instead
-
Prompt hardening
- Update system prompts to reject "print env" or "ignore previous instructions" payloads, and restrict the agent's toolset from accessing sensitive shell commands
-
Continuous review
- Periodically review the output of the SECURITY agent's stored memories (via
agentf memory recent) for regressions
- Periodically review the output of the SECURITY agent's stored memories (via
You can fetch the canonical checklist at runtime with:
Agentf::Commands::SecurityScanner.new.best_practicesAdopting these practices keeps secrets out of your repo, enforces layered security checks, and helps the orchestration workflows remain resilient against prompt-injection attacks.