Show HN: RunSecret – An open source secrets management CLI for developers

1 week ago 3

Go Report Card GitHub release License

Securely manage secrets for local development with one simple philosophy: Never store secrets statically

RunSecret (rsec) is a CLI tool that simplifies secret management for local development by injecting secrets from your team's vault at runtime.

Most engineering teams are solving local development secrets with git-ignored .env files. These files store secrets in plaintext, and are rife with problems:

  • ❌ Manual bootstrapping the secret values for every new developer
  • ❌ Regular manual updates need to be performed by every team member when secrets rotate
  • ❌ There's a high risk of accidental secret commits, especially when you're managing multiple .env files
  • ❌ Employees retain access to secrets when they rotate teams or leave the company

It's generally a pain for the developers, and a security risk for the company. RunSecret seeks to address these issues by providing a simple, secure way to manage secrets for local development.

RunSecret uses secret references to solve these problems. Think of these as pointers that replace the secrets themselves. To use RunSecret you simply:

  1. Update your environment variables or .env files with references to secrets (not the secrets themselves)
  2. Use rsec run to inject actual secret values from your vault at runtime
  3. Continue using your existing development workflow with no code changes!

Benefits:

  • Easy Setup: Works with existing .env files and environment variables
  • Team-Friendly: .env files can be safely committed to git, making team onboarding/offboarding a breeze
  • Vault Agnostic: Works with multiple secret storage solutions, with more on the way
  • Secure: Leverages your existing vault permissions so only those who need access to secrets can get them
  • Leak Prevention: Automatically redacts secret values in logs and console output

If you use Homebrew, you can install RunSecret with the following command:

brew install runsecret/tap/rsec

For Linux and macOS, you can use the following command to install RunSecret:

curl -sSL https://raw.githubusercontent.com/runsecret/rsec/main/scripts/install.sh | bash

For Linux and macOS, you can use the following command to install RunSecret:

wget -qO- https://raw.githubusercontent.com/runsecret/rsec/main/scripts/install.sh | bash

For Windows, you can use the following command to install RunSecret:

iwr -useb https://raw.githubusercontent.com/runsecret/rsec/main/scripts/install.ps1 | iex
  1. Authenticate with your secret vault

    Ensure your local machine is authenticated with your secrets vault. This can vary by vault provider, but often requires logging in via a provided CLI.

  2. Replace static secrets with references

    Instead of:

    DATABASE_PASSWORD=MyS3cretP@ssw0rd

    Use a secret reference (AWS Secrets Manager Example):

    DATABASE_PASSWORD=rsec://012345678912/sm.aws/MyDatabasePassword?region=us-east-1
  3. Run your application with rsec

    Or with a .env file:

    rsec run -e .env -- npm start

Secret references point to secrets in your vault. The format is consistent across all supported secret vaults, though optional arguments may only apply to specific Secret Vaults which support or require thoe features.

General Secret Reference Format

All secret references, regardless of the underlying vault, conform to the following format:

rsec://<vaultAddress>/<vaultType>/<secretNameOrPath>?<arguments>

where:

  • vaultAddress: Is the minimum address required to reach out to the vault. The exact format of this value may vary from one vault provider to the next.
  • vaultType: Is a specific string that tells rsec which vault provider this secret lives in.
  • secretNameOrPath: Is the full path (where applicable) or name of the secret you want to access.
  • arguments: Are optional arguments provided as query parameters to configure how to access the secret value. Note: Some arguments may only apply for certain secret vaults. These will be documented for each secret vault provider.

Tip: Use the rsec ref command to generate references from Vault Addresses or vice versa:

$ rsec ref arn:aws:secretsmanager:us-east-1:012345678912:secret:DatabasePassword Secret Reference: rsec://012345678912/sm.aws/MyTestSecret?region=us-east-1 Vault Address: arn:aws:secretsmanager:us-east-1:012345678912:secret:MyDatabasePassword

For examples specific to your vault provider, see the Supported Secret Vaults section.

Here's a complete workflow example:

  1. Create a .env file with secret references

    # myapp/.env DATABASE_URL=rsec://012345678912/sm.aws/DatabasePassword?region=us-east-1 API_KEY=rsec://apiVault/kv.azure/ApiKey
  2. Commit this file to your repository

    Since it contains only references, not actual secrets, it's safe to commit and share with your team.

  3. Run your application using rsec

For example:

rsec run -e .env -- npm start
  1. What happens behind the scenes:
    • RunSecret loads the .env file
    • Retrieves actual secrets from AWS Secrets Manager and Azure Key Vault (multiple vaults can be used simultaneously)
    • Injects them into the environment only for your application
    • Monitors stdout/stderr and redacts any accidental leaks of those secrets

Runs a command with secrets injected into the environment.

rsec run [-e|--env <.env file>] -- <command> [arguments]

Example:

rsec run -e .env -- npm run dev --prefix ./my_app

Retrieves and copies a secret value directly to your clipboard securely.

rsec copy <secret-reference>

Example:

rsec copy rsec://012345678912/sm.aws/MyApiKey?region=us-east-1

Generates a secret reference from a vault address, or vice versa.

Example:

rsec ref arn:aws:secretsmanager:us-east-1:012345678912:secret:MyApiKey

Authentication:

  • Uses standard AWS SDK authentication
  • Supports environment variables, shared credentials file, IAM roles

Limitations:

  • Only supports string values (not binary)

Secret Reference Format All AWS Secrets Manager references are constructed with the following values:

rsec://<accountNumber>/sm.aws/<secretName>?region=<region>

The region attribute is currently only applicable to AWS Secrets Manager references, and will appear on all secret references for this provider.

Example:

rsec://012345678912/sm.aws/DatabasePassword?region=us-east-1

Authentication:

  • Uses standard Azure SDK authentication
  • Supports Azure CLI, Managed Identity, Service Principal

Secret Reference Format For Azure Key Vault, the reference format is:

rsec://<vaultAddress>/kv.azure/<secretName>?<arguments>

Where:

  • vaultAddress: The name of the Azure Key Vault (e.g. if using https://myvault.vault.azure.net/ then myvault is the vault address)
  • secretName: The name of the secret in the Azure Key Vault
  • arguments: Optional arguments, such as version to specify a specific version of the secret.

Example:

rsec://myvault/kv.azure/MySecret?version=1.0

Using Azure China/Azure Government/Azure Germany If you are using Azure China, Azure Government, or Azure Germany, you can use rsec in the same way described above, but will replace the kv.azure with a region-specific value. For example, for Azure China, you would use kv.azure.cn instead of kv.azure. Example secret references for each Azure region is as follows:

# Azure China rsec://myvault/kv.azure.cn/MySecret?version=1.0 # Azure Government rsec://myvault/kv.azure.us/MySecret?version=1.0 # Azure Germany rsec://myvault/kv.azure.de/MySecret?version=1.0

Supports both versions of the KV secret engine (v1 and v2) and credential-based secret engines such as database, AWS, RabbitMQ, etc.

Authentication:

  • Currently supports token-based authentication via one of the following methods:
    • The VAULT_TOKEN environment variable
    • Tokens set in the ~/.vault-token file (via userpass authentication)

Limitations

  • Currently returns the entire secret object, not just the value. This will be addressed in issue #8.

Secret Reference Format For HashiCorp Vault, the reference format may look like one of the following:

rsec://<mountPath>/kv1.hashi/<secretName>?<arguments> rsec://<mountPath>/kv2.hashi/<secretName>?<arguments> rsec://<mountPath>/cred.hashi/<secretName>?<arguments>

Where:

  • mountPath: The path where the secret or credential is mounted in HashiCorp Vault.
  • secretName: The name of the secret in HashiCorp Vault
  • arguments: Optional arguments
    • endpoint: The URL encoded endpoint to the HashiCorp Vault server (e.g. https://vault.example.com). If not set, will default to the VAULT_ADDR environment variable.

Upcoming Vault Support (Roadmap)

  • GCP Secret Manager
  • AWS Parameter Store

We recommend using the same method you used to install RunSecret to uninstall it. For example, if you installed it with Homebrew, you can uninstall it with:

brew uninstall runsecret/tap/rsec

If you installed it with the install script, you can uninstall it with:

curl -sSL https://raw.githubusercontent.com/runsecret/rsec/main/scripts/uninstall.sh | bash

Or with wget:

wget -qO- https://raw.githubusercontent.com/runsecret/rsec/main/scripts/uninstall.sh | bash

Or with PowerShell:

iwr -useb https://raw.githubusercontent.com/runsecret/rsec/main/scripts/uninstall.ps1 | iex

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feat/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

This project is licensed under the MIT License - see the LICENSE file for details.

Read Entire Article