Guides
Security
A payments library has to fail safely. These rules hold in all five SDKs, and each has a test.
The rules
- No automatic retries of payments. A retried STK Push or payout can charge or pay someone twice.
- HTTPS only. Your consumer secret travels to the Daraja base URL, so plain
http://is refused unless it points at your own machine. - No redirects. A redirect could forward your token or credentials elsewhere, so the SDKs refuse to follow one.
- Secrets stay out of logs. Logging or printing a client shows its base URL and shortcode, never the consumer secret, passkey or initiator password.
- Input is checked before it's sent. Phone numbers, amounts, lengths and URLs.
- Callbacks are untrusted. They aren't signed, so the parsers reject malformed bodies and ignore fields they don't know.
Your side
- Keep credentials in environment variables or a secret manager.
- Never call Daraja from a mobile or browser app.
- Confirm every callback with Daraja before you deliver.
- Make your callback URLs hard to guess, and log every callback you receive.
- Store each payment's
CheckoutRequestIDororiginatorConversationIdbefore you call, so you can always reconcile.
Reporting a vulnerability
Please don't open a public issue. See SECURITY.md for how to report privately.