Webhook Endpoints Validate Sender
Why it matters
Webhook endpoints that process payloads without verifying the sender's signature accept forged requests from anyone who knows the endpoint URL. An attacker can POST a fabricated payment_succeeded event to trigger order fulfillment without paying, or a user.deleted event to wipe accounts. CWE-345 (Insufficient Verification of Data Authenticity) and CWE-347 (Improper Verification of Cryptographic Signature) define this failure. OWASP A02 (Cryptographic Failures) covers the broader category. NIST 800-53 SC-8 requires data integrity protection in transit — webhook signature verification is the enforcement mechanism for inbound event streams.
Severity rationale
Medium because exploitation requires knowing the webhook URL, but the business impact of forged events (fake payments, account manipulation) can be severe and irreversible.
Remediation
Verify the webhook signature before processing any payload. Read the body as raw text before parsing — webhook providers sign the raw bytes, and parsing first invalidates the signature.
// app/api/webhooks/stripe/route.ts
export async function POST(req: NextRequest) {
const body = await req.text(); // Raw text — not req.json()
const signature = req.headers.get('stripe-signature');
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(body, signature!, process.env.STRIPE_WEBHOOK_SECRET!);
} catch (err) {
return NextResponse.json({ error: 'Signature verification failed' }, { status: 400 });
}
// Safe to process event.type
}
Every major webhook provider (Stripe, Clerk, GitHub, Svix) offers a signature mechanism — use the provider's official SDK method rather than rolling your own HMAC check.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Authorization Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-345 — Insufficient Verification of Data Authenticity
- cwe · CWE-347 — Improper Verification of Cryptographic Signature
- owasp:2021 · A02
- nist:rev5 · SC-8 — Transmission Confidentiality and Integrity
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-authorization·automated