r/AskNetsec • u/mwateejudah • 5h ago
Architecture How do you authenticate payment-provider webhooks when the provider doesn’t sign the payload (e.g. M-PESA Daraja callbacks)?
I build systems that receive payment confirmations from Safaricom’s M-PESA Daraja API (STK Push and C2B callbacks). As far as I can tell, Daraja doesn’t send an HMAC signature or similar with its callbacks, unlike Stripe or GitHub webhooks, so the receiving endpoint can’t cryptographically verify that a callback really came from Safaricom.
Current mitigations I’m aware of or using:
- Allowlisting Safaricom’s published callback IP ranges
- A long random secret token in the callback URL path
- Treating the callback only as a hint, then confirming the payment with an outbound Transaction Status query before marking anything paid
- Idempotency on the transaction ID so replayed callbacks can’t double-credit
My specific question: is the outbound “confirm before trust” query enough on its own to treat inbound callbacks as untrusted, or are there attack paths I’m missing (e.g. race conditions between callback and confirmation, or manipulation of the confirmation response)? How do others handle unsigned webhooks from payment providers in production?