How CodePeel's OWASP Security Scanning Works
A technical walkthrough of the security review pass: deterministic diff checks, the OWASP/CWE-focused SAST analysis, custom rules, and the noise gates that decide what reaches your pull request.
Every CodePeel review passes changed code through a dedicated security analysis before any comment reaches your pull request. Whether initiated in GitHub, inside our VS Code extension, or via the Claude Code MCP server, this security pass executes prior to general code review comments.
Key Takeaways
- Dual-Layer Architecture: Combines zero-latency deterministic regex diff pattern matchers with a targeted, zero-temperature LLM SAST analysis.
- Standardized Weakness Taxonomy: Findings cite standardized identifiers from OWASP Top 10 and MITRE CWE rather than vague advice.
- Strict Redaction Protocol: Credentials detected in problematic diff lines are automatically masked before persisting to databases or dashboards.
- Noise Gate Filtering: Opinionated style advice on small diffs is suppressed, preserving high developer signal-to-noise ratios.
OWASP security scanning is a dual-layer static analysis system designed for fast code review. It prioritizes actionable, exploit-ready vulnerabilities over theoretical security lectures.
This deep dive walks through the deterministic checks on raw diffs, model-driven SAST analysis, custom repository rules, and noise-filtering gates.
Two layers: deterministic checks and model analysis
The scanning pipeline separates detection into two specialized layers:
Incoming Pull Request Diff
│
┌───────────────┴───────────────┐
▼ ▼
Layer 1: Deterministic Layer 2: Model SAST
(Regex Pattern Matchers) (Zero-Temp Security LLM)
- Hardcoded Credentials - OWASP Top 10 Flaws
- Reserialized Webhook HMAC - Broken Authorization
- Custom Repo Rules - Input Injection (CWE-89)
│ │
└───────────────┬───────────────┘
▼
Noise-Filter Gates
(Severity Capping + Fix Checks)
▼
Inline Findings & Auto-Fix PR
- Deterministic analysis: Plain pattern checks execute against raw diff chunks before model invocation. They execute instantaneously, never hallucinate, and produce identical outputs on repeated runs.
- Deep static analysis (SAST): A targeted language model evaluates semantic context using a security-only instruction set. It searches for OWASP Top 10 categories, injection vectors, broken authentication, and resource exhaustion bugs.
Both engines emit normalized finding objects: file path, line number, severity level, weakness classification, problematic code snippet, and a verified code replacement.
Deterministic checks on raw diff text
Two dangerous patterns appear repeatedly in rapid development. Because both have clear signatures, CodePeel evaluates them deterministically line by line.
1. Hardcoded secret fallbacks (CWE-798)
Developers frequently add fallback literals during local testing, intending to delete them before merging:
// Flagged: Predictable fallback credential
const token = process.env.AUTH_TOKEN || "dev-token-12345";
The matcher inspects environment variables containing SECRET, API_KEY, ACCESS_KEY, PRIVATE_KEY, or AUTH_TOKEN coupled with an inline || fallback string. When detected, CodePeel raises a high severity finding with a fail-closed replacement:
// Suggested fix: Fail closed when configuration is missing
const rawToken = process.env.AUTH_TOKEN;
if (!rawToken) throw new Error('AUTH_TOKEN is required');
const token = rawToken;
This simple check prevents temporary staging credentials from lingering in permanent git commit history.
2. Webhook signatures over reconstructed bodies (CWE-352)
A frequent signature verification bug occurs when computing an HMAC over re-serialized JSON instead of original raw payload bytes:
// Flagged: Signature computed over re-serialized JSON string
const isValid = verifyHmac(JSON.stringify(req.body), req.headers['x-signature']);
Webhooks require cryptographic verification over the exact byte stream emitted by the sender. Parsing a payload into an object and serializing it back to text alters whitespace, reorders object keys, and changes number precision. Verification either fails intermittently or allows attackers to bypass checks via crafted payloads.
CodePeel detects JSON.stringify(req.body) within webhook verification diffs and directs developers to their web framework's raw body hook:
// Suggested fix: Verify against raw request buffer
const rawBody = req.rawBody;
if (!rawBody) throw new Error('Raw request body is required for signature verification');
The SAST pass: OWASP Top 10 and CWE classes

The model-driven SAST engine evaluates diffs within strict boundaries:
- Security scope exclusively: The analyzer is barred from commenting on formatting, syntax preferences, or non-security logic.
- Explicit weakness taxonomy: Explanations must cite applicable MITRE CWE identifiers, such as CWE-89 for SQL Injection or CWE-79 for Cross-Site Scripting.
- Exploitability over speculation: Warnings flag realistic attack vectors and structural risks rather than theoretical edge cases.
- Structured JSON contract: The model returns typed arrays containing file paths, line numbers, severity (
criticalorwarning), and copy-paste patches. - Zero-temperature reproducibility: Requests run at temperature zero to ensure deterministic findings across duplicate pull request commits.
| Vulnerability Type | Primary CWE | Detection Layer | Auto-Fix Compatible |
|---|---|---|---|
| Hardcoded Secret Fallback | CWE-798 | Deterministic Diff Regex | Yes |
| Reserialized Webhook HMAC | CWE-352 | Deterministic AST Matcher | Yes |
| SQL & Query Injection | CWE-89 | Semantic Model SAST | Yes |
| Cross-Site Scripting (XSS) | CWE-79 | Semantic Model SAST | Yes |
| Broken Access Control | CWE-284 | Semantic Model SAST | Manual |
| Unbounded Cache Growth | CWE-400 | Model Pattern Matcher | Yes |
Resource-exhaustion anti-patterns (CWE-400)
Beyond standard OWASP categories, the SAST pass identifies common resource exhaustion anti-patterns. Unbounded in-memory collections (maps, arrays, or object caches lacking eviction policies) and unindexed N+1 database queries are caught directly in the diff before production deployments.
Automated secret redaction in findings
When a finding quotes code containing API keys or passwords, the engine wraps secrets in [SECRET]...[/SECRET] delimiters within the payload. The server strips and sanitizes these tokens before persisting records to database storage or rendering them on dashboards.
Redaction serves as a protective backstop. If real credentials reach a public pull request, treat them as compromised immediately. Consult our security architecture guide for data retention details.
Custom repository compliance rules
Teams can enforce custom security standards via repository YAML configuration in the web dashboard:
rules:
- id: no-direct-db-calls
message: "Execute queries via the repository layer instead of calling raw database drivers."
pattern: "\\.query\\("
paths: ["src/api/**"]
severity: high
category: security
Custom rules evaluate against added diff lines (+ hunks) with directory path scoping. Rules are also injected into the model's instruction prompt, allowing the AI to explain violations in context rather than relying on blind pattern matches.
Noise-reduction filtering gates
Excessive warnings lead to notification fatigue. CodePeel routes raw findings through three noise gates:
- Suppression on small changes: Architecture commentary is suppressed on diffs smaller than 120 lines. Small PRs do not require architectural redesign notes.
- Per-file finding caps: Findings are ranked by severity, keeping only high-impact issues. A single noisy file cannot overwhelm the pull request.
- Actionability requirement: General suggestions like "consider adding validation" are dropped unless accompanied by concrete code remedies.
These filters ensure surfaced findings are severe, actionable, and compatible with our auto-fix PR generation engine.
Enforcing security at the merge gate
Security findings integrate directly with GitHub branch protection via pre-merge gates. By enabling the security_blocker gate, any unaddressed security flaw sets a failing commit status, preventing developers from merging vulnerable code. Read A Guide to CodePeel's Pre-Merge Quality Gates for branch protection setup.
To measure how effectively your automated gates catch real vulnerabilities, compare your results against our seeded corpus methodology in How to Benchmark an AI Code Reviewer.
Understanding scanner boundaries
A responsible security pipeline defines its operational limits:
- Diff analysis scope: Scanning examines changed files in the active pull request. It does not replace full-repository SAST tools or dynamic runtime analyzers.
- Probabilistic detection: While deterministic rules are absolute, semantic AI analysis can miss subtle logic flaws. Treat findings as guided investigations rather than guarantees.
- Repository history: Scans inspect the active commit diff. Hardcoded secrets committed in historical revisions require dedicated git-history scanning tools.
Testing the scanner on a practice branch
To observe the pipeline in action, add a fallback credential like process.env.TEST_KEY || "temp-secret" on a test branch and open a pull request. You can also run the review pre-commit using the VS Code extension or via the Claude Code MCP server.
