Skip to content

DOCS

Scan

balerx scan looks for coding agents, reads their configuration, and reports findings. It does not execute MCP servers, and it does not upload anything.

Uploaded scans appear on the endpoint scans page. A labelled terminal sample is on the sample report page.

Demo endpoint scan history with risk scores
Demo data. Uploaded scans in the Balerx Demo organization.
balerx scan
balerx scan .
balerx scan --format json
balerx scan --fail-on high
balerx scan --fail-on-unreadable
balerx scan --json report.json --sarif report.sarif --html report.html
balerx scan --json report.json --quiet
balerx scan --write-baseline baseline.json
balerx scan --exclude '**/.cursor/**'

--exclude PATH drops findings under that path or glob (**/.cursor/**). Repeat it to skip more than one.

--quiet skips the terminal report. Files you asked for are still written. -q is the short form. An optional path scans that directory, or one config file. A directory scan reads known config names in that folder (.mcp.json, .cursor/mcp.json, .vscode/mcp.json, .claude/settings.json, .claude.json, .kiro/settings/mcp.json, opencode.json) and does not walk nested copies. Instruction-file checks still recurse in that directory. --format prints json, sarif, or text on stdout. Logs go to stderr. The GitHub Action passes --quiet, so the setup hint is not in the job log.

Exit code

The process exits 2 when the report has a critical finding, 1 when it has a high finding and no critical finding, and 0 otherwise. Medium, low, and info findings do not change that exit code. A usage error, a missing --baseline resource field, or a file the scanner cannot parse as a baseline, exits 64.

--fail-on critical, high, medium, low, or info replaces those codes. The process then exits 1 when any finding is at or above the chosen severity, and 0 otherwise. --fail-on-unreadable exits 1 when a config file could not be read. Default codes for readable files stay the same. --write-baseline FILE writes a JSON ignore list from the current findings, after --exclude and before --baseline is applied. --baseline FILE hides those findings. JSON rule_id is the same code as SARIF (MCP-REMOTE-001). The old Rust name still matches. Unmatched entries warn on stderr.

Risk score

Each finding adds to a score that is capped at 100. The label is not the score alone. One critical finding, or a score above 75, is CRITICAL. Three or more high findings, or a score above 50, is HIGH. Any remaining high or medium finding, or a score above 25, is MEDIUM. Otherwise the label is LOW. Three high findings score 30 and are still labeled HIGH.

SeverityPoints
critical25
high10
medium4
low1
info0

Output files

JSON is the findings file you can pass to upload. rule_id is the rule code (the same value as SARIF ruleId). Older JSON that stored the Rust name (McpRemotePlainHttp) still deserializes. SARIF is for GitHub code scanning and other SARIF tools. driver.rules lists the rules that fired, with a name, helpUri, and security-severity (critical 9.0, high 7.0; the highest finding for that rule). Locations are relative to the working directory when possible, and include a line when the scanner has one. Each SARIF result includes partialFingerprints.balerx/v1 (rule, path, line, title, and JSON key or server name). Path aliases of the same finding share that identity; two secrets in one file do not. HTML is a report you can open in a browser. You can write any combination in one run.

Credentials in MCP server URLs, meaning userinfo and sensitive query parameters, are redacted in terminal, JSON, SARIF, HTML (including unpinned and latest-tag finding titles and evidence), the lockfile (command, args, and package name/version), and upload. Credential-like flags, Authorization / Cookie / X-Api-Key / X-Auth* headers, and inline shell -c strings are redacted in lockfile command and args. Userinfo is taken from the @ in the authority only, so a path such as /pkg@latest stays. A / inside what looks like userinfo ends the authority, so that value is a path and is not redacted. Values that appear only in a URL path are not redacted. An older lockfile of the same config does not report command, args, or version drift. A remote URL swap or auth change is HIGH (LOCK-URL-001 / LOCK-AUTH-001). Lockfiles from before this version omit url and auth; missing fields are not HIGH drift. Re-run balerx lock to start tracking them. A lockfile written by this version shows spurious command/args drift when read by an older scanner (v0.1.5 and earlier). Run balerx lock with the same version everywhere.

--format json, --format sarif, and --format text print that report on stdout. Tracing and warnings go to stderr. --quiet turns tracing off. Set NO_COLOR, or pipe stdout, to turn color off.

What a current scan can raise

RuleMeaning
MCP-SUPPLY-001Unpinned npx, uvx, pip, pipx, bunx, pnpm dlx, deno run https, Docker image, or a git/tarball spec containing ://. @latest is not this rule
MCP-SUPPLY-002Package or image uses a latest tag
MCP-PERM-001Filesystem argument is /, ~, $HOME, /home/<user>, or a similar whole-home path
MCP-PERM-002Server command is a shell
MCP-PERM-003Docker --privileged or a root mount
MCP-PERM-004Database client or database URL
MCP-REMOTE-001Plain http:// whose host is not loopback
MCP-REMOTE-002Remote server with no auth field, URL userinfo, or Authorization / Cookie / X-Api-Key / X-Auth* header
SECRET-001Secret material in a config file, redacted in the report
SECRET-002The same material in an env block
SECRET-003The same material in command arguments
AGENT-AUTONOMY-001Approval policy that never asks, autoApprove: ['*'], or alwaysAllow
AGENT-AUTONOMY-002bypassPermissions, acceptEdits, Bash allow entries, Claude skip/enable flags, or danger-full-access
TOOL-POISON-001Hidden instructions in the scan directory
TOOL-POISON-002Exfiltration wording in the scan directory
HOOK-GAP-001Claude Code or Cursor config with no Balerx hook
CONFIG-001Empty config file is info. Malformed JSON or TOML is high
CONFIG-002Config file could not be read

MCP-SUPPLY-003, MCP-SUPPLY-004, and HOOK-GAP-002 are planned. Current scans do not raise them. Git and tarball specs that contain :// raise MCP-SUPPLY-001.

Fixing common findings

HOOK-GAP-001

The finding title names the product, such as Claude Code. Install that agent with its id, then check the hooks and scan again:

balerx setup
balerx guard install claude-code
balerx guard install cursor
balerx guard status
balerx scan

balerx setup chooses the local policy the hook will read. The finding itself is fixed by the install command. If no policy file exists, scan prints No policy set yet. Run: balerx setup on stderr. Install prints that hint first on stdout, then writes the hooks.

claude-code is Claude Code. cursor is Cursor. balerx guard status shows whether those hooks are installed. balerx scan runs the check again. See Guard.

Guard coverage

Guard hooks exist for Claude Code and Cursor. balerx guard install accepts claude-code and cursor.

When a scan finds another agent, such as VS Code with GitHub Copilot or Codex CLI, the agents section includes a Guard coverage line:

Guard hooks are not available for VS Code with GitHub Copilot yet, so its tool calls aren't intercepted. The scan still checks its config.

The line uses that agent's display name. It is separate from findings. The finding count and the risk score stay the same, and --fail-on ignores it. JSON stores it on the agent as guard_coverage. HTML shows it under Agents. SARIF stores it on the run as properties.guardCoverage, and it is not a SARIF result. HOOK-GAP-002 stays planned. Current scans do not raise it.

CONFIG-001

An empty or whitespace-only config, including a file that is only a UTF-8 BOM, is info: Configuration file is empty. Delete it or add valid contents in that file's format. VS Code mcp.json uses { "servers": {} }. Cursor, Claude, Windsurf, Cline, Roo, and Gemini JSON use { "mcpServers": {} }. Codex config.toml uses an empty [mcp_servers] table or a [mcp_servers.<name>] entry. Claude Code settings.json and VS Code settings.json use {}. Aider, Continue, and Goose use YAML, not a JSON object.

A file with real JSON or TOML syntax errors stays high. The finding includes the parser line and column. Fix that syntax, then run balerx scan again. See CONFIG-001.

CONFIG-002

A file the scanner could not read is info: Configuration file could not be read. It is never a clean scan. Terminal, JSON, and SARIF include the skipped count. --fail-on-unreadable exits 1. The same file reached as . and as a canonical or symlink path is counted once. A parent directory that cannot be listed is not walked, so a file under it is not discovered. See CONFIG-002.

After the scan

Save a lockfile if you want drift checks. Upload the JSON if the team dashboard should show this machine.