Skip to main content

Replicate API Token

Replicate API Tokens are used to authenticate requests to the Replicate platform, which provides machine learning model hosting and inference services. These tokens grant access to various functionalities, including deploying models, running predictions, and managing resources. Exposure of these tokens is a significant security concern as it can lead to unauthorized access to sensitive data and misuse of computational resources, potentially resulting in financial and reputational damage.


How Does It Look

Replicate API Tokens can appear in various contexts, such as:

  • Environment variables:

    export REPLICATE_API_TOKEN="rpt_1234567890abcdef"
  • Configuration files (JSON, YAML, .env):

    {
    "replicate_api_token": "rpt_1234567890abcdef"
    }
    replicate_api_token: rpt_1234567890abcdef
    REPLICATE_API_TOKEN=rpt_1234567890abcdef
  • Code snippets:

    import replicate

    client = replicate.Client(api_token="rpt_1234567890abcdef")

Severity

  • 🟠 High

This severity level is due to the potential for unauthorized access to the Replicate platform, allowing attackers to deploy models, run predictions, and manage resources. The blast radius includes potential data exposure, financial costs from resource misuse, and disruption of services.


What Can an Attacker Do?

With immediate access to a Replicate API Token, an attacker can perform several actions:

  • Deploy or modify models (if the token has write permissions), potentially altering machine learning outputs.
  • Run unauthorized predictions (if the account has prediction scope enabled), leading to unexpected computational costs.
  • Access sensitive data (if the token allows data retrieval), exposing proprietary or confidential information.
  • Consume computational resources for unauthorized purposes, such as cryptomining (if compute permissions are granted).

An attacker could also escalate their access by exploiting other vulnerabilities within the environment or moving laterally to other connected systems, increasing the potential damage.


Real-World Impact

Exposure of a Replicate API Token poses significant business risks:

The primary impact includes unauthorized access to machine learning models and data.

Potential consequences include:

  • Data Exposure: Proprietary model data and prediction results (if the token 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 degraded performance (if the attacker modifies or deletes models).
  • Reputational Damage: Loss of trust from clients and partners due to data breaches or service disruptions.

In a worst-case scenario, the exposure could lead to cascading effects, such as further breaches in connected systems or prolonged service outages.


Prerequisites for Exploitation

To exploit a Replicate API Token, an attacker needs:

  • Network access to the Replicate API endpoints.
  • Knowledge of account-specific details such as model IDs or endpoint URLs.
  • No IP restrictions or MFA enforcement on the account to prevent unauthorized access.

How to Verify If It's Active

To verify if a Replicate API Token is active, use the following command:

curl -H "Authorization: Token [TOKEN]" https://api.replicate.com/v1/models

Valid credential response: A list of models 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:

  • REPLICATE_API_TOKEN
  • replicate_api_token
  • REPLICATE_TOKEN
  • replicateToken
  • API_TOKEN
  • apiToken

File Locations:

  • .env
  • config.json
  • settings.yaml
  • credentials.py

Regex Pattern:

rpt_[a-zA-Z0-9]{16,32}

Remediation Steps

  1. Revoke immediately - Go to Replicate Dashboard > API Tokens and delete the compromised token.
  2. Audit access logs - Review Replicate access logs for unauthorized model deployments or predictions during the exposure window.
  3. Assess blast radius - Identify all systems, applications, and environments that used the exposed token.
  4. Rotate credential - Generate a new API token in the Replicate Dashboard with least-privilege permissions.
  5. Update dependent systems - Deploy the new token to all applications and update CI/CD pipelines securely.
  6. Harden access controls - Enable IP allowlisting in Replicate and require MFA for account access.
  7. Implement secrets management - Migrate tokens to a secrets manager (HashiCorp Vault, AWS Secrets Manager) to prevent hardcoding.
  8. Add detection controls - Set up pre-commit hooks and repository scanning to catch token 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.


References