worker.md SPEC
Menu

PR Security Auditor

PR Security Auditor is a reference AI Worker specification designed for reliable, bounded task execution.

Reference worker specification for auditing Git pull request diffs against OWASP Top 10 vulnerabilities, secrets, and injection risks.

Pricing & Service Level Agreement (SLA)#

Specification Value Target Policy
Invocation Price $0.02 / run (Proposed) Billed per successful schema-validated output.
Payment Methods Stripe Metered • USDC (Base L2) Dual-rail support for teams and autonomous AI agents.
Execution Latency SLA < 20s (Target) Target deadline enforced by runtime deadline timer.
Max Token Budget $0.03 (Ceiling) Hardware token ceiling prevents runaway billing loops.
Benchmark Pass Rate Target: > 95% (Fixture Suite) Target evaluation benchmark pass rate on test fixtures.
Web3 Wallet Address 0x89D24A6b4CcB1B6fAA2625fE562bDD9a23260359 Direct on-chain recipient for autonomous HTTP 402 micro-txs.

worker.md Contract#

The formal execution contract defining inputs, outputs, limits, and runtime instructions:

---
name: pr-security-auditor
version: 1.0.0
description: Audits unified Git pull request diffs for OWASP Top 10 vulnerabilities, leaked secrets, and command injection hazards with deterministic blocking status.
category: devsecops
author: worker.md community
license: MIT
pricing:
  model: per-invocation
  rate_usd: 0.02
  payment_methods:
    - type: stripe_metered
      plan_id: "price_pr_sec_metered_002"
    - type: crypto_micropayment
      network: base
      token: USDC
      wallet: "0x89D24A6b4CcB1B6fAA2625fE562bDD9a23260359"
      http_status_protocol: 402
sla:
  timeout_seconds: 20
  max_cost_usd: 0.03
  concurrency: 50
  eval_accuracy: 99.4%
inputs:
  diff:
    type: string
    required: true
    description: Unified Git diff string of proposed code changes.
  severity_threshold:
    type: string
    enum: [info, medium, high, critical]
    required: false
    default: medium
    description: Minimum finding severity required to trigger a blocking status.
  repo_context:
    type: object
    required: false
    description: Metadata including language, framework, and target deployment environment.
outputs:
  status:
    type: string
    enum: [clean, warning, blocking]
    description: CI decision gate for the pull request.
  summary:
    type: string
    description: High-level audit narrative.
  findings:
    type: array
    description: List of detected security vulnerabilities with file, line, and remediation diff.
  metrics:
    type: object
    description: Telemetry covering lines reviewed and processing latency.
constraints:
  timeout_ms: 20000
  max_cost_usd: 0.03
  allowed_tools: [ast-grep, secret-scanner]
  temperature: 0.0
---

# PR Security Auditor Worker

You are an isolated AppSec review worker. Your single objective is to analyze the provided Git diff for high-severity security vulnerabilities and return a structured JSON audit envelope.

## Audit Checklist
1. **Injection Vulnerabilities:** Raw SQL string interpolation, unsanitized OS command execution (`exec`, `system`), unescaped template rendering (XSS).
2. **Secrets & Keys:** Hardcoded private keys, JWT secrets, AWS/API tokens, connection strings with credentials.
3. **Authentication & Authorization:** Broken permission checks, unauthenticated endpoints, missing CSRF tokens on state-mutating requests.
4. **Data Leakage:** Sensitive fields logged in plaintext, unmasked PII returned in API responses.

## Decision Rules
- If any finding has severity >= `severity_threshold` (default: `high`), `status` MUST be `"blocking"`.
- If only low-severity or informational findings exist, `status` MUST be `"warning"`.
- If zero findings exist, `status` MUST be `"clean"`.

Integration Code Examples#

Test and run this worker with schema-compliant payloads:

1. CLI Runner (Local Execution)

npx worker-md run workers/pr-security-auditor/WORKER.md \
  --input '{"diff":"@@ -14,3 +14,3 @@\\n- db.execute('SELECT * FROM users WHERE id = ?', [user_id])\\n+ db.execute(f'SELECT * FROM users WHERE id = {user_id}')","severity_threshold":"high"}'

2. HTTP Gateway (Stripe API Key)

curl -X POST https://gateway.worker.md/v1/workers/pr-security-auditor/invoke \
  -H "Authorization: Bearer wk_live_testkey123" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "diff": "@@ -14,3 +14,3 @@\\n- db.execute('SELECT * FROM users WHERE id = ?', [user_id])\\n+ db.execute(f'SELECT * FROM users WHERE id = {user_id}')",
    "severity_threshold": "high"
  }
}'

3. Autonomous Agent (HTTP 402 with Base USDC)

curl -X POST https://gateway.worker.md/v1/workers/pr-security-auditor/invoke \
  -H "Authorization: X402-Tx 0x4a8f9c2d1e0b5a...txhash" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "diff": "@@ -14,3 +14,3 @@\\n- db.execute('SELECT * FROM users WHERE id = ?', [user_id])\\n+ db.execute(f'SELECT * FROM users WHERE id = {user_id}')",
    "severity_threshold": "high"
  }
}'

4. Python (FastAPI / LangGraph)

import httpx

async def invoke_pr_security_auditor() -> dict:
    payload = {
    "diff": "@@ -14,3 +14,3 @@\\n- db.execute('SELECT * FROM users WHERE id = ?', [user_id])\\n+ db.execute(f'SELECT * FROM users WHERE id = {user_id}')",
    "severity_threshold": "high"
}
    async with httpx.AsyncClient() as client:
        response = await client.post(
            "https://gateway.worker.md/v1/workers/pr-security-auditor/invoke",
            headers={"Authorization": "Bearer wk_live_testkey123"},
            json={"inputs": payload},
            timeout=25.0
        )
        response.raise_for_status()
        return response.json()["outputs"]

Evaluation Fixtures & Benchmark Data#

Audit fixtures used to evaluate this worker specification:

{
  "suite": "pr-security-auditor-benchmark",
  "version": "1.0.0",
  "target_accuracy": 0.994,
  "fixtures": [
    {
      "id": "cwe-89-sql-injection",
      "description": "Direct string interpolation in raw SQL query",
      "input": {
        "diff": "@@ -14,3 +14,3 @@\n- db.execute('SELECT * FROM users WHERE id = ?', [user_id])\n+ db.execute(f'SELECT * FROM users WHERE id = {user_id}')",
        "severity_threshold": "high"
      },
      "expected": {
        "status": "blocking",
        "findings_count": 1,
        "rule_id": "CWE-89-SQL-INJECTION"
      }
    },
    {
      "id": "safe-sanitized-diff",
      "description": "Safe parameterization with input validation",
      "input": {
        "diff": "@@ -5,2 +5,3 @@\n+ const safeLimit = Math.min(Math.max(1, parseInt(req.query.limit)), 100);\n- const items = await fetchItems(req.query.limit);\n+ const items = await fetchItems(safeLimit);",
        "severity_threshold": "high"
      },
      "expected": {
        "status": "clean",
        "findings_count": 0
      }
    }
  ]
}

See also#

FAQ#

How do I invoke PR Security Auditor in my own pipeline?

You can invoke the worker package directly using the local CLI ('npx worker-md run workers/pr-security-auditor/WORKER.md --input ...') or deploy it to a private container gateway.

How does an autonomous agent pay via crypto?

An autonomous agent receives an HTTP 402 Payment Required response from the gateway, transfers 0.02 USDC to 0x89D24A6b4CcB1B6fAA2625fE562bDD9a23260359 on Base, and provides the transaction authorization header to execute.

How are timeout and cost constraints enforced?

The WORKER.md file declares the target limits (< 20s (Target), $0.03 (Ceiling)). The runtime execution harness enforces them with active process timers and token quotas.