Supabase Project API Key
Supabase Project API Keys are credentials used to authenticate requests to Supabase, an open-source backend-as-a-service platform that provides a suite of tools for building applications. These keys allow access to Supabase's database, authentication, and storage services. Exposure of a Supabase Project API Key can lead to unauthorized access to sensitive data and manipulation of application resources, posing significant security risks.
How Does It Look
Supabase Project API Keys can appear in various contexts, such as:
-
Environment variables:
export SUPABASE_API_KEY="sbp_1234567890abcdef" -
Configuration files (JSON, YAML, .env):
{
"supabaseApiKey": "sbp_1234567890abcdef"
}supabase_api_key: sbp_1234567890abcdef -
Code snippets:
const supabase = createClient('https://xyzcompany.supabase.co', 'sbp_1234567890abcdef'); -
Connection strings:
postgres://user:password@host:5432/database?apikey=sbp_1234567890abcdef
Severity
🟠 High
The Supabase Project API Key provides access to various services within a Supabase project, including databases and authentication systems. If exposed, an attacker could potentially read or modify data, leading to data breaches or service disruptions. The severity is high due to the potential for significant data exposure and operational impact.
What Can an Attacker Do?
With immediate access to a Supabase Project API Key, an attacker can interact with the Supabase services as if they were an authorized user.
Key actions an attacker can perform:
- Read sensitive data (if the credential has read permissions)
- Modify or delete data (if the credential has write permissions)
- Access user authentication details (if the credential includes access to authentication services)
- Manipulate storage resources (if storage permissions are granted)
An attacker could also escalate their access by exploiting other vulnerabilities within the application or using the compromised key to pivot to other systems connected to the Supabase project.
Real-World Impact
Exposure of a Supabase Project API Key poses significant business risks, including:
Primary impact includes unauthorized access to sensitive data and potential service disruptions.
Potential consequences include:
- Data Exposure: User data, application data, and other sensitive information (if the credential has read access to sensitive data)
- Financial Loss: Costs associated with data breaches, service downtime, and potential regulatory fines (if billing/resource creation is permitted)
- Operational Disruption: Application downtime or degraded performance (if the attacker has delete/modify permissions)
- Reputational Damage: Loss of customer trust and brand reputation
In a worst-case scenario, the exposure could lead to cascading effects, such as further unauthorized access to connected systems or data breaches affecting multiple services.
Prerequisites for Exploitation
To exploit a Supabase Project API Key, an attacker needs:
- Network access: Ability to send requests to the Supabase API endpoint
- Additional context: Knowledge of the Supabase project URL or endpoint
- No rate limits: Exploitation is easier if there are no strict rate limits or IP restrictions in place
How to Verify If It's Active
To verify if a Supabase Project API Key is active, use the following command:
curl -H "apikey: [API_KEY]" https://[SUPABASE_URL]/rest/v1/table_name
Valid credential response: A successful response will return data from the specified table.
Invalid/expired credential response: An error message indicating unauthorized access or invalid API key.
Detection Patterns
Common Variable Names:
- SUPABASE_API_KEY
- supabaseApiKey
- SUPABASE_KEY
- sbp_api_key
- sbpKey
- SUPABASE_SECRET
File Locations:
.envconfig.jsonsettings.yamlapp-config.jsdatabase.yml
Regex Pattern:
sbp_[a-zA-Z0-9]{16,}
Remediation Steps
- Revoke immediately - Go to Supabase Dashboard > Project Settings > API and regenerate the API key.
- Audit access logs - Review Supabase logs for unauthorized access or data modifications during the exposure window.
- Assess blast radius - Identify all systems, applications, and environments that used the exposed credential.
- Rotate credential - Generate a new API key in Supabase and update all dependent systems with the new key.
- Update dependent systems - Deploy the new credential to all applications and update CI/CD pipelines securely.
- Harden access controls - Enable IP allowlisting in Supabase and enforce strict rate limits.
- 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.