Skip to content

fix(config): fail at boot when a configured key version has no key - #387

Open
ASJ18 wants to merge 2 commits into
Rotula-Labs:mainfrom
ASJ18:fix/issue-238-fix-config-fail-at-boot-when-a-configured-key
Open

ASJ18 wants to merge 2 commits into
Rotula-Labs:mainfrom
ASJ18:fix/issue-238-fix-config-fail-at-boot-when-a-configured-key

Conversation

@ASJ18

@ASJ18 ASJ18 commented Oct 17, 2026

Copy link
Copy Markdown

Overview

This PR makes encryption key configuration fail fast at boot. src/config/env.ts now cross-checks CURRENT_ENCRYPTION_KEY_VERSION against the ENCRYPTION_KEYS map, so a missing or malformed key for the active version is rejected during configuration load instead of surfacing later inside getKeyBuffer on the first wallet operation.

Related Issue

Changes

🔐 Boot-time key validation

  • [MODIFY] src/config/env.ts
    • After parsing CURRENT_ENCRYPTION_KEY_VERSION and building ENCRYPTION_KEYS, validate that an entry exists for the current version and that its value is a usable key.
    • Missing key for the current version now throws at boot with a message naming the expected variable (e.g. ENCRYPTION_KEY_V2).
    • Present but malformed key for the current version also throws at boot.
    • A fully populated map continues to boot unchanged.

Verification Results

npm test
✅ passes locally
Acceptance Criteria Status
Booting with the current version set and its key missing fails immediately, naming the variable ✅ Validation in env.ts throws with the missing variable name
A present but malformed key for the current version also fails at boot ✅ Malformed key rejected during config load
A fully populated map boots unchanged ✅ No behavior change for valid configurations
A test covers the missing and malformed cases ✅ Covered via npm test
npm test passes locally ✅ Passes

Closes #238

Toyosi5566 and others added 2 commits October 16, 2026 15:32
.env is read by dotenv.config() at boot and holds ENCRYPTION_KEY, JWT_SECRET,
SEP10_SERVER_SECRET, HMAC_KEY and DEPLOYER_SECRET_KEY. None of the .env
variants were ignored, so a contributor's real credentials file could be
staged by a routine `git add .` with nothing to warn anyone. Ignore the
.env variants and keep the committed example file trackable.

No .env file is tracked at HEAD and no .env object appears anywhere in the
repository history, so this is preventive rather than a remediation.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@ASJ18 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abdul-dev-creator
Abdul-dev-creator force-pushed the main branch 2 times, most recently from af3277b to a2a4455 Compare October 18, 2026 18:47
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(config): fail at boot when a configured key version has no key

2 participants