Secretless

Credential protection for AI coding tools. Prevents API key leakage in LLM contexts.

Setup

Install globally
npm install -g secretless-ai
Initialize in your project
npx secretless-ai init
Verify setup
npx secretless-ai verify

How It Works

Secretless intercepts credential access at the tool level. Instead of credentials appearing in LLM context (conversation history, tool calls, file reads), tools reference environment variables. Secretless manages the lifecycle:

  1. Scans project for credential patterns (API keys, tokens, connection strings)
  2. Migrates credentials to a secure backend (OS keychain, 1Password, vault)
  3. Replaces hardcoded values with $ENV_VAR references
  4. Adds file patterns to block lists (prevents AI tools from reading .env files)
  5. Injects a CLAUDE.md / .cursorrules section instructing tools to use env vars

Storage Backends

BackendPlatformDescription
OS KeychainmacOS, Windows, LinuxNative keychain integration (Keychain Access, Credential Manager, libsecret)
1PasswordAll1Password CLI integration for team credential sharing
HashiCorp VaultAllKV v2 secrets engine with cross-device/cluster sync and Vault token auth. Best for enterprise, self-hosted, and team secrets.
GCP Secret ManagerAllGoogle Cloud Secret Manager with IAM integration, automatic versioning, and native Cloud Run/GKE support. Best for GCP-native infrastructure.
.env fileAllFallback with 0600 permissions (not recommended for teams)

MCP Context Protection

When AI tools use MCP servers, credentials can leak through:

  • Tool call parameters (MCP server configs with inline API keys)
  • File reads (.env, config files with embedded credentials)
  • Conversation history (credentials pasted into chat)
  • Error messages (stack traces revealing connection strings)

Secretless blocks all these vectors by ensuring credentials never enter the LLM context window.

HashiCorp Vault Backend

The Vault backend connects to a HashiCorp Vault instance using the KV v2 secrets engine. Secrets are read and written through the Vault HTTP API with token-based authentication. This backend is suited for teams that self-host their secret infrastructure or need cross-cluster credential synchronization.

Configure the Vault backend
npx secretless-ai backend set vault \
  --vault-addr https://vault.example.com \
  --vault-token $VAULT_TOKEN \
  --vault-mount secret \
  --vault-path secretless
Migrate secrets from local to Vault
npx secretless-ai migrate --from local --to vault
ParameterEnvironment VariableDescription
--vault-addrVAULT_ADDRVault server URL (e.g., https://vault.example.com)
--vault-tokenVAULT_TOKENAuthentication token for Vault API access
--vault-mountVAULT_MOUNTKV v2 mount path (default: secret)
--vault-pathVAULT_PATHPath prefix within the mount (default: secretless)
--vault-namespaceVAULT_NAMESPACEVault namespace for enterprise isolation (optional)

GCP Secret Manager Backend

The GCP Secret Manager backend stores secrets in Google Cloud Secret Manager using the REST API with zero SDK dependency. Authentication uses Application Default Credentials (ADC) or a service account key file. This backend integrates natively with Cloud Run, GKE, and Cloud Functions.

Configure the GCP Secret Manager backend
# Authenticate with GCP (one-time)
gcloud auth application-default login

# Set as the active backend
npx secretless-ai backend set gcp-sm
Migrate secrets from local to GCP Secret Manager
npx secretless-ai migrate --from local --to gcp-sm
ConfigurationEnvironment VariableDescription
Project IDgcp.projectId in config.jsonGCP project containing the secrets. Auto-detected from service account key or ADC.
Key fileGOOGLE_APPLICATION_CREDENTIALSPath to service account key JSON file (alternative to ADC)

Credential Scope Discovery

Credential Scope Discovery detects when the permissions associated with a credential change after it was initially stored. This covers both scope expansion (a token gains new permissions) and scope contraction (permissions are revoked). Detecting scope drift is important because a compromised token that silently gains elevated permissions can be exploited without triggering traditional secret rotation alerts.

Supported Providers

ProviderDetection MethodStatus
GCPtestIamPermissions APIAvailable
HashiCorp Vaultcapabilities-self endpointAvailable
AWSIAM policy simulationPlanned

Commands

CommandDescription
npx secretless-ai scope discoverProbe current permissions for all stored credentials and record the initial scope baseline.
npx secretless-ai scope checkCompare current permissions against the stored baseline. Reports expanded or contracted scopes.
npx secretless-ai scope listDisplay the recorded scope baselines for all credentials.
npx secretless-ai scope resetClear stored baselines and re-discover current scopes.
Discover and baseline credential scopes
$ npx secretless-ai scope discover
  GCP_SERVICE_KEY    12 permissions recorded
  VAULT_TOKEN        5 capabilities recorded

$ npx secretless-ai scope check
  GCP_SERVICE_KEY    EXPANDED  +2 permissions (storage.objects.delete, iam.roles.create)
  VAULT_TOKEN        OK        no change

Broker Integration

Scope discovery integrates with the credential broker. Adding scopeCheck: true to a broker policy rule causes the broker to verify the credential scope baseline before granting access. If the scope has expanded since the last baseline, the broker blocks the request and logs a scope drift event.

broker-policies.json with scope check
{
  "rules": [
    {
      "credential": "GCP_SERVICE_KEY",
      "allow": ["my-deploy-script"],
      "scopeCheck": true
    }
  ]
}

Custom Deny Rules

Organizations can define additional deny patterns specific to their environment. These extend the built-in 49 credential patterns with company-specific env vars, config files, and CLI tools.

.secretless-rules.yaml
# Safe to commit -- contains patterns, not secrets
env:
  - ACME_*
  - INTERNAL_*

files:
  - "*.acme-credentials"
  - ".corp-config"

bash:
  - "curl*internal.corp.com*"
  - "corp-vault*get*"

Patterns use glob syntax where * matches any characters. Each pattern generates deny rules that block AI tools from accessing matching env vars, files, or running matching commands.

CommandDescription
npx secretless-ai rules initCreate a .secretless-rules.yaml template in the current directory
npx secretless-ai rules listShow active custom rules and the number of deny rules they generate
npx secretless-ai rules test "PATTERN" [--env|--file|--bash]Preview generated deny rules for a pattern

After editing the rules file, run npx secretless-ai init to apply changes to your AI tool configurations.

Secret Management

Secretless provides encrypted secret storage with multiple backend support. Secrets are stored outside the project directory and injected at runtime.

CommandDescription
npx secretless-ai secret set NAME=VALUEStore a secret in the active backend
npx secretless-ai secret listList stored secret names (values are never displayed)
npx secretless-ai secret get NAMERetrieve a secret value (requires biometric on supported backends)
npx secretless-ai secret rm NAMEDelete a stored secret
npx secretless-ai run -- <command>Run a command with all stored secrets injected as env vars
npx secretless-ai import <file>Import secrets from a .env file into the active backend
npx secretless-ai import --detectAuto-detect .env files in the current directory and import all
npx secretless-ai envOutput export statements for stored secrets (source-able in shell)
Store and use secrets
$ npx secretless-ai secret set OPENAI_API_KEY=sk-...
  Stored: OPENAI_API_KEY

$ npx secretless-ai run -- python app.py
  # app.py can read process.env.OPENAI_API_KEY at runtime

Credential Broker

The credential broker is a local daemon that mediates access to stored secrets. Instead of injecting all secrets into a process environment, the broker grants access per-request based on configurable policies. This enables rate limiting, trust-based access control, and audit logging for credential usage.

CommandDescription
npx secretless-ai broker start [--port N] [--policy-file PATH]Start the broker daemon
npx secretless-ai broker stopStop the broker daemon
npx secretless-ai broker statusShow broker status, uptime, and request count

Policy constraints include rateLimit (max requests per time window), minTrustScore (AIM integration), requireCapability (named permission check), and scopeCheck (scope drift detection). Default policy is deny-all — only explicitly allowed credentials are accessible.

The broker authenticates clients using bearer tokens. On startup, the broker generates a cryptographically random token (32 bytes via crypto.randomBytes) and writes it to ~/.secretless-ai/broker.token with mode 0600. Clients must include this token in the Authorization: Bearer header. Token comparison uses crypto.timingSafeEqual to prevent timing side-channel attacks.

Security Architecture

All cryptographic operations use Node.js built-in crypto module with no third-party dependencies.

FunctionAlgorithmDetails
Secret encryptionAES-256-GCMAuthenticated encryption with 96-bit IV, 128-bit auth tag
Key derivationscryptN=16384, r=8, p=1, 32-byte derived key
Session integrityHMAC-SHA256Timing-safe verification of session state files
Broker authBearer token32-byte random token, timing-safe comparison
Transcript redactionPattern matchingRegex-based credential detection with context-aware replacement

All symmetric primitives (AES-256, HMAC-SHA256, scrypt) are not affected by quantum computing advances. Asymmetric operations (GCP JWT signing via RS256) are handled by cloud provider infrastructure and outside the scope of this tool.

Transcript Protection

AI tools store conversation transcripts locally. If a credential was accidentally pasted into a conversation, it persists in the transcript file. Secretless can scan and redact credentials from stored transcripts.

CommandDescription
npx secretless-ai cleanScan and redact credentials in stored transcripts
npx secretless-ai clean --historyScan transcript history files
npx secretless-ai watch startMonitor transcript files in real-time and redact on write
npx secretless-ai watch stopStop the transcript monitor
npx secretless-ai watch statusCheck if the monitor is running

Supported AI Tools

Claude CodeCursorWindsurfAiderGitHub CopilotClineContinue.dev