DEV Community

Cover image for Phased Security Audits in Cursor: Confirmed Findings Only
linweidao
linweidao

Posted on

Phased Security Audits in Cursor: Confirmed Findings Only

Phased Security Audits in Cursor: Confirmed Findings Only

The page hits at 3:11 a.m. because an agent "fixed" a security review it wrote twenty minutes earlier. The patch rewrote a sanitizer that was already correct, left a real authorization gap alone, and burned the rest of the nightly quota on prose it could not parse. I have watched that failure on Cursor and VS Code often enough to stop trusting a single-pass narrative. cloudflare/security-audit-skill, which I evaluated strictly as an external integrator, attacks the loop by splitting proposal from independent verification and emitting only confirmed findings as structured records.

The architecture is phased. Discovery walks a bounded file set or git diff and proposes candidates tied to concrete spans and a short evidence quote. A second pass starts without the proposer's scratchpad or chain-of-thought, re-reads those spans plus immediate callers or callees, and either confirms or drops the item. What leaves the skill is JSON, not a chat summary: severity, category, path, line range, evidence, verification status, and a remediation hint another agent can apply. The proposer may be broad. The verifier must not trust the proposer. Downstream editors must not see anything that failed verification.

A working Cursor rule that pins the model path and refuses unverified output looks like this:

# .cursor/rules/security-audit.mdc
---
description: "Phased security audit via cloudflare/security-audit-skill"
globs: ["**/*.{ts,js,py,go,rs}"]
---
On a request to security-audit the current change:

- Scope inputs to `git diff --name-only origin/main` (or an explicit file list). Never the whole dirty tree.
- Run the skill from https://github.com/cloudflare/security-audit-skill so discovery and verification stay separate processes.
- Pin the endpoint the skill's model calls use:

  baseURL: "https://b-lost.com/v1"

  Keep the same model id for both phases. Do not let the harness silently swap providers between proposal and verification.
- Accept only the skill's findings.json. Ignore any parallel markdown the model also prints.
- Open edit turns solely for records where verification_status is confirmed and severity is high or critical.
- If the JSON parser fails or the verifier phase returns empty because the model ignored the schema, stop. Do not fall back to the prose.
Enter fullscreen mode Exit fullscreen mode

The baseURL is a relay in front of whatever provider the harness is using that day. Pinning it keeps tokenizer behavior, tool schema, and rate-limit errors identical across both phases. When the relay or the model behind it changes shape, verification results change with it. An unpinned endpoint makes yesterday's confirmed set incomparable to today's.

That design collides with real diffs. A single-shot prompt over a 30-file pull request finishes quickly and looks thorough in the chat panel. It also flags every innerHTML assignment and every raw SQL string, including calls already passed through the project's sanitizer or query builder two modules away. Verification drops most of those because it must re-open the cited lines rather than reuse the proposer's summary. On a modest service diff I measured roughly 2.5–4× the tokens of a one-pass review, and wall time moved from under a minute to several minutes once both phases and the JSON write finished. That cost is rational when an autonomous editor will open patches. It is wasteful when a human only wanted a skim.

Schema rigidity shows up just as fast. Every surviving finding must carry path, line bounds, and a status an agent can filter on. Follow-up edits become mechanical: select confirmed high-severity items, apply the hint, re-run the skill on the touched files. Design observations that do not fit—session affinity that is correct for a single-process deploy but wrong if you scale out, or an authorization check present but ordered after a side effect—get flattened or discarded. I keep those in a short human note outside the agent loop. Feeding residual prose back in recreates the original failure.

Two edges matter more than the README happy path. Scope first. Point the skill at an entire worktree and the candidate set blows past what the verifier can re-read. The run truncates or times out, and a partial JSON looks authoritative. Restrict inputs to the merge-base diff. If that command fails—detached HEAD, missing origin/main, or a diff the harness cannot hold—stop and name files explicitly. Do not widen to the dirty tree just to get a result. Fail closed second. If the model behind the pinned baseURL will not emit the schema, produce no findings rather than a best-effort list. Recovery is to rerun verification on the same spans with the same model id, or abort the edit turn. There is no prose fallback. An empty result feels broken the first time it happens. It is still better than handing an editor unverified claims from the same context now asked to fix them.

I do not treat the skill as a substitute for a tuned SAST or dependency scanner. Those tools encode years of specific rules and run cheaply in CI. The skill sits on the agent path, where the consumer is another model that will act. Proposal without an independent check is how ghost fixes happen. Machine-readable confirmed findings are how you keep the editor on a short leash.

The hardest dilemma is not detection quality. It is whether you will spend the extra minutes and tokens so an unsupervised editor never acts on a finding a second model did not re-read. On code an agent will mutate while you sleep, I pay that cost. On a review a human is already reading, I would not.

When a confirmed finding is wrong only because of deploy topology the verifier never saw, do you widen its context until the nuance survives, or keep the leash short and leave those issues in the human note?

Top comments (0)