Skip to content

fix: correct base64 detection for ENCRYPTION_KEY#6036

Open
yb175 wants to merge 2 commits intoInfisical:mainfrom
yb175:fix/encryption-key-detection
Open

fix: correct base64 detection for ENCRYPTION_KEY#6036
yb175 wants to merge 2 commits intoInfisical:mainfrom
yb175:fix/encryption-key-detection

Conversation

@yb175
Copy link
Copy Markdown

@yb175 yb175 commented Apr 15, 2026

Context

Local development was failing with a 502 Bad Gateway on /login. Backend logs revealed KMS initialization failing due to Invalid key length.

The root cause: inverted logic when checking if ENCRYPTION_KEY is base64-encoded. The condition !envConfig.ENCRYPTION_KEY was treating a present key as missing, causing it to be decoded as UTF-8 instead of base64. This resulted in a 44-byte buffer instead of the required 32 bytes for AES-256-GCM.

Fix

Changed the condition to !!envConfig.ENCRYPTION_KEY, so base64-encoded keys are correctly decoded when present.

Verification

  1. Set up the project locally with default dev config
  2. Start backend and frontend
  3. Navigate to /login
  4. Before: 502 Bad Gateway + Invalid key length in logs
  5. After: Backend starts cleanly, /login loads successfully

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows conventional commit format
  • Tested locally
  • Updated docs (if needed)
  • Updated CLAUDE.md files (if needed)
  • Read the contributing guide

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@maidul98
Copy link
Copy Markdown
Collaborator

maidul98 commented Apr 15, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b515dede5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/src/services/kms/kms-service.ts Outdated
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.

2 participants