Security

Crypto API Key Security: Emergency Recovery Guide

2026-11-23·9 min read

Your trading bot is running, but someone is quietly draining your assets with your API Key. The first reaction when you discover this is often "change the password" — but that's not enough. The hacker may have already bound their own devices, set up withdrawal addresses, or even created new API Keys.

This article walks you through the emergency recovery process for Binance and OKX, the two largest exchanges. Every step is based on official documentation and security team guidance, not speculation. If you're currently experiencing account theft, skip directly to Binance Recovery or OKX Recovery.

If you've just noticed something wrong, stop all automated trading tools first, then follow the steps below. Continuing to run your bot is like handing the keys to a thief.

How Are API Keys Stolen?

An API Key (Application Programming Interface key, which lets your trading bot communicate automatically with an exchange) is not a password, but serves the same function: whoever has it can execute trades, check balances, and even withdraw assets (if the Key has withdrawal permissions enabled). Common methods hackers use to obtain API Keys:

  • Malware (keyloggers): Trojans installed on your computer scan code repositories, environment variable files, or clipboard for API Keys.
  • Phishing sites: Fake Binance or OKX login pages trick you into entering your credentials, then lure you into "verifying" your API Key.
  • Social engineering phone scams: Fraudulent customer service calls claim your account is compromised and ask you to adjust permissions on the API settings page — when in reality they're enabling withdrawal access for themselves. Binance published a warning specifically about this method in August 2025.
  • Public code repository leaks: Writing API Keys into GitHub or other version control systems makes them searchable by anyone.
If you haven't had issues yet, read our [API Key Permissions Checklist](/blog/en/crypto-api-key-permissions-checklist/) first to make sure your Key only has the minimum permissions necessary.

Binance Recovery

Step 1: Confirm Signs of Account Compromise

Binance proactively notifies you through its anomaly detection system via email and App pop-ups. If you receive such a notification, do not ignore it. Check the following:

  • Whether there are unfamiliar devices in your login device list
  • Whether there are unfamiliar Keys on the API management page (https://www.binance.com/en/my/settings/api-management)
  • Whether your trade history or withdrawal records show anomalies
Binance's 8-layer defense system includes a forced logout mechanism — when account takeover is detected, it forcibly kicks out all active sessions across devices. This is the fastest way to disconnect the hacker.

Step 2: Immediately Delete All API Keys

This is the most critical step in the recovery process. As long as the hacker holds a valid API Key, they can continue operating your account.

  1. Log in to Binance (if you still can)
  2. Go to the API Management page
  3. Delete all Keys — both the ones you created and any you don't recognize
  4. Confirm the list is empty

If you can no longer log in, skip to [Step 5].

Step 3: Change Password and Reset 2FA (Two-Factor Authentication)

  1. Go to account security settings
  2. Change your login password (use one that is different from and not reused for your Email)
  3. Reset 2FA — if you discover someone has bound Google Authenticator to your account, remove it immediately and set it up again
  4. Consider enabling Passkey (FIDO standard, a passwordless login method that binds to your device's Face ID / Touch ID)
Binance will **suspend withdrawal functions for 24 to 48 hours** after a password change. This is a protective measure, not an issue. Use this time to complete all security settings.

Step 4: Check and Clear Other Security Settings

The hacker may have done more than just your API Key:

  • Anti-phishing code: Check whether your anti-phishing code has been changed. Binance's anti-phishing code is 8 characters and appears in official emails and notifications to help identify spoofed messages.
  • Withdrawal address whitelist: Check if any unfamiliar addresses have been added.
  • Email and phone number: Confirm that your contact information has not been changed by someone other than you.

Step 5: If You Can't Log In — Contact Binance Support

If you can't log in (account locked out or password no longer works):

  1. Go to the Binance Self-Report page
  2. Or email support@binance.com
  3. Provide your account information, a detailed description of the suspicious activity, and timestamps

Binance's risk control team will manually freeze your account and withdrawal functions when necessary. According to Binance's 2025 Anti-Scam Report, they recovered over $12.8 million in user funds in 2025.

Binance **will never proactively call you** to ask you to adjust API settings. If someone calls claiming to be Binance customer service, hang up and report through official channels.

OKX Recovery

Step 1: Immediately Contact Official Support to Freeze Your Account

OKX provides a 24/7 emergency security inbox at urgent@okx.com, with a promised response within 12 minutes. Include in your email:

  • Device model
  • Timestamps of suspicious activity
  • Screenshots (if available)
If you can't log in via the App, use a trusted device to access the OKX website instead. OKX also offers an in-app "Report fraud or suspicious activity" feature: Menu → Account settings → Security → Report fraud or suspicious activity.

Step 2: Change Password

  1. Open the OKX App
  2. Menu → Profile and Settings → Security → Login Password
  3. Set a strong password containing uppercase letters, lowercase letters, numbers, and special characters
  4. Do not use the same password as your Email
OKX will **disable withdrawal functions for 24 hours** after a 2FA change. Use this time to complete all security checks.

Step 3: Delete All API Keys

  1. OKX App → Menu → Toolbar (dropdown) → API
  2. Delete all API Keys — including ones you created yourself
  3. OKX API Keys that are not bound to an IP and have trade or withdrawal permissions will be automatically deleted after 14 days of inactivity. But don't wait — delete them manually now.
OKX API Keys consist of three elements: API Key, Secret Key, and Passphrase. The Passphrase cannot be viewed after creation; if lost, you can only delete the old Key and create a new one. This also means that even if a hacker only obtains the API Key without the Passphrase, they cannot use it alone.

Step 4: Reset 2FA and Passkeys

  1. OKX App → Menu → Profile and Settings → Security → Security Center
  2. Reset 2FA (if you discover Google Authenticator has been bound without your authorization)
  3. Check Passkeys: remove any Passkey you don't recognize
  4. Set up 2FA again (a verification App is recommended; avoid SMS)

Step 5: Check Trusted Devices and Withdrawal Address Book

  1. Device management: Security Center → Device Management → remove unrecognized devices
  2. Withdrawal address book: Assets → Withdraw → Address Book → delete addresses not added by you
  3. Payment methods: P2P → Profile → Payment → update or delete unfamiliar payment methods

Step 6: If Your Device May Be Infected with Malware

OKX specifically warns that if your phone may have malware installed (e.g., unknown apps auto-installing, clipboard content being modified), do the following:

  1. Disconnect your device from the network
  2. Use another trusted device to proceed
  3. Consider factory resetting or replacing the device
  4. Contact the OKX security team: safety@okx.com

Cross-Platform Comparison: Binance vs OKX Recovery Process

StepBinanceOKX
Emergency contactsupport@binance.com, App supporturgent@okx.com (12-minute response)
API Key deletionAPI Management page → delete allApp → Menu → Toolbar → API → delete
Withdrawal suspension period24–48 hours after password change24 hours after 2FA change
Auto Key expirationUnbound IP + 30 daysUnbound IP + 14 days
Self-report pagebinance.com/en/my/risk/user-scam-reportApp → Security → Report fraud
Withdrawal address whitelistSupportedSupported (Address Book)

Binance and OKX Recovery Process Comparison

Long-Term Security Hardening

After recovery, immediately strengthen your API Key security settings. The following principles apply to both Binance and OKX:

BinanceOKX
IP whitelist bindingHighly recommended / mandatory (required for withdrawal)Up to 20 IPs per Key
Permission minimizationUnbound IP = read-only onlyOnly enable needed permissions at creation
Key rotation frequencyMonthly or quarterlyDelete and recreate immediately if compromised
Auto expirationUnbound IP + 30 daysUnbound IP + 14 days
Passkey supportFace ID / Touch IDSecurity Center → Passkeys

Binance vs OKX Long-Term Security Hardening Comparison

1. Always Bind an IP Whitelist

  • Binance: System-generated HMAC Keys (a type of encryption key format) without an IP binding can only be set to read-only (since 2023-01-30)
  • OKX: Each Key can bind up to 20 IPs (supports IPv4 / IPv6 and CIDR notation)
  • Keys without an IP whitelist can still be used for trading — hackers can quietly drain assets using low-liquidity pairs

2. Only Enable Necessary Permissions

  • Read-only tools → only need read permission
  • Trading bots → only need trade permission
  • Never enable withdrawal permissions unless you genuinely need to withdraw via API
If you want to learn how to set the correct permissions for your API Key, check out our [API Key Permissions Checklist](/blog/en/crypto-api-key-permissions-checklist/).

3. Rotate API Keys Regularly

  • Binance recommends regular rotation like passwords (monthly or quarterly)
  • OKX unbound IP Keys are automatically deleted after 14 days of inactivity
  • If a Key may have been compromised, delete it immediately and create a new one — don't wait for expiration

4. Use Passkey Authentication

  • Binance supports FIDO Passkey (Face ID / Touch ID)
  • OKX also offers Passkey functionality
  • Passkeys are bound to the device, protecting your account even if your password is compromised

5. Treat API Keys Like Passwords

  • Never write them into source code or commit to a repo
  • Use environment variables or configuration files excluded by .gitignore
  • Don't take screenshots, don't paste into chat windows, don't store in note-taking apps

FAQ

Will deleting an API Key stop my trading bot?
Yes. After deleting the Key, all third-party tools using that Key will immediately lose access. After recovery, you'll need to create a new Key, set up the IP whitelist and permissions, then update it in your bot's configuration.
Can Binance / OKX help me recover stolen assets?
Binance says they have mechanisms to track and freeze stolen funds — over $12.8 million was recovered in 2025. OKX also has rapid freeze tools and a 24/7 support team. But once funds are moved on-chain, the chance of full recovery is generally low. The key is to report as soon as possible.
How long after being compromised before I can resume normal trading?
Binance suspends withdrawals for 24–48 hours after a password change; OKX disables withdrawals for 24 hours after a 2FA change. Use this period to complete all security settings — don't rush to restart your bot.
What if I lost my OKX Passphrase?
OKX explicitly states that a lost Passphrase cannot be recovered. The only solution is to delete the existing API Key and create a new one. This also means you must update all third-party tools that use that Key simultaneously.
Should I tell everyone that my API Key was compromised?
No need for a public announcement, but you should report to the exchange. Binance has a self-report page (`/my/risk/user-scam-report`), and OKX allows fraud reporting in-app. The more detailed your report (timestamps, device info, screenshots), the higher the chance of recovery.

Summary

A stolen API Key is not the end — but the actions in the first hour determine how much you can save. Remember this order:

  1. Stop all automated trading tools
  2. Delete all API Keys (the most critical step)
  3. Change password and reset 2FA
  4. Check devices, address book, payment methods
  5. Contact exchange support to report
  6. Create a new Key, bind IP, enable only necessary permissions

Prevention is always easier than recovery. Spend ten minutes checking your API Key permissions and IP whitelist — it's likely more efficient than trying to recover assets afterward. If you want to learn how to set up API permissions correctly, read our API Key Permissions Checklist.