McTaba Labs logo
Software EngineeringThe WhiteboardProjectsEventsMasterclassesWebinarsLearn
Book Call

500+ developers already in the community

Get answers, find accountability partners, and stay ahead

Join Discord →
McTaba Labs logo

Educating 1 million students in tech by 2030.

Programs

  • HighSchool Graduates Launchpad
  • AI & Business Automation
  • Corporate Training
  • McTaba Story & Mission
  • Full-Stack Curriculum
  • Course Pricing & Plans
  • Frequently Asked Questions

Resources

  • Join Discord Community
  • Tech Events in Nairobi
  • Masterclasses
  • Free Resources
  • Learn
  • Campus
  • Africa Tech Talent Report
  • Partner With Us
  • Start a Project
  • Our Work

Contact Us

  • 124 Manyani East Road, Lavington, Nairobi
  • +254727795603
  • Book a Discovery Call

Office Hours:

Mon-Fri: 9am - 2pm EAT

Sat: 10am - 12pm EAT

© 2027 McTaba Labs - A product of Edtech Industries. All rights reserved.

Privacy PolicyTerms of ServiceRefund Policy
  1. Learn
  2. Paystack for African Developers
  3. What to Do If Your Paystack Secret Key Leaked
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

What to Do If Your Paystack Secret Key Leaked

Rotate the key immediately on the Paystack dashboard. Do not investigate first. Rotate first, then check your transaction and transfer history for unauthorized activity. Update all deployments with the new key. Review audit logs. Contact Paystack support if you find unauthorized transactions. Then install prevention measures like pre-commit hooks and secret scanning.

In this article

  1. 1. Step 1: Rotate the Key Immediately
  2. 2. Step 2: Update All Deployments
  3. 3. Step 3: Assess the Damage
  4. 4. Step 4: Contact Paystack Support
  5. 5. Step 5: Investigate How the Leak Happened
  6. 6. Step 6: Install Prevention Measures
  7. 7. Documenting the Incident

Step 1: Rotate the Key Immediately

Do not investigate how the leak happened. Do not try to figure out who has the key. Do not check if anyone has used it yet. Rotate first. Investigate second.

Every minute the old key is active after a leak is a minute an attacker can use it to move money out of your account. The investigation can wait. The rotation cannot.

  1. Log in to the Paystack dashboard at dashboard.paystack.com
  2. Go to Settings, then API Keys & Webhooks
  3. Generate new keys
  4. Copy the new secret key immediately. Paystack will not show it again after you navigate away.

The old key is invalid the moment you generate new ones. Any request using the old key will return 401 Unauthorized. This means your live application will also break until you update it with the new key. That is acceptable. A few minutes of payment downtime is vastly better than an attacker draining your account.

Step 2: Update All Deployments

With the new key in hand, update every place the old key was used:

  • Production server environment variables. Update on Vercel, Railway, Render, or wherever your app runs.
  • Staging and development environments. If you leaked a test key, update those too.
  • Background workers and cron jobs. Any service that calls the Paystack API needs the new key.
  • Webhook handlers. Your webhook signature verification uses the secret key. Update it or webhooks will fail verification.
  • Third-party services. If you stored the Paystack key in a third-party service (a no-code tool, a Zapier integration, a monitoring service), update those too.

Trigger redeployments for all affected services. Verify each one processes a test transaction successfully before moving on.

For detailed platform-specific update instructions, see Paystack keys in Vercel, Railway and Render.

Get weekly developer tips

Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.

No spam. Unsubscribe anytime.

Step 3: Assess the Damage

Now that the key is rotated and your services are running with the new key, investigate what happened during the exposure window.

Determine the Exposure Window

Figure out when the key was first exposed and when you rotated it. The exposure window is the time between these two events. If the key was committed to a public GitHub repo three weeks ago and you just discovered it, the exposure window is three weeks.

Review Transaction History

In the Paystack dashboard, go to Transactions and filter by the exposure window. Look for:

  • Transactions you do not recognize
  • Transactions with unusual amounts
  • Transactions from customers you do not recognize
  • Transactions at unusual times (middle of the night in your timezone)

Review Transfer History

Transfers are the most dangerous thing an attacker can do with your key. Go to Transfers in the dashboard and look for any transfers you did not initiate. An attacker can create a transfer to send money from your Paystack balance to any bank account.

Review API Logs

If you have application-level logging, search your logs for Paystack API calls during the exposure window. Look for calls you did not make, especially to the /transfer endpoint.

Check Customer Data Access

An attacker with your secret key can read all customer data: emails, names, card details (last four digits and expiry), and transaction history. If you believe customer data was accessed, you may have a data breach notification obligation under the Kenya Data Protection Act or Nigeria Data Protection Act.

Step 4: Contact Paystack Support

If you find unauthorized transactions or transfers, contact Paystack support immediately:

  • Email: support@paystack.com
  • Dashboard: Use the in-app chat/support feature

When you contact them, provide:

  1. Your business name and Paystack account email
  2. The exposure window (when the key was leaked and when it was rotated)
  3. A list of suspicious transactions or transfers (include references)
  4. How the key was leaked (git commit, log file, etc.)

Paystack may be able to:

  • Freeze suspicious transfers before they settle
  • Provide API access logs showing which endpoints were called with your key
  • Help identify the source of unauthorized activity
  • Guide you through any regulatory notification requirements

Even if you do not find unauthorized activity, it is good practice to notify Paystack that a key rotation happened due to a security incident. They may have additional visibility into your account activity that you do not have from the dashboard.

Step 5: Investigate How the Leak Happened

With the immediate crisis handled, find and fix the root cause. Common sources of Paystack key leaks:

Git Commits

The most common source. The key was hardcoded in a source file or a .env file that was committed. Scan your repository:

git log -p --all -S 'sk_live_' -- .
git log -p --all -S 'sk_test_' -- .

If found, clean the git history with git filter-repo and install pre-commit hooks. See detection and remediation for committed keys.

Log Files

Application logs, error tracking services (Sentry, Bugsnag), or request logging middleware may have captured the key in Authorization headers or request bodies. Search your logging service for sk_live_ and sk_test_ patterns.

Chat Messages and Documentation

Keys shared through Slack, WhatsApp, email, or internal documentation. These are harder to find but important to clean up. Delete the messages or documents containing the key.

Client-Side Exposure

The secret key was accidentally used in frontend code (using NEXT_PUBLIC_ prefix for the secret key, or passing it in a client-side API response). Check your frontend bundle and API responses.

Team Member Departure

A former team member retained access to the key after leaving. This is not a "leak" in the traditional sense, but it is a security risk. Rotation is the correct response.

Step 6: Install Prevention Measures

After resolving the incident, put measures in place to prevent it from happening again:

  1. Pre-commit hooks. Install git-secrets or gitleaks as a pre-commit hook to block commits containing key patterns.
  2. CI pipeline scanning. Add gitleaks to your CI pipeline to catch keys that bypass pre-commit hooks.
  3. GitHub secret scanning. Enable secret scanning and push protection on your GitHub repository.
  4. Environment variable validation. Add startup checks that verify keys are loaded from environment variables, not hardcoded.
  5. Logging sanitization. Configure your logging to redact Authorization headers and any values matching the sk_ pattern.
  6. Access audit. Review who has access to your Paystack dashboard and hosting platform. Remove unnecessary access.

For detailed setup instructions for each measure, see detection and remediation for committed keys.

Documenting the Incident

Write an internal incident report. This is important for team learning, for compliance requirements, and for demonstrating due diligence if a regulatory question arises later.

A good incident report covers:

  • Timeline. When the key was exposed, when the exposure was discovered, when the key was rotated, and when the incident was fully resolved.
  • Impact. Were any unauthorized transactions or transfers made? Was customer data accessed?
  • Root cause. How was the key exposed?
  • Response actions. What did you do to contain and resolve the incident?
  • Prevention measures. What changes are being made to prevent recurrence?

Store the report securely. It may contain sensitive details about your security posture and should not be publicly accessible.

Key Takeaways

  • ✓Rotate the leaked key immediately on the Paystack dashboard before doing anything else. Every second the old key is active is a second an attacker can use it.
  • ✓An attacker with your secret key can verify transactions, initiate transfers out of your account, read all customer data, create subscriptions, and issue refunds.
  • ✓After rotation, review your Paystack transaction history and transfer logs for any activity you did not authorize during the exposure window.
  • ✓Update all deployment environments with the new key and verify payments work before considering the incident resolved.
  • ✓Contact Paystack support immediately if you find unauthorized transactions or transfers. They may be able to reverse or freeze suspicious activity.
  • ✓Install pre-commit hooks, CI scanning, and GitHub secret scanning to prevent future leaks.

Frequently Asked Questions

How quickly do attackers exploit leaked keys?
Automated bots scan public GitHub repositories continuously. Leaked API keys on public repos can be discovered and exploited within minutes. Even on private repos, you should assume the key could be used as soon as anyone with access sees it.
I leaked a test key, not a live key. Is it still a problem?
A test key cannot move real money, but it gives full API access in test mode. An attacker can read test customer data, create test transactions, and understand your integration architecture. Rotate it and treat it as a security incident, just a lower severity one.
Can Paystack tell me if someone used my leaked key?
Contact Paystack support. They may have API access logs that show which endpoints were called with your key, from which IP addresses, and at what times. This information helps you assess whether the leak was exploited.
What if the leak was weeks ago and I just discovered it?
Rotate immediately. The exposure window is longer, which means more potential for unauthorized activity. Review your full transaction and transfer history for the entire period. Contact Paystack support even if you do not find anything suspicious.
Do I need to notify my customers about the leak?
It depends on whether customer data was accessed and which data protection law applies. Under the Kenya Data Protection Act and Nigeria Data Protection Act, you may be required to notify affected individuals and the data protection authority if personal data was compromised. Consult a legal advisor if you believe customer data was accessed.

Learn Paystack Integration

KES 2,999

The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.

Start Paystack Course

Not ready? Create Free Account

Keep reading

Paystack Security, Keys and PCI Compliance: Complete Guide

A complete security reference for Paystack integrations. Covers API key types and rotation, secure key storage, PCI DSS compliance scope, price tampering prevention, webhook replay attacks, rate limiting, fraud signals, and logging without exposing secrets.

Read more

Never Commit Your Paystack Key: Detection and Remediation

Committing a Paystack secret key to version control is one of the most common and most dangerous mistakes in payment integrations. This guide shows you how to detect committed keys, set up automated prevention with pre-commit hooks, and remediate the damage when a key does slip through.

Read more

Replay Attacks on Paystack Webhooks

A replay attack captures a legitimate Paystack webhook and sends it to your server again. The signature is valid because the payload is unchanged. Without idempotency checks, your server processes the same payment twice, granting double value to the attacker. This guide shows how to defend against replays.

Read more

Logging Payments Without Logging Secrets

Good payment logging helps you debug failed charges and reconcile transactions. Bad payment logging leaks your Paystack secret key, card tokens, or customer data into log files that attackers can read. This guide draws a clear line between safe and dangerous payment log data.

Read more

Paystack Split Not Applied to Transaction

You set up a split on Paystack, but the transaction settled entirely to your main account. The split was not applied. Here is why it happens and how to fix it.

Read more

Explore related topics

M-Pesa & African Stack

M-Pesa Daraja API tutorials, USSD development, and WhatsApp Business API guides. The African Stack that global bootcamps do not teach.

Learn to Code in Kenya

Everything a Kenyan needs to know before writing their first line of code. Career paths, real costs, hardware requirements, and honest answers about what it takes.

Learning to Code

Roadmaps, language guides, and practical advice for learning to code and launching a programming career.

Breaking Into Tech

Practical, no-nonsense guides for anyone looking to start or change their career in tech. From choosing your first language to acing interviews.

The African Stack: Skills for This Market

The skills that make Kenyan developers hard to replace: M-Pesa, USSD, WhatsApp, fintech, and building for the African market.

Bonaventure Ogeto

Bonaventure Ogeto

Founder, McTaba Labs

Bonaventure is the founder of McTaba Labs, a coding bootcamp in Nairobi, Kenya. He has spent years building products for the African market and mentoring the next generation of developers across the continent.