PlanetScale service tokens can now be locked to an IP range
A new CIDR restriction on PlanetScale service tokens rejects API requests from anywhere outside an allowed list, up to ten ranges per token.
PlanetScale announced on 19 November that service tokens can now be restricted to specific IPv4 addresses or ranges. A token with a restriction set only accepts API requests from the listed addresses; anything else is rejected outright.
Each token can hold up to ten addresses or ranges, set from the token dialog, the token management page, the CLI’s --cidrs flag, or the API’s matching parameter. A bare address is stored as a /32. IPv6 addresses and 0.0.0.0/0 are not accepted, so this is deliberately for narrowing access, not widening it. Leaving the list empty keeps the old behaviour of accepting requests from anywhere.
pscale service-token update <id> --cidrs 203.0.113.0/24,198.51.100.4
This follows PlanetScale’s move last month to show the last IP, location and network operator a service token was used from, which helped spot a leaked token after the fact. This change is earlier in the chain: a token restricted to your CI runner’s address range or your production VPC simply can’t be used anywhere else, leaked or not.
Why it matters: service tokens sit in deploy pipelines and application servers, often with broad database access and a long lifetime. If one ends up in a log, a build artefact or a compromised dependency, an IP restriction is the difference between a leaked credential being a non-event and being a breach.