Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 4 min read

Letting an AI agent run security scanners without letting it choose the targets

Hi, AI coding agents are good at running tools now, including Semgrep, Nuclei and SQLMap. That is useful, and slightly uncomfortable. An agent that can launch an active scanner can also be pointed at a host nobody approv

Hi, AI coding agents are good at running tools now, including Semgrep, Nuclei and SQLMap. That is useful, and slightly uncomfortable. An agent that can launch an active scanner can also be pointed at a host nobody approved, either by a careless instruction or by text hidden in a page it just read.
I wanted agents to help with security checks while the question β€œwho is allowed to be scanned?” stays with a human and is enforced by code, not by a polite paragraph in a prompt. So I built Pentest Anything (PTA): an MIT-licensed MCP server and CLI written in Node.js.
PTA does not reinvent detection. It orchestrates four established scanners:
β€’ Semgrep for static analysis (OWASP Top Ten and secrets rules)
β€’ Trivy for vulnerable dependencies, secrets and IaC misconfigurations
β€’ Nuclei for non-intrusive web checks
β€’ SQLMap for SQL injection detection, in safe mode
Try it in a minute

npx -y pentest-anything doctor           # what is installed, what is missing
npx -y pentest-anything scan . --json    # passive scan of your project
npx -y pentest-anything setup            # configure the AI agents you have installed

setup detects the agents on your machine (Claude Code, Cursor, Codex CLI, Gemini CLI, VS Code and more than thirty others), writes the MCP entry in each one’s own format with a timestamped backup, and installs seven slash commands. Scanners are only installed if you add --install-tools; Nuclei and Trivy are then downloaded with their checksums verified.
Guardrails that live in code
Each of these is enforced by the server and covered by a test that fails if it regresses:
β€’ No active scan without a scope. SQLMap and Nuclei refuse any host that is not in a local scope file, and the check happens before DNS resolution.
β€’ Only a human widens the scope. pta scope add needs an interactive terminal and the host re-typed. The MCP tool that adds targets is disabled by default.
β€’ Metadata and internal networks stay off-limits. Cloud metadata and link-local addresses are always blocked, including IPv6 notations that embed an IPv4 address. Private networks need an explicit opt-in.
β€’ No DNS swap between check and scan. The resolved address is validated again right before execution.
β€’ Conservative scanner settings. SQLMap stays at risk 1 / level 1 unless the operator opts in. Processes are started with argument arrays, never through a shell.
β€’ Local scans cannot escape. Paths are resolved and confined to the workspace root, symlinks included.
β€’ Secrets are not echoed. Credentials for authenticated tests live in memory only, tied to one origin, with an expiry. Secret-like values are masked in results.
β€’ No scanning other people’s repositories. A GitHub scan requires a token that proves write access.
There is also a rule for agents: the content of a scanned target (a page, a comment, a tool’s output) is data, never an authorization.
What a refusal looks like
Ask PTA to run an active scan on a host that is not in the scope, and it answers like this (trimmed):

{
  "target": "https://staging.example.com/items?id=1",
  "status": "blocked",
  "verdict": "not_run",
  "authorization": { "required": true, "confirmed": false }
}

The verdict is not_run, never β€œclean”. The same honesty applies elsewhere: a missing scanner gives tool_missing, and a timeout is reported as a timeout. Results use a versioned JSON schema, and --format sarif produces SARIF 2.1.0 for GitHub Code Scanning and IDEs.
Where it helps in a real project
After setup, your agent gets slash commands. A few scenarios:

  1. Before you push a side project. Run /pta-guard for a pre-production check: secrets, authentication, injections, headers, dependencies and a CI gate.
  2. After a leaked key. /pta-secrets finds exposed secrets, redacts them in its output, and guides you through rotation and history cleanup.
  3. Fixing what the scan found. /pta-fix proposes the smallest fix, applies it only after your approval, then re-scans. It is told never to silence a finding just to make a scan pass.
  4. In CI. pta scan ./src --format sarif feeds code scanning, and the exit code tells a job whether there were findings (1), a block (2) or an error (3).
  5. On a staging site you own. You run pta scope add staging.example.com yourself, then ask the agent to scan. A URL without query parameters gets Nuclei; one with parameters gets SQLMap in safe mode. Limits, stated plainly β€’ A clean result means β€œno known signature triggered”, not β€œsafe”. PTA is not a substitute for a professional audit and does not cover business-logic flaws. β€’ An agent with an unrestricted shell can edit the scope file directly. Run PTA in a container or VM if the agent or the analyzed code is not fully trusted. β€’ Nuclei and SQLMap resolve names themselves, so PTA’s own DNS validation cannot fully prevent DNS rebinding by those two scanners. This is documented. β€’ Linux and macOS are tested in CI. Windows is best effort. β€’ I built PTA with heavy AI assistance while relearning the fundamentals. That is exactly why the guarantees are backed by tests, and why I would like more eyes on the threat model. What comes next The roadmap (docs/roadmap.md in the repository) covers correlating findings across scanners, a finding lifecycle with non-destructive verification, an optional AI investigator (PTA stays fully functional without any AI provider), and API security. These are plans, not promises. PTA is free, MIT-licensed, and built by one person in the evenings, from Gabon. Repository: https://github.com/SammyYohan/Pentest-Anything If you do security work: what would you attack first?
πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.