Environment Variables & Secrets

Learn how TurboV stores, encrypts, and injects application secrets using industry-standard envelope encryption.


1. Security Architecture: Envelope Encryption

Storing plain-text environment variables or relying on single database-level passwords exposes applications to critical credential leakage. TurboV implements envelope encryption using AES-256-GCM:

[ Central Key Management Engine ]
                 │
                 │ Manages Root Key Encryption Key (KEK)
                 ▼
[ Per-Environment Data Encryption Key (DEK) ]
                 │ Generated as a dedicated, random 256-bit key
                 │ Encrypted via KEK into envelope format
                 ▼
[ Application Environment Variables & Secrets ]
                 │ Encrypted with DEK using AES-256-GCM
                 │ Stored with unique IV and authentication tag
                 ▼
[ Injected into Memory at Runtime ]
  Never baked into Docker images, never exposed in build caches

Key Security Guarantees

  • At-Rest Protection: All secrets are stored in encrypted ciphertext form. They cannot be decrypted without authorized access to the key management service.
  • Cryptographic Isolation: Every project and environment has an isolated Data Encryption Key (DEK). A secret in staging is encrypted with a completely different key than production.
  • Integrity Validation: AES-256-GCM includes an authentication tag for every ciphertext, ensuring secrets cannot be altered or corrupted in storage without failing validation immediately.

2. Managing Variables in the Dashboard

Adding Individual Variables

  1. Navigate to your application's Environment → Settings → Environment Variables.
  2. Click Add Variable.
  3. Enter Key (e.g. STRIPE_API_KEY) and Value.
  4. Click Save.

Bulk Import from .env

If you already have a local .env file:

  1. Click Bulk Import.
  2. Paste the contents of your .env file directly into the textarea:
    # Database Configuration
    DATABASE_URL="postgres://user:pass@db-postgres:5432/app"
    PORT=3000
    NODE_ENV="production"
    API_KEY="sk_live_948fbc..."
  3. The parser automatically handles comments (#), quotes (" or '), and multiline values cleanly.
  4. Click Import & Encrypt.

Reveal & Hide Values

By default, secret values are masked in the dashboard UI with bullet points. Team members with OWNER or ADMIN privileges can click the eye icon to reveal the plaintext value during debugging sessions.


3. Variable Expansion & Cross-Referencing

Variables can reference other variables within the same environment using ${VAR} syntax:

DB_HOST=db-postgres
DB_PORT=5432
DB_USER=app_user
DB_PASS=secret123
DB_NAME=production_db
 
# Evaluated automatically at runtime
DATABASE_URL=postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}

4. Runtime Injection vs Build-Time Arguments

Understanding where environment variables exist in the deployment lifecycle is critical for security:

PhaseVariable ExposureSecurity Behavior
Docker BuildNot exposed by defaultSecrets are never baked into image layers. Build-time arguments must be explicitly enabled if required by static site generators.
Container RuntimeInjected via secure memory arrayThe agent passes decrypted variables in memory directly to the container during startup.
Version ControlNever stored in GitKept completely separate from code repositories.

5. Updates Trigger Zero-Downtime Redeployment

When you update, add, or delete an environment variable:

  1. TurboV re-encrypts the secret store and records an audit log entry.
  2. The agent automatically triggers a blue-green redeployment of your running containers.
  3. The new container spins up with the updated environment variables.
  4. Once verified healthy, Traefik routes traffic to the updated container.
  5. In-flight requests are not interrupted.

6. Shared Project Variables

If you have multiple microservices sharing common configuration (such as AUTH_URL, SENTRY_DSN, or company-wide API keys), define them once as Project-Level Environment Variables. All applications inside the project inherit them automatically.