Skip to content

fix(secrets): pin configuration-named secrets to the hosts they may reach - #641

Open
Bccorb wants to merge 3 commits into
mainfrom
fix/secret-env-host-pins
Open

Bccorb wants to merge 3 commits into
mainfrom
fix/secret-env-host-pins

Conversation

@Bccorb

@Bccorb Bccorb commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Closes #601 (L-API-12). L-API-9 to L-API-11 are in #639.

What changes

Configuration names the env var a secret lives in, and also the host it is sent to: an OAuth provider's tokenUrl receives the clientSecretEnv value, and an OTLP audit sink's endpoint receives every headersFromEnv value. Operators can now pin each secret to its hosts with <NAME>_HOSTS:

GOOGLE_CLIENT_SECRET_HOSTS=oauth2.googleapis.com
DD_AUDIT_SINK_SECRET_HOSTS=http-intake.logs.datadoghq.com
  • When the pin is set, a provider or sink that would send the secret to another host is refused. The check runs when it is written (where the endpoint is known) and again before each token exchange or send, including against a token endpoint found by discovery. Sink sends fail as misconfigured before any connection.
  • A pin that is set but lists no host allows none.
  • Syslog TLS names (tlsCaEnv, tlsClientCertEnv, tlsClientKeyEnv) with a pin are refused for a syslog host outside it.
  • No name a secret may have ends in _HOSTS, so configuration cannot set or name a pin.

Default

Pinning is opt-in in this release. An unpinned secret is still sent, and production logs one warning per variable that names it, never its value. Refusing unpinned secrets would stop every production OAuth provider and OTLP sink with header secrets on upgrade, which is out of proportion for a finding that already needs admin:write and step-up. Refusing them by default is deferred to a later minor, tracked in #640. Pinning is documented as recommended in production in docs/configuration.md and docs/oauth.md.

Compatibility

No route, schema or response change. Configs that were accepted before are refused only when an operator sets a pin they do not match.

Checks

npm run typecheck, npm run lint, npm run format:check and npm run coverage (3688 tests, 99.11% lines, 95.97% branches) pass.

Comment thread src/lib/secretHostPins.ts
if (!pinnedHosts(secretEnv, env) && env.NODE_ENV === 'production' && !warned.has(secretEnv)) {
warned.add(secretEnv);
logger.warn(
`${secretEnv} is not pinned to a host. Set ${secretHostsEnv(secretEnv)} to the hosts it may be sent to.`,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: low severity outbound call and exposure hardening (review bundle 2)

2 participants