Netlify API Key
Netlify API keys are used to authenticate requests to the Netlify platform, which provides services for building, deploying, and managing web applications. These keys allow users to interact with Netlify's API to automate workflows, manage site settings, and access deployment data. Exposure of a Netlify API key can lead to unauthorized access to your Netlify account, potentially allowing attackers to manipulate site configurations, access sensitive data, or disrupt services.
How Does It Look
Netlify API keys can appear in various contexts, such as:
-
Environment variables:
export NETLIFY_API_KEY="netlify_example_key_123456" -
Configuration files (JSON, YAML, .env):
{
"netlifyApiKey": "netlify_example_key_123456"
}netlify_api_key: netlify_example_key_123456NETLIFY_API_KEY=netlify_example_key_123456 -
Code snippets:
const netlifyApiKey = "netlify_example_key_123456";
Severity
🟠 High
This severity level is due to the potential for significant unauthorized access to your Netlify account. An exposed API key can allow attackers to modify site configurations, access deployment data, and potentially disrupt services. The blast radius includes all sites and services managed under the compromised Netlify account.
What Can an Attacker Do?
With immediate access to a Netlify API key, an attacker can perform several actions that compromise the security and integrity of your web applications.
Key actions an attacker can perform:
- Modify site configurations (if the key has write permissions), potentially redirecting traffic or altering site behavior.
- Access deployment data (if the account has read access), exposing sensitive information about your applications.
- Trigger deployments (if deployment permissions are granted), potentially deploying malicious code.
- Access billing information (if the account has billing scope enabled), leading to potential financial exploitation.
An attacker could also use the compromised key to escalate privileges or move laterally within your infrastructure, especially if the key is used in conjunction with other exposed credentials or misconfigured services.
Real-World Impact
The exposure of a Netlify API key poses significant business risks, including unauthorized access and potential service disruptions.
Potential consequences include:
- Data Exposure: Access to deployment data and site configurations (if the credential has read access to sensitive data).
- Financial Loss: Unauthorized access to billing information or triggering of costly deployments (if billing/resource creation is permitted).
- Operational Disruption: Alteration of site configurations or unauthorized deployments (if the attacker has modify permissions).
- Reputational Damage: Loss of trust from users and clients due to compromised site integrity.
In worst-case scenarios, attackers could leverage the exposed API key to deploy malicious content or redirect traffic, leading to cascading effects across your web applications and potentially affecting user trust and business operations.
Prerequisites for Exploitation
To exploit an exposed Netlify API key, an attacker needs:
- Network access: Ability to send requests to the Netlify API.
- Additional context: Knowledge of the specific Netlify account or site ID to target.
- No rate limits: If rate limits are not enforced, attackers can perform numerous actions quickly.
How to Verify If It's Active
To verify if a Netlify API key is active, use the following command:
curl -H "Authorization: Bearer [API_KEY]" https://api.netlify.com/api/v1/sites
Valid credential response: A list of sites associated with the Netlify account, indicating the key is active.
Invalid/expired credential response: An error message indicating unauthorized access or invalid credentials.
Detection Patterns
Common Variable Names:
- NETLIFY_API_KEY
- netlifyApiKey
- NETLIFY_KEY
- netlify_key
- NETLIFY_TOKEN
- netlifyToken
File Locations:
.envconfig.jsonsettings.yamlcredentials.js
Regex Pattern:
(?i)(netlify[_-]?api[_-]?key|netlify[_-]?token)["']?\s*[:=]\s*["'][a-zA-Z0-9_-]{20,}["']
Remediation Steps
- Revoke immediately - Go to Netlify Dashboard > User Settings > Applications and delete the compromised API key.
- Audit access logs - Review Netlify access logs for unauthorized actions or deployments during the exposure window.
- Assess blast radius - Identify all sites and services that used the exposed API key.
- Rotate credential - Generate a new API key in the Netlify Dashboard with least-privilege permissions.
- Update dependent systems - Deploy the new API key to all applications and update CI/CD pipelines securely.
- Harden access controls - Enable IP allowlisting in Netlify and require two-factor authentication for account access.
- Implement secrets management - Migrate API keys 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.