PlanetScale API Token
PlanetScale API Tokens are credentials used to authenticate and interact with the PlanetScale database platform, which provides a scalable and serverless MySQL database service. These tokens allow users to perform various operations such as managing databases, deploying branches, and configuring settings. Exposure of these tokens is a significant security concern as it can lead to unauthorized access to sensitive database operations and data.
How Does It Look
PlanetScale API Tokens can appear in various contexts, such as:
-
Environment variables:
export PLANETSCALE_API_TOKEN="pscale_xxx_redacted" -
Configuration files (JSON, YAML, .env):
{
"apiToken": "pscale_xxx_redacted"
}api_token: pscale_xxx_redacted -
Code snippets:
api_token = "pscale_xxx_redacted" -
Connection strings (if applicable):
pscale://pscale_xxx_redacted@host/database
Severity
- 🔴 Critical
The severity is marked as critical because the API token provides access to the PlanetScale database platform, potentially allowing full control over database operations. This includes creating, modifying, or deleting databases and branches, which can lead to significant data loss or corruption. The blast radius is extensive, as it can affect all databases and branches associated with the token.
What Can an Attacker Do?
With immediate access to a PlanetScale API Token, an attacker can perform a wide range of actions:
An attacker can immediately access and manipulate database resources, potentially leading to data breaches or service disruptions.
Key actions an attacker can perform:
- Delete or modify data (if the credential has write permissions)
- Access sensitive database configurations (if the account has administrative scope enabled)
- Spin up additional database branches (if branch creation permissions are granted)
- Extract sensitive data (if read access is enabled)
Additionally, an attacker could escalate their access by exploiting other vulnerabilities within the connected systems or use the compromised token to move laterally across other services integrated with PlanetScale.
Real-World Impact
The exposure of a PlanetScale API Token poses significant business risks, including:
The primary impact is the potential for unauthorized access to sensitive data and disruption of database operations.
Potential consequences include:
- Data Exposure: Sensitive customer or business data (if the credential has read access to sensitive data)
- Financial Loss: Increased costs from unauthorized resource usage (if billing/resource creation is permitted)
- Operational Disruption: Service outages or data integrity issues (if the attacker has delete/modify permissions)
- Reputational Damage: Loss of customer trust and brand credibility
In the worst-case scenario, the exposure could lead to cascading effects, such as widespread data breaches or prolonged service outages, severely impacting business operations.
Prerequisites for Exploitation
To exploit a PlanetScale API Token, an attacker needs:
- Network access to the PlanetScale API endpoints
- Knowledge of account IDs or database names to target specific resources
- No IP restrictions or MFA enforcement on the account
How to Verify If It's Active
To verify if a PlanetScale API Token is active, use the following command:
curl -H "Authorization: Bearer [TOKEN]" https://api.planetscale.com/v1/databases
Valid credential response: A list of databases associated with the account, indicating the token is active.
Invalid/expired credential response: An error message indicating unauthorized access or token expiration.
Detection Patterns
Common Variable Names:
- PLANETSCALE_API_TOKEN
- PSC_API_TOKEN
- PSC_TOKEN
- PLANETSCALE_TOKEN
- API_TOKEN
- PSC_API_KEY
File Locations:
.envconfig.jsonsettings.yamlcredentials.py
Regex Pattern:
pscale_[a-zA-Z0-9]{32,}
Remediation Steps
- Revoke immediately - Go to PlanetScale Dashboard > Settings > API Tokens and delete the compromised token.
- Audit access logs - Review PlanetScale audit logs for unauthorized database operations during the exposure window.
- Assess blast radius - Identify all systems, applications, and environments that used the exposed credential.
- Rotate credential - Generate a new API token in the PlanetScale Dashboard with least-privilege permissions.
- Update dependent systems - Deploy the new credential to all applications and update CI/CD pipelines securely.
- Harden access controls - Enable IP allowlisting in PlanetScale and require MFA for account access.
- Implement secrets management - Migrate credentials to a secrets manager (HashiCorp Vault, AWS Secrets Manager) to prevent hardcoding.
- Add detection controls - Set up pre-commit hooks and repository scanning to catch credential leaks before they reach production.
Credential exposures often go undetected for extended periods, increasing the window for exploitation. As a long-term strategy, plan to establish an internal process or engage an external vendor for continuous external exposure monitoring. This helps identify leaked secrets across public repositories, paste sites, dark web forums, and other external sources before attackers can leverage them. Proactive detection and rapid response are essential to minimizing the impact of credential leaks.