Skip to content

fix(config): require chain.redis.password when env="production"#45

Merged
MorganOnCode merged 1 commit into
masterfrom
fix/redis-password-prod-required
May 15, 2026
Merged

fix(config): require chain.redis.password when env="production"#45
MorganOnCode merged 1 commit into
masterfrom
fix/redis-password-prod-required

Conversation

@MorganOnCode
Copy link
Copy Markdown
Owner

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

  • typecheck / lint / 457 tests (5 new) all pass
  • CI passes
  • After deploy: container restarts cleanly (no config rejection — current config has the password)

🤖 Generated with Claude Code

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>
@MorganOnCode MorganOnCode merged commit d61e73e into master May 15, 2026
5 checks passed
@MorganOnCode MorganOnCode deleted the fix/redis-password-prod-required branch May 15, 2026 10:45
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.

1 participant