pitcheye.dev← All 30 rules
severity: errorpack: webhooksv1.0 core

webhooks/unverified-signature

Webhook parses the body without verifying its signature

npx @pitcheye/check . --pack webhooks

whyItBreaks

A webhook URL is public and unguessable at best. Without a signature check, anyone who learns it can POST a forged `checkout.session.completed` and the handler will mark orders paid, credit balances, or flip a subscription — a full business-logic compromise with no credentials at all.

✖ Bad — triggers errorfixtures/webhooks-unverified-signature/bad
export async function POST(req: Request) {
  const event = await req.json();
  await markPaid(event.id);
}
✓ Good — passes checkfixtures/webhooks-unverified-signature/good
export async function POST(req: Request) {
  const raw = await req.text();
  const event = stripe.webhooks.constructEvent(raw, sig, secret);
  await markPaid(event.id);
}

suggestedFix

Read the RAW body (`await req.text()`), then verify it: `stripe.webhooks.constructEvent(rawBody, sig, secret)` (or `Webhook.verify` for Svix/Clerk/Resend). JSON-parsing first also breaks the signature — the exact bytes matter.

explain_rule({"webhooks/unverified-signature"})

Agent & MCP JSON output contract

{
  "ruleId": "webhooks/unverified-signature",
  "pack": "webhooks",
  "severity": "error",
  "file": "apps/web/src/app/api/uploadthing/core.ts",
  "line": 6,
  "message": "a webhook handler calling `await req.json()` with no `constructEvent`/`verify` in the file",
  "whyItBreaks": "A webhook URL is public and unguessable at best. Without a signature check, anyone who learns it can POST a forged `checkout.session.completed` and the handler will mark orders paid, credit balances, or flip a subscription — a full business-logic compromise with no credentials at all.",
  "suggestedFix": "Read the RAW body (`await req.text()`), then verify it: `stripe.webhooks.constructEvent(rawBody, sig, secret)` (or `Webhook.verify` for Svix/Clerk/Resend). JSON-parsing first also breaks the signature — the exact bytes matter.",
  "docsUrl": "https://pitcheye.dev/rules/webhooks-unverified-signature"
}

Markdown: curl -H "Accept: text/markdown" https://pitcheye.dev/rules/webhooks-unverified-signature

raw markdown
# webhooks/unverified-signature

- **severity:** error
- **pack:** webhooks
- **docs:** https://pitcheye.dev/rules/webhooks-unverified-signature

## whyItBreaks

A webhook URL is public and unguessable at best. Without a signature check, anyone who learns it can POST a forged `checkout.session.completed` and the handler will mark orders paid, credit balances, or flip a subscription — a full business-logic compromise with no credentials at all.

## bad

```ts
export async function POST(req: Request) {
  const event = await req.json();
  await markPaid(event.id);
}
```

## good

```ts
export async function POST(req: Request) {
  const raw = await req.text();
  const event = stripe.webhooks.constructEvent(raw, sig, secret);
  await markPaid(event.id);
}
```

## suggestedFix

Read the RAW body (`await req.text()`), then verify it: `stripe.webhooks.constructEvent(rawBody, sig, secret)` (or `Webhook.verify` for Svix/Clerk/Resend). JSON-parsing first also breaks the signature — the exact bytes matter.

## commands

```bash
npx @pitcheye/check . --pack webhooks
```

```json
{"tool":"explain_rule","arguments":{"ruleId":"webhooks/unverified-signature"}}
```
← uploadthing/missing-size-or-mime-limitBack to rule catalogwebhooks/payment-update-missing-idempotency →