Why use secrets?
Builds that are executed remotely on BuildBuddy’s servers may occasionally need access to an API key or other credentials. For example, you may want to pass credentials for a Docker image. Secrets solve this problem by allowing sensitive keys to be stored in encrypted format separately from the actions themselves.Defining secrets
Secrets can be added to your organization using the Secrets page in settings.Add a new secret
Click “Add Secret” and provide:
- Secret name (used to reference it in your builds)
- Secret value (will be encrypted before storage)
Secrets can be edited or deleted using the Secrets page. Once a secret
is saved, its currently stored value cannot be viewed using the Secrets
page.
Getting secret values
- Bazel actions
- Workflows
To opt a specific action into secrets, you can define the remote exec
property
include-secrets=true. We recommend doing this per-action to
avoid exposing secrets to actions that do not need them.Example:BUILD
Short-lived secrets
For secrets that have a short Time To Live (TTL), BuildBuddy supports setting environment variables via special headers passed at the Bazel command line. Headers are more secure than setting environment variables with Bazel, as they are not stored in the remote cache.- Simple Secrets
- Complex Secrets
Use At execution time:
env-overrides for simple key-value pairs:If multiple values are given with the same variable name, the last value will be used.
If a variable is specified in both
env-overrides and env-overrides-base64,
env-overrides-base64 will take priority.env-overrides or env-overrides-base64 headers
are not subjected to include-secrets control documented above.
Security notes
Secrets are encrypted on the client-side using libsodium, which is based on NaCl.Organization-specific keys
The public key used to encrypt secrets is unique to each organization. The private key used to decrypt secrets is stored encrypted and only decrypted when used to unseal secrets.
Encrypted at rest
Secrets are only stored in their encrypted form and are decrypted on-demand for actions that opt in to receiving secrets.
Encrypted in transit
All communication with BuildBuddy servers uses TLS encryption to protect secrets during transmission.
Minimal exposure
Secrets are only decrypted for actions that explicitly opt in, reducing the attack surface.
Best practices
Use short-lived tokens when possible
Use short-lived tokens when possible
Prefer generating short-lived tokens (e.g., using
gcloud auth print-access-token) over storing long-lived credentials. Pass these via remote headers for maximum security.Minimize secret scope
Minimize secret scope
Only enable
include-secrets=true for specific actions that need secrets, not globally for all actions.Rotate secrets regularly
Rotate secrets regularly
Update secrets periodically and when team members with access leave the organization.
Audit secret usage
Audit secret usage
Review which actions have access to secrets and remove unnecessary access.
Use descriptive names
Use descriptive names
Name secrets clearly to indicate their purpose and scope (e.g.,
PROD_DB_PASSWORD vs db_pass).