Crypto API Key Security: Emergency Recovery Guide
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.
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.
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
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.
- Log in to Binance (if you still can)
- Go to the API Management page
- Delete all Keys — both the ones you created and any you don't recognize
- 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)
- Go to account security settings
- Change your login password (use one that is different from and not reused for your Email)
- Reset 2FA — if you discover someone has bound Google Authenticator to your account, remove it immediately and set it up again
- Consider enabling Passkey (FIDO standard, a passwordless login method that binds to your device's Face ID / Touch ID)
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):
- Go to the Binance Self-Report page
- Or email support@binance.com
- 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.
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)
Step 2: Change Password
- Open the OKX App
- Menu → Profile and Settings → Security → Login Password
- Set a strong password containing uppercase letters, lowercase letters, numbers, and special characters
- Do not use the same password as your Email
Step 3: Delete All API Keys
- OKX App → Menu → Toolbar (dropdown) → API
- Delete all API Keys — including ones you created yourself
- 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.
Step 4: Reset 2FA and Passkeys
- OKX App → Menu → Profile and Settings → Security → Security Center
- Reset 2FA (if you discover Google Authenticator has been bound without your authorization)
- Check Passkeys: remove any Passkey you don't recognize
- Set up 2FA again (a verification App is recommended; avoid SMS)
Step 5: Check Trusted Devices and Withdrawal Address Book
- Device management: Security Center → Device Management → remove unrecognized devices
- Withdrawal address book: Assets → Withdraw → Address Book → delete addresses not added by you
- 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:
- Disconnect your device from the network
- Use another trusted device to proceed
- Consider factory resetting or replacing the device
- Contact the OKX security team: safety@okx.com
Cross-Platform Comparison: Binance vs OKX Recovery Process
| Step | Binance | OKX |
|---|---|---|
| Emergency contact | support@binance.com, App support | urgent@okx.com (12-minute response) |
| API Key deletion | API Management page → delete all | App → Menu → Toolbar → API → delete |
| Withdrawal suspension period | 24–48 hours after password change | 24 hours after 2FA change |
| Auto Key expiration | Unbound IP + 30 days | Unbound IP + 14 days |
| Self-report page | binance.com/en/my/risk/user-scam-report | App → Security → Report fraud |
| Withdrawal address whitelist | Supported | Supported (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:
| Binance | OKX | ||
|---|---|---|---|
| IP whitelist binding | Highly recommended / mandatory (required for withdrawal) | Up to 20 IPs per Key | |
| Permission minimization | Unbound IP = read-only only | Only enable needed permissions at creation | |
| Key rotation frequency | Monthly or quarterly | Delete and recreate immediately if compromised | |
| Auto expiration | Unbound IP + 30 days | Unbound IP + 14 days | |
| Passkey support | Face ID / Touch ID | Security 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
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?
Can Binance / OKX help me recover stolen assets?
How long after being compromised before I can resume normal trading?
What if I lost my OKX Passphrase?
Should I tell everyone that my API Key was compromised?
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:
- Stop all automated trading tools
- Delete all API Keys (the most critical step)
- Change password and reset 2FA
- Check devices, address book, payment methods
- Contact exchange support to report
- 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.