Harness security review

From Intense-Visions/harness-engineering · View interactive version

Harness security review is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Deep security audit combining mechanical scanning with AI-powered vulnerability analysis. OWASP baseline + stack-adaptive rules + optional threat modeling.

How to use this skill

Skill file

Harness Security Review

Deep security audit combining mechanical scanning with AI-powered vulnerability analysis. OWASP baseline + stack-adaptive rules + optional threat modeling.

When to Use

Scope Adaptation

This skill adapts its behavior based on invocation context — standalone or as part of the code review pipeline.

Detection

Check for pipelineContext in .harness/handoff.json. If present, run in changed-files mode. Otherwise, run in full mode.

# Check for pipeline context
cat .harness/handoff.json 2>/dev/null | grep -q '"pipelineContext"'

Changed-Files Mode (Code Review Pipeline)

When invoked from the code review pipeline (Phase 4 fan-out, security slot):

Findings returned in this mode must use the ReviewFinding schema with populated security fields (cweId, owaspCategory, confidence, remediation, references).

Full Mode (Standalone)

When invoked directly (no PipelineContext):

Principle: Layered Security

This skill follows the Deterministic-vs-LLM Responsibility Split principle. The mechanical scanner runs first and catches what patterns can catch. The AI review then looks for semantic issues that patterns miss — user input flowing through multiple functions to a dangerous sink, missing authorization checks, logic flaws in authentication flows.

Process

Phase 1: SCAN — Mechanical Security Scanner (full mode only)

Note: This phase is skipped in changed-files mode. See Scope Adaptation above.

Run the built-in security scanner against the project.

  1. Run the scanner. Use the harness check-security CLI command:

```bash

harness check-security

```

For machine-readable output, add --json. For scanning only changed files, add --changed-only.

  1. Review findings. Categorize by severity:
  1. Report mechanical findings. Present each finding with:

Phase 2: REVIEW — AI-Powered Security Analysis

After mechanical scanning, perform deeper AI analysis.

OWASP Baseline (always runs)

Review the codebase against OWASP Top 10 and CWE Top 25:

  1. Injection (CWE-89, CWE-78, CWE-79): Look for user input flowing to SQL queries, shell commands, or HTML output without sanitization. Trace data flow across function boundaries — patterns only catch single-line issues.
  1. Broken Authentication (CWE-287): Check for weak session management, missing MFA enforcement, hardcoded credentials, predictable tokens.
  1. Sensitive Data Exposure (CWE-200): Look for PII logged to console/files, sensitive data in error messages, missing encryption for data at rest or in transit.
  1. Broken Access Control (CWE-862): Check for missing authorization on API endpoints, IDOR vulnerabilities, privilege escalation paths.
  1. Security Misconfiguration (CWE-16): Check for debug mode in production configs, default credentials, overly permissive CORS, missing security headers.
Stack-Adaptive Review (based on detected tech)

After the OWASP baseline, add stack-specific checks:

Insecure Defaults Analysis

For each configuration variable that controls a security feature (auth, encryption, TLS, CORS, rate limiting), verify:

Patterns the mechanical SEC-DEF-* rules cannot catch (focus here):

Rationalizations to reject (adapted from Trail of Bits):

Phase 3: THREAT-MODEL (optional, `--deep` flag; full mode or explicit `--deep` in pipeline)

When invoked with --deep, build a lightweight threat model:

  1. Identify entry points. Find all HTTP routes, API endpoints, message handlers, CLI commands, and file upload handlers.
  1. Map trust boundaries. Where does data cross from untrusted (user input, external APIs) to trusted (database queries, file system, internal services)?
  1. Trace data flows. For each entry point, trace how user-controlled data flows through the system. Use the knowledge graph if available (query_graph, get_relationships).
  1. Identify threat scenarios. For each trust boundary crossing, ask:
  1. Report threat model. Present as a table:

| Entry Point | Data Flow | Trust Boundary | Threats | Controls | Risk |

|-------------|-----------|----------------|---------|----------|------|

Phase 4: REPORT — Consolidated Findings

Produce a unified security report:

Security Review: [PASS/WARN/FAIL]

Mechanical Scanner:
- Scanned: N files, M rules applied
- Coverage: baseline/enhanced
- Errors: N | Warnings: N | Info: N

[List each finding with rule ID, file:line, severity, and remediation]

AI Review:
- OWASP Baseline: [findings or "No issues found"]
- Stack-Adaptive ([detected stacks]): [findings or "No issues found"]

[If --deep]
Threat Model:
- Entry points: N
- Trust boundaries: N
- High-risk flows: [list]

Harness Integration

Rationalizations to Reject

| Rationalization | Reality |

| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| "The scanner didn't flag it so it must be fine" | Mechanical scanners catch pattern-level issues. They cannot trace user input across multiple function calls to a dangerous sink, detect authorization logic flaws, or evaluate whether a fallback chain fails open. The AI review phase exists precisely because scanners miss semantic vulnerabilities. |

| "This endpoint is behind authentication so we don't need to validate input" | Authentication and input validation are orthogonal controls. Authenticated users can still send malicious payloads. Authenticated SQL injection, SSRF, and path traversal are well-documented attack patterns against internal-only endpoints. |

| "The vulnerability requires knowing our internal schema to exploit" | Security through obscurity is not a control. Internal schema details leak through error messages, API responses, documentation, and employee turnover. Rate the vulnerability based on its impact assuming the attacker knows the system. |

| "We'll add rate limiting and input validation later once the feature ships" | Security controls added after deployment require re-testing and re-review. Shipping without them creates an exposure window and establishes technical debt that is systematically deprioritized once the feature is live. |

| "That's an OWASP theoretical risk — our app isn't targeted by sophisticated attackers" | OWASP findings are exploited by automated scanners, not just sophisticated attackers. Opportunistic bots continuously probe for SQL injection, XSS, and auth bypass. Unpatched OWASP Top 10 issues are routinely exploited within hours of exposure. |

Gates

Success Criteria

Escalation

Examples

Example: Clean Scan

Security Review: PASS

Mechanical Scanner:
- Scanned: 42 files, 22 rules applied
- Coverage: baseline
- Errors: 0 | Warnings: 0 | Info: 0

AI Review:
- OWASP Baseline: No issues found
- Stack-Adaptive (node, express): No issues found

Example: Findings Detected

Security Review: FAIL

Mechanical Scanner:
- Scanned: 42 files, 22 rules applied
- Coverage: baseline
- Errors: 2 | Warnings: 1 | Info: 0

Findings:
1. [SEC-SEC-002] ERROR src/config.ts:12 — Hardcoded API key or secret detected
   Remediation: Use environment variables: process.env.API_KEY
2. [SEC-INJ-002] ERROR src/db.ts:45 — SQL query built with string concatenation
   Remediation: Use parameterized queries: query("SELECT * FROM users WHERE id = $1", [id])
3. [SEC-NET-001] WARNING src/cors.ts:8 — CORS wildcard origin allows any website to make requests
   Remediation: Restrict CORS to specific trusted origins

AI Review:
- OWASP Baseline: 1 finding — user input from req.params.id flows through formatQuery() to db.execute() without sanitization (confirms SEC-INJ-002 with data flow trace)
- Stack-Adaptive (node, express): Missing helmet middleware, missing rate limiting on /api/* routes

Example: Deep Audit with Threat Model

Security Review: WARN

Mechanical Scanner:
- Scanned: 120 files, 30 rules applied
- Coverage: baseline
- Errors: 0 | Warnings: 2 | Info: 3

AI Review:
- OWASP Baseline: No critical issues
- Stack-Adaptive (node, react): localStorage used for session token (SEC-REACT-001)

Threat Model:
- Entry points: 12 (8 REST endpoints, 2 WebSocket handlers, 2 CLI commands)
- Trust boundaries: 4 (client→API, API→database, API→external service, CLI→filesystem)
- High-risk flows:
  1. POST /api/upload → file stored to disk without size limit or type validation
  2. WebSocket message handler passes user data to eval-like template engine
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.