Code RoomWebhook signature verification
HardPrep Room Coding #4359

Webhook signature verification

Vibe & agenticSecuritySenior–Staff~22 min

You're implementing the receiving end of Stripe-style webhooks in Node/TypeScript: verify the `Stripe-Signature` HMAC, reject forgeries and replays, and hand off valid events. You'll have an AI agent write the verifier. Write the prompt/spec — constraints, edge cases, acceptance criteria — so it's correct first try, given this guards money-moving events. What does a loose prompt ("verify the webhook signature") get dangerously wrong?

Implement
verify_webhook_events(secret: str, event_lines: list[str], now_seconds: int, tolerance_seconds: int) → list[str]
Examples
in["whsec_kernel",["evt_1|t=1749999990,v1=87a7370c|{\"id\":\"evt_1\",\"type\":\"charge.succeeded\",\"amount\":2000}","evt_1|t=1749999990,v1=87a7370c|{ \"id\": \"evt_1\", \"type\": \"charge.succeeded\", \"amount\": 2000 }"],1750000000,300]out["accepted","bad_signature"]
in["whsec_kernel",["evt_7|t=1749999999,v1=166bfbe4|{\"id\":\"evt_9\",\"type\":\"invoice.paid\",\"amount\":500}","evt_7|t=1749999999,v1=166bfbe4|{\"id\":\"evt_9\",\"type\":\"invoice.paid\",\"amount\":500}"],1750000000,300]out["accepted","duplicate"]
in["whsec_kernel",["evt_old|t=1749990000,v1=99b04ef0|{\"id\":\"evt_9\",\"type\":\"invoice.paid\",\"amount\":500}","evt_broken"],1750000000,300]out["stale","malformed"]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 22 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.