# Changelog of MCPGuard Security Auditor (`zluowa/mcpguard-security-auditor`) Actor

- **URL**: https://apify.com/zluowa/mcpguard-security-auditor/changelog.md
- **Full Actor documentation**: https://apify.com/zluowa/mcpguard-security-auditor.md

## Changelog — MCPGuard & LoopBreaker Kit

### v1.3.0 (2026-11-27)

#### Added — Unified Repo Gate (`audit-repo`), SKILL.md Supply-Chain Hardening & x402 v2 Discovery

- **Unified One-Command Repo Auditor (`src/repo-auditor.mjs`, CLI `audit-repo <dir>`)**:
  - Auto-discovers both MCP JSON/JSONC configs (`mcp.json`, `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `claude_desktop_config.json`, `opencode.json`, etc.) and Agent Rules/Skill files (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `SKILL.md`, `.cursorrules`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`).
  - Handles malformed JSONC gracefully via `MCP_PARSE_ERROR` (`HIGH`) instead of crashing mid-scan.
  - Emits deterministic **Security Score (`0–100`) & Grade (`A–F`)**, unified **SARIF 2.1.0** (`--sarif`), and PR-ready **Markdown summary** (`--markdown`, wired into `deploy/github-action.yml` `$GITHUB_STEP_SUMMARY`).
- **SKILL.md Supply-Chain Hardening (`src/rules-auditor.mjs`)**:
  - Extended `PIPE_REMOTE_TO_SHELL` to catch `curl|wget ... | python/python3/node/perl/ruby`.
  - Added `POWERSHELL_IEX_DOWNLOAD` (`irm/iwr/Invoke-WebRequest ... | iex/Invoke-Expression`) and `CREDENTIAL_HARVEST_EXFIL` (flag-verified or piped exfiltration of `~/.ssh`, `~/.aws/credentials`, `/etc/shadow`, `.env`, `.npmrc`, `.pypirc`, `.git-credentials`), maintaining zero false positives on normal security documentation prose.
- **x402 v2 Production Compatibility & Machine-Readable Discovery (`src/discovery.mjs`)**:
  - Closes the `PAYAPI_READINESS_2026-11-26.md` gap: `402 PAYMENT-REQUIRED` now emits a canonical absolute `resource.url` (`https://host/api/v1/...`, configurable via `PUBLIC_BASE_URL` / `--public-base-url`) across both `src/http-server.mjs` and `deploy/cloudflare-worker.mjs`.
  - Added `GET /.well-known/x402`, `GET /openapi.json` (OpenAPI 3.1.0), `GET /llms.txt`, and `POST /api/v1/audit-repo-bundle` (also exposed as the 5th Stdio MCP tool `audit_repo_bundle`).

### v1.2.0 (2026-11-26)

#### Added — 3-in-1 Expansion: AI Agent Rules File Backdoor & Context Bloat Auditor (`audit-rules`)

- **Pure-ESM Rules Auditor (`src/rules-auditor.mjs`)**:
  - Audits `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, and `SKILL.md` (single file or recursive directory scan).
  - **`RULES_UNICODE_TAG_STEGO` (`CRITICAL`, exit `4`)**: Unconditionally flags hidden Unicode Tag characters (`U+E0000–U+E007F`) with decoded ASCII payload preview.
  - **`RULES_BIDI_OVERRIDE` (`CRITICAL`, exit `4`)**: Unconditionally flags Trojan Source bidirectional control overrides (`U+202A–U+202E`, `U+2066–U+2069`).
  - **`RULES_INVISIBLE_CONTROL` (`HIGH`, exit `4`)**: Flags `U+200B`, `U+200C`, `U+2060`, mid-file BOM (`U+FEFF`), and non-emoji `U+200D` while **explicitly preserving legitimate compound Emoji ZWJ sequences** (`👨‍💻`, `🧑‍🔬`, `🏳️‍🌈`, `👩🏽‍💻`, `🏃‍♀️` via `isLegitimateEmojiZwj()`).
  - **`RULES_EMBEDDED_SECRET` (`CRITICAL`/`HIGH`, exit `4`)**: Reuses `SECRET_RULES` from `src/scanner.mjs` to catch accidentally pasted live credentials.
  - **`RULES_DANGEROUS_EXEC_SNIPPET` (`HIGH`, exit `4`)**: Matches only deterministic high-precision shell payloads (`curl/wget ... | sh/bash`, encoded PowerShell, `base64 -d | sh`, destructive root wipe / reverse shell); **strictly zero single-word prose blacklist** (zero false positives on security docs mentioning `exfiltrate` such as `vercel/next.js/AGENTS.md` L329).
  - **`RULES_CONTEXT_BLOAT` (`MEDIUM`, advisory — never blocks exit `4`)**: Reports bytes, lines, estimated tokens (`bytes / 4`), and estimated Context Tax cost per 1,000 uncached turns (`@$3/1M`).
  - **`sanitizeRulesText()`** & **`rulesReportToSarif()`**: Strips hidden backdoors while keeping compound Emoji intact; exports SARIF 2.1.0 with exact line numbers.
- **Wired Across Every Surface**:
  - CLI: `node cli/mcpguard.mjs audit-rules <file-or-dir> [--max-tokens 4000] [--json | --sarif] [--sanitize <out>]`
  - Stdio MCP Server (`src/mcp-server.mjs`): 4th tool `audit_rules_file`
  - HTTP API (`src/http-server.mjs`) & Cloudflare Worker (`deploy/cloudflare-worker.mjs`): `POST /api/v1/audit-rules` (protected by route-first 404, 1 MiB 413, and x402 `/verify` + `/settle`)
  - Offline UI (`web/index.html`): 3rd tab **Agent Rules Auditor** with built-in backdoor/Emoji/Context Tax demo & strip preview
  - GitHub Actions (`deploy/github-action.yml`): Dual SARIF upload for MCP configs and Agent Rules files
  - Fixture: `examples/sample-rules-backdoor.md`

### v1.1.1 (2026-11-26)

#### Security Hardening (Closes Su Heng Audit Items `V11-01` & `V11-02`)

- **V11-01 (`HIGH`, x402 Replay & Settlement Gap Fixed)**:
  - Added `settleX402WithFacilitator()` in `src/payment-hooks.mjs` calling the facilitator `/settle` endpoint and returning a Base64-encoded `PAYMENT-RESPONSE` receipt header.
  - Wired full `/verify` → compute → `/settle` flow into both `src/http-server.mjs` and `deploy/cloudflare-worker.mjs`: paid results are released ONLY after `/settle` confirms `{ success: true }`, closing the signature-replay / zero-settlement gap; malformed `400`/`413` requests never trigger settlement.
- **V11-02 (`MEDIUM`, Route Whitelist & Worker Body Cap Fixed)**:
  - Both `src/http-server.mjs` and `deploy/cloudflare-worker.mjs` now validate `POST` paths against `SUPPORTED_POST_ROUTES` (`/api/v1/audit-mcp`, `/api/v1/sanitize-mcp`, `/api/v1/circuit-break`) **before** invoking x402 verification/settlement (unknown paths immediately return `404 Not Found` with zero facilitator calls).
  - Added a hard `1 MiB` (`1,048,576` bytes) request body limit to `deploy/cloudflare-worker.mjs` (both `Content-Length` pre-check and actual UTF-8 byte length check returning `413 Payload Too Large`).
- **Offline Browser UI (`web/index.html`) Breaker Parity**:
  - Synchronized `runBreaker()` in `web/index.html` to handle numeric Unix epoch timestamps (`ms`/`s`), nested OpenAI/Anthropic `usage` token objects, and `cost_usd`/`total_cost_usd` fields cleanly alongside JSONC/Docker/sensitive-path auditing.

### v1.1.0 (2026-11-26)

#### Added & Hardened (Zero Human Gate, Zero npm Dependencies)

- **9/9 Adversarial & 14-Repo Field Gate Cleared (`confirmedBugs: 0`)**:
  - **BUG-01**: `sanitizeMcpConfig()` now scrubs URL query secrets (`?api_key=...`) and inline credentials inside `args` (e.g. `postgres://user:pass@host`) in addition to `env` and `headers`.
  - **BUG-02 & BUG-06**: `evaluateCircuitBreaker()` supports numeric Unix timestamps (`ms` and `s`) plus standard nested OpenAI/Anthropic `usage` (`input_tokens`/`output_tokens`, `prompt_tokens`/`completion_tokens`, `total_tokens`) and `cost_usd`/`total_cost_usd` fields without inventing missing USD values.
  - **BUG-03**: Fixed `sk-ant-api*` regex collision so Anthropic keys match exclusively `ANTHROPIC_KEY` (zero `OPENAI_KEY` double-count).
  - **BUG-04**: Path normalization catches trailing slashes (`/etc/`, `~/`, `$HOME/`) as `OVERBROAD_FS_ROOT` and flags sensitive credential/system mounts (`~/.ssh`, `~/.aws`, `~/.kube`, `~/.gnupg`, `/var/run/docker.sock`, etc.) as `SENSITIVE_FS_MOUNT` (`CRITICAL`).
  - **BUG-05**: Added Python `uvx` unpinned package detection (`UNPINNED_UVX_PACKAGE`) alongside `npx`/`pnpx`/`bunx` (`@latest` floating tags caught).
  - **BUG-07**: Recognized VS Code `${input:...}` / `${env:...}` and 1Password `op://...` references in `SAFE_PLACEHOLDER_RE`, eliminating false positives on official `github/github-mcp-server` configs.
  - **BUG-08**: Added zero-dependency string-aware `parseJsonc()` across CLI (`audit-mcp`), stdio MCP server, and offline `web/index.html` to parse real `.vscode/mcp.json` files containing `//` comments, `/* */` comments, and trailing commas while keeping `https://` URLs intact.
  - **BUG-09**: Added Docker/Podman MCP security rules (`DOCKER_PRIVILEGED_MODE` for `--privileged`/`--network=host`/`--pid=host`/`--cap-add=SYS_ADMIN|ALL`, `DOCKER_HOST_FS_MOUNT` for `-v`/`--volume`/`--mount` targeting broad roots or sensitive paths, and `DOCKER_UNPINNED_IMAGE` for `:latest`/floating/untagged images).
- **Native Stdio MCP Server (`src/mcp-server.mjs`, `cli/mcpguard.mjs mcp-server`)**: JSON-RPC 2.0 server exposing `audit_mcp_config`, `sanitize_mcp_config`, and `evaluate_circuit_breaker`.
- **Runnable HTTP + Fail-Closed x402 v2 Micro-API (`src/http-server.mjs`, `cli/mcpguard.mjs serve`)** & **Cloudflare Workers Edge Bundle (`deploy/cloudflare-worker.mjs`, `deploy/wrangler.toml`)**: Free public mode by default; when `X402_PAY_TO` is set, emits `HTTP 402` + `PAYMENT-REQUIRED` and enforces real facilitator `/verify` (`503` fail-closed if no facilitator URL is configured).
- **SARIF 2.1.0 Export (`toSarifReport`, `audit-mcp --sarif`)** + upgraded `deploy/github-action.yml` for GitHub Code Scanning.
- **Offline Browser UI (`web/index.html`)** synchronized with JSONC parsing, `sk-ant-api` non-duplication, VS Code/1Password placeholders, `uvx`, sensitive paths, and Docker privilege/mount checks.

#### Verification Evidence (`2026-11-26 15:17 UTC+8`, Node.js `v24.19.0`)

- `node projects/audit/adversarial-repro-mcpguard.mjs`: **`9/9 PASS` (`confirmedBugs: 0`, exit code `0`)**.
- `node --test test/*.test.mjs`: **`17/17 pass, 0 fail`** (`1170.49ms`, exit code `0`).
- Backwards-compatible CLI exit codes preserved (`audit-mcp` exit `4`, `circuit-break` `$5` exit `2`, `$50` exit `3`, clean exit `0`).
- Zero Lemon Squeezy checkout links; zero fabricated URLs, wallet addresses, or revenue claims. Wallet remains `$0.00`.

### v1.0.0 (2026-11-26)

- Initial zero-dependency CLI (`audit-mcp`, `circuit-break`, `init-k8s`), offline `web/index.html`, K8s CronJob & GitHub Actions templates, `dist/mcpguard-kit-v1.0.0.zip` (`23,734 bytes`), and `LAUNCH_KIT.md`. Verified 7/7 pass by independent audit.
