security: remove REDIS_SSL_PRIVATE_KEY env var path (PER-8500)#52
Open
amandeepsingh333 wants to merge 2 commits into
Open
security: remove REDIS_SSL_PRIVATE_KEY env var path (PER-8500)#52amandeepsingh333 wants to merge 2 commits into
amandeepsingh333 wants to merge 2 commits into
Conversation
Percy::RedisClient previously accepted the raw RSA private key via the REDIS_SSL_PRIVATE_KEY environment variable. Anything that captures the process environment -- /proc, crash reporters (Sentry, Honeybadger, the Datadog APM env-capture, etc.), pod specs, audit logs -- could lift the key in plaintext, after which an attacker could impersonate the Redis client in mutual-TLS or decrypt captured sessions (CVSS 5.5, AV:L/PR:L). Drop the private_key_from_env code path entirely. Callers must now supply key material either explicitly via ssl_params[:key] or by pointing REDIS_SSL_PRIVATE_KEY_PATH at a file with restrictive (e.g. 0400) permissions. On k8s/ECS this should be a volume-backed secret, not an env var. This is intentionally a breaking change for any downstream service currently setting REDIS_SSL_PRIVATE_KEY: they need to migrate to the _PATH variant or pass the key into ssl_params directly. The cert-side counterpart (REDIS_SSL_CLIENT_CERTIFICATE) is left in place -- it carries no private key material -- and should be tackled separately if we want to standardise on file-only inputs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds a spec under 'with an SSL-enabled redis URL' that:
* unsets every REDIS_SSL_* env var,
* supplies REDIS_SSL_CERTIFICATE_AUTHORITY_PATH and
REDIS_SSL_CLIENT_CERTIFICATE_PATH so the configuration check
reaches the private-key branch,
* sets REDIS_SSL_PRIVATE_KEY (the env var the removed code path used
to honour) to a placeholder value, and
* asserts that Percy::RedisClient.new raises
InvalidConfiguration with `REDIS_SSL_PRIVATE_KEY_PATH is not defined`.
The assertion pins the new failure mode and prevents a future patch
from silently restoring the env-var fallback. The original env state
is restored in `ensure`.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PER-8500 — `Percy::RedisClient` previously accepted the raw RSA private key via `REDIS_SSL_PRIVATE_KEY`. Anything that captures the process environment (`/proc`, Sentry, Honeybadger, Datadog APM env-capture, pod specs, audit logs) could lift the key in plaintext, enabling Redis-client impersonation in mTLS or decryption of captured sessions. CVSS 5.5, CWE-321.
This PR drops the `private_key_from_env` code path entirely. Key material must now be supplied either:
Why this is split from the other PER-* fixes
This is a behaviour-changing breaking change: any downstream service currently setting `REDIS_SSL_PRIVATE_KEY` will start raising `InvalidConfiguration: REDIS_SSL_PRIVATE_KEY_PATH is not defined` the moment it picks up the new percy-common. Separating it from the other PER tickets so it can be reviewed and rolled out on its own cadence.
Action item for reviewers: before merging, please confirm whether any production service in the org sets `REDIS_SSL_PRIVATE_KEY` (rg / grep across the consuming repos). If so, those services need to be cut over to `REDIS_SSL_PRIVATE_KEY_PATH` (or pass the key directly via `ssl_params`) in the same release that bumps percy-common.
The cert-side counterpart `REDIS_SSL_CLIENT_CERTIFICATE` (env var) is left in place — it carries no private-key material — and can be tackled separately if we want to standardise on file-only inputs.
Test plan