fix(config): require chain.redis.password when env="production"#45
Merged
Conversation
Closes audit #15. The deployment runbook says Redis MUST be password-protected in production, but the schema marked chain.redis.password as optional() unconditionally. An operator could deploy with config.env="production" and a missing/empty password and the server would happily come up, connecting to an unauthenticated Redis. That's a real production-safety gap. Adds a superRefine on the root ConfigSchema that mirrors the existing MAINNET=true guardrail in chain/config.ts: when config.env is "production", chain.redis.password must be a non-empty, non-whitespace string. Otherwise the config fails validation at startup with a descriptive error pointing to .env and config.json. development and test envs are unaffected -- they can still run without a Redis password (the default dev compose's redis service has no auth). 5 new tests cover: missing password rejected, empty string rejected, whitespace-only rejected, valid password accepted, dev mode unaffected. Full suite: 34 files / 457 tests pass (was 34 / 452). Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Closes audit #15. The deployment runbook says Redis must be password-protected in production, but the schema marked `chain.redis.password` as `optional()` unconditionally — an operator could deploy with `config.env="production"` and a missing/empty password and the server would happily come up, connecting to an unauthenticated Redis. Real production-safety gap.
Fix
A `superRefine` on the root `ConfigSchema` mirroring the existing `MAINNET=true` guardrail in `chain/config.ts`:
```ts
if (data.env === 'production') {
const pwd = data.chain.redis.password;
if (!pwd || pwd.trim() === '') {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'chain.redis.password is required when config.env is "production". ...',
path: ['chain', 'redis', 'password'],
});
}
}
```
The check fails closed at startup with a descriptive error path. Dev and test envs are unaffected (no-auth Redis in the dev compose still works).
Production impact
Current production config (the one bind-mounted on this VPS) already has a Redis password set — verified by the running container's healthcheck succeeding. So this change is a no-op for the live deployment but adds the missing guardrail for any future fresh setup or misconfiguration.
Test plan
🤖 Generated with Claude Code