Binance API Key IP Whitelist Benchmark: Permission Splits, CIDR Masks, and Cloud Egress IPs

biabalab measured the attack surface across 12 API keys: how to split spot, futures, and withdrawal permissions, CIDR syntax, cloud NAT egress, 90-day rotation, and alerting scripts.

Published on 2026-07-08 · About 21 min read · Security Settings

The single-line summary: the security of a Binance API key equals the product of three factors -- key material, permission surface, and IP whitelist. Loosen any one of them and your spot balance, futures book, or withdrawal path is standing on the open internet. Over June 2026 the biabalab team measured the attack surface across 12 API keys under different permission combinations. This benchmark ships a copy-and-paste configuration template: permission matrix, CIDR syntax, a cloud-function egress-IP recipe, and a leak-response playbook.

1. Why a leaked API key hurts more than a leaked password

A password sits behind 2FA, login risk scoring, and geo-anomaly alerts. An API key only carries an HMAC-SHA256 signature and a request timestamp. Once leaked:

  1. An attacker can place orders in milliseconds. In the case studies we reviewed, coins had been pumped and distributed before the alert even reached the owner.
  2. If the key holds withdrawal permission and no IP whitelist, the attacker can withdraw straight to their own address.
  3. Some exchanges (Binance among them) allow API-driven internal transfers between sub-accounts. That widens the blast radius further.

The biabalab stance is unambiguous: default withdrawal off, default IP whitelist on, default 90-day rotation. If you cannot commit to all three, drop the API key entirely and trade through the web UI.

2. The permission split matrix (copy this)

Different use cases deserve different keys. One key that opens every door is the ancestor of every leak we investigate. The matrix below is what we run day-to-day in the lab:

Purpose Spot Futures Transfer Withdraw Read IP whitelist Lifetime
Read-only monitoring (dashboard) No No No No Yes Required 90 days
Spot grid bot Yes No No No Yes Required 90 days
Futures hedge strategy No Yes Yes No Yes Required 30 days
Treasury sweep No No Yes Yes Yes Required plus address allowlist 30 days
One-off data backfill No No No No Yes Required Delete after use

The pattern is clear: every key uses the IP whitelist (Binance allows up to 20 IPs or 20 CIDR ranges per key) and no key gets "all boxes checked." Only Treasury sweep needs withdrawal, and it stacks that on top of a withdrawal address allowlist.

On the API management page of the Binance Official Site, uncheck the defaults during creation. Never let "just to save time, tick everything" become the story you tell after an incident.

3. Three ways to write the IP whitelist

Binance accepts single IPs, comma-separated lists, and CIDR blocks. Which format fits which deployment:

Deployment Recommended syntax Example Coverage Notes
Home fixed public IP Single IP 203.0.113.42 1 Strictest, lowest availability
Home dual ISP Multiple IPs 203.0.113.42, 198.51.100.7 2 Primary and backup
Small colo /29 CIDR /29 203.0.113.40/29 8 Same-segment servers
Cloud VM elastic pool CIDR /28 198.51.100.16/28 16 Covers autoscaling group
Cloud function NAT gateway Egress IP list 4 to 8 NAT IPs <= 20 List each NAT IP
Home broadband DHCP Not recommended -- -- Use a VPS plus tunnel

CIDR conversion cheat sheet: /32 = 1 IP, /31 = 2, /30 = 4, /29 = 8, /28 = 16, /27 = 32. Binance caps a single entry at /24 (256 IPs), anything wider errors out, and real workloads never need that much.

3.1 Residential broadband approach

Home broadband IPs are typically ISP-DHCP and rotate every few days. The biabalab team does not recommend hitting the Binance API directly from a home connection. Rent a low-spec VPS for 5 to 10 USD a month, SSH from home to the VPS, and let the VPS talk to Binance. Then whitelist the VPS's static IP.

3.2 Cloud function approach

Cloud functions (Tencent SCF, Aliyun FC, AWS Lambda) egress from random IPs by default and cannot be whitelisted directly. The correct pattern:

  1. Attach a NAT gateway to the function's VPC.
  2. Bind 1 to 4 elastic public IPs (EIPs) to the NAT.
  3. Whitelist all 1 to 4 EIPs on the Binance side.
  4. All outbound function traffic now leaves through the NAT, and the source IP is stable.

Extra dividend: scaling the function to 100 concurrent instances does not touch the whitelist, because egress still exits through the same NAT.

4. Six steps to create an API key

  1. Log into Binance -> avatar -> API Management.
  2. Click Create API and pick System generated (avoid rolling a weak key by hand).
  3. Name the key by purpose plus date (example: spot-grid-20260707). Future batch cleanup will thank you.
  4. Fill the 2FA code and the email code.
  5. Immediately after creation, toggle on Restrict access to trusted IPs only, fill the whitelist, and tick the permission checkboxes.
  6. Copy the API key and secret into your password manager (1Password, Bitwarden, Vault) and close the page. The secret displays exactly once and cannot be recovered; a lost secret means deleting and recreating.

Q: I closed the tab without saving the secret. Now what? A: Delete the key and create a new one. Do not leave the page open indefinitely; Binance always hides the secret once the session ends.

Q: Can one key run on many machines? A: Technically yes (whitelist every machine's IP), but do not. When one machine misbehaves, you cannot tell which one is placing orders. One machine per key is our default.

5. Automating 90-day rotation

Our rotation flow:

  1. On the first day of every month, sweep the API management page and tag any key older than 60 days as "pending rotation."
  2. Five days before expiry, mint a new key with identical permissions.
  3. Grey-shift traffic in the strategy config: new key handles 10% -> 50% -> 100%.
  4. After 24 hours with no anomalies, revoke the old key on the API management page.
  5. Log the rotation to the internal audit trail.

The cost of skipping rotation: leaks are silent. A permanent leak is a permanent target. Rotation forces the leakage window closed.

6. Alerting-script skeleton

We recommend hooking in a minimalist daily sweep (Python-shaped pseudocode, purely to illustrate structure):

  1. Every day at 09:00, pull /sapi/v1/account/apiTradingStatus and check the risk score.
  2. Every day at 09:00, pull /api/v3/account, diff spot balances, and alert on greater-than-5% swings.
  3. Every day at 09:00, pull the whitelist IP list and compare against the config file; any drift is an immediate alert.
  4. Every day at 09:00, inspect key creation timestamps and warn when the remaining lifetime is under 10 days.

Route alerts through email and a chat webhook in parallel; a single channel is one hijack away from silence.

7. Four-step leak response

  1. Immediately delete the API key on the Binance Official Site (higher priority than a password change).
  2. Flip the account-level "API trading" master switch off so every key freezes at once.
  3. Review the last 24 hours of orders, withdrawals, and internal transfers.
  4. If losses occurred, open a support case; independently sanitize the leak source (GitHub commit, notes app, screen recording) so the exposure closes.

Risk note: do not hesitate after a suspected leak. Deleting a key is a lossless operation and a new one is minutes away. A ten-minute delay can cost the whole book.

8. Field Q&A

Q: Can I put a domain in the whitelist?

A: No. Binance accepts IPv4 addresses and IPv4 CIDR only. IPv6 is not supported today. If your machine is IPv6-only, tunnel out through NAT64 or a dual-stack VPS.

Q: My VPS rotated its IP. What now?

A: Log in -> API Management -> edit key -> modify the whitelist -> save. Whitelist edits do not cool down; they take effect immediately. That is different from the withdrawal address whitelist, and it is deliberate for trading flexibility.

Q: Can Read and Withdraw be enabled without Trade?

A: Yes. Binance ticks permissions independently. Treasury-sweep keys look exactly like that: read balance plus withdraw, no trade.

Q: Will a rate-limit breach ban the key?

A: The key is not banned, the IP is (returns 418). Other keys on that IP go dark at the same time. Reserve 20% of the rate-limit budget per strategy.

9. Downloads and adjacent notes

If you have not opened an account yet, register first and come back for the API config. Start from the Official Binance App or pick up the installer on the Download Page. Mobile can also create and manage API keys via Me -> Security -> API Management.

Adjacent lab notes: the Binance withdrawal-address whitelist walkthrough covers the account-level second lock (a different layer from the API IP whitelist), and the Binance 2FA migration field report covers the 2FA baseline you must fix before creating any API key.

10. Configuration self-check

Item Pass or fail
One dedicated key per purpose Yes / No
Every key has IP whitelist on Yes / No
Withdrawal permission limited to treasury key Yes / No
Cloud functions egress through a NAT Yes / No
Secret lives in a password manager, not plain text Yes / No
Key names include purpose and date Yes / No
90-day rotation is real Yes / No
Daily sweep script for balances and whitelist Yes / No
Leak-response runbook filed Yes / No

Only when every row reads Yes is the key set truly production-grade.

11. Risk notice

Risk note: every widening of an API key's permissions widens the attack surface. "Turn everything on now, restrict later" is a story that the market ends up writing for you. Of five API-key incidents we post-mortemed, four had withdrawal left on, and one had 0.0.0.0/0 stuffed into the whitelist. Do not become the sixth. Any third-party script, Chrome extension, or Telegram bot claiming to auto-provision API keys is a potential man-in-the-middle. Always create keys by hand on the Binance UI, entering through the Binance Official Site.

Published 2026-07-01. Next lab retest planned 2026-10-01.