ProSkillsLibraryFreePassScan
Code Review

Code Review · agent skill

Security Review

Exploit sketch, severity and fix for each finding.

What it does

Loads when it is needed

Your agent loads it when the change touches auth, user input, outbound requests, secrets or an LLM feature. It carries 5 rules and reads a profile.md with your details before it starts, so the output matches your brand and project.

Same prompt, with and without

Security review of two new routes

Prompt · Security review this change before it ships. The app holds customer invoices.

src/routes/preview.ts (new)
12 router.post("/api/link-preview", requireAuth, async (req, res) => {
13   const html = await (await fetch(req.body.url)).text();
14   const title = /<title>(.*?)<\/title>/i.exec(html)?.[1] ?? "";
15   res.json({ title, html });
16 });

src/routes/files.ts (new)
30 router.get("/api/invoices/:id/pdf", requireAuth, async (req, res) => {
31   const inv = await db.query(`SELECT * FROM invoices WHERE id = ${req.params.id}`);
32   res.sendFile(path.join(PDF_DIR, inv.rows[0].file_name));
33 });

Both routers are mounted behind requireAuth. Invoice ids are sequential integers.

Profile used: Project: B2B invoicing app with customer PII; Stack: Node, Express, Postgres (pg); Strictness: Standard; Conventions: session user is req.user (has customerId)

Without the skill
Both routes have serious problems. **1. /api/link-preview: SSRF (high).** The server fetches any user-supplied URL, so a user can reach internal services, cloud metadata (169.254.169.254) or localhost, and the full response body is returned in `html`. Fix: allow only http/https, resolve DNS and block private/loopback/link-local ranges (re-check after redirects), cap redirects, set a timeout and size limit, and return only the title. **2. /api/invoices/:id/pdf: SQL injection (critical).** `req.params.id` is interpolated straight into the query. Use `db.query("SELECT * FROM invoices WHERE id = $1 AND customer_id = $2", [id, req.user.customerId])`. **3. Same route: IDOR (high).** Ids are sequential and there's no ownership check, so any logged-in user can enumerate other customers' invoices. The customerId filter above fixes it. Return 404 when no row matches. **4. Null handling and path traversal.** `inv.rows[0]` is undefined when nothing matches, which crashes. Also make sure `file_name` can't contain `../`: use `path.basename`, or resolve and verify the result stays inside PDF_DIR. Being behind requireAuth only means "logged in", not "authorized". Consider UUIDs for invoice ids as defense in depth, and add tests for cross-customer access.
With the skill
Scope: POST /api/link-preview, GET /api/invoices/:id/pdf. Any logged-in user controls `url` and `:id`. Invoices hold PII. [High] src/routes/preview.ts:13 SSRF (A10) Exploit: a user posts url=http://169.254.169.254/latest/meta-data/iam/security-credentials/; line 15 returns the fetched body, so cloud credentials come back in the response. Fix: parse the URL, allow http/https only, resolve DNS and reject private, loopback and link-local IPs, `redirect: "manual"`, timeout and size cap. Return only `title`, never `html`. [High] src/routes/files.ts:31 SQL injection (A03) Exploit: GET /api/invoices/0%20OR%201=1 is interpolated into the query; a UNION SELECT reads any table. Fix: `db.query("SELECT * FROM invoices WHERE id = $1 AND customer_id = $2", [req.params.id, req.user.customerId])`. [High] src/routes/files.ts:31 Broken object-level authorisation (A01) Exploit: with sequential ids, a user loops 1, 2, 3... and downloads every customer's PDF; nothing compares the owner to the session. The query above fixes it (foreign id returns 404). Add a two-user test. Looked at, no issue: line 32 joins a DB value (`file_name`), not request input; safe only if upload code validates names (outside this diff). Not covered: auth middleware, upload code, dependencies, infrastructure. This review reads source code only and does not replace a penetration test.

Both answers from the same model (Claude sonnet), 2026-10-16. The one without the skill was written in a separate session that never saw it. Shortened where marked with …

Install

One command, in your project

It detects your agent; add --agent all for every agent.

npx proskills-cli add security-review --order <order id from your receipt>

Or copy the skill folder (the one holding SKILL.md) into the directory your agent reads, then restart it or start a new session.

AgentThis projectEvery project
Claude Code.claude/skills/~/.claude/skills/
Cursor.agents/skills/ (or .cursor/skills/)~/.cursor/skills/
Codex.agents/skills/~/.agents/skills/
Gemini CLI.agents/skills/ (or .gemini/skills/)~/.gemini/skills/

Changelog

What changed

  • v1.0.0 · 2026-10-16
    • First versioned release: Exploit sketch, severity and fix for each finding.
    • Scanned 100/100 before release.

Keep it current with npx proskills-cli update; your profile.md is never touched. Everyone who bought it gets the update free and an email when it lands.

Same collection

More from Code Review

The scan checks spec compliance, token cost, clarity and security patterns. A clean scan is not a guarantee: static scanners can be evaded. Scan any skill yourself.