Skip to content

F-6133 enc: fail on unsupported -pass source instead of empty password#256

Open
julek-wolfssl wants to merge 2 commits into
wolfSSL:mainfrom
julek-wolfssl:fenrir/20260623
Open

F-6133 enc: fail on unsupported -pass source instead of empty password#256
julek-wolfssl wants to merge 2 commits into
wolfSSL:mainfrom
julek-wolfssl:fenrir/20260623

Conversation

@julek-wolfssl

Copy link
Copy Markdown
Member

wolfCLU_setup ignored the return value of wolfCLU_GetPassword in the WOLFCLU_PASSWORD_SOURCE (-pass) case. wolfCLU_GetPassword only accepts the "stdin" and "pass:" sources; for any other source it zeroes the password buffer and returns WOLFCLU_FATAL_ERROR. The error was ignored and the crypto dispatch was not gated on ret, so encryption proceeded with an all-zero password, wrote a valid output file, and returned success. A user passing an OpenSSL-style "env:", "file:", or "fd:" source therefore silently encrypted under an empty password.

Check the return value and bail out (freeing buffers) on failure.

Add EncPassSourceTest regression tests covering unsupported sources and the still-working pass: source.

wolfCLU_setup ignored the return value of wolfCLU_GetPassword in the
WOLFCLU_PASSWORD_SOURCE (-pass) case. wolfCLU_GetPassword only accepts the
"stdin" and "pass:" sources; for any other source it zeroes the password
buffer and returns WOLFCLU_FATAL_ERROR. The error was ignored and the
crypto dispatch was not gated on ret, so encryption proceeded with an
all-zero password, wrote a valid output file, and returned success. A user
passing an OpenSSL-style "env:", "file:", or "fd:" source therefore
silently encrypted under an empty password.

Check the return value and bail out (freeing buffers) on failure.

Add EncPassSourceTest regression tests covering unsupported sources and the
still-working pass: source.
Copilot AI review requested due to automatic review settings June 23, 2026 13:11
@julek-wolfssl julek-wolfssl self-assigned this Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a security-sensitive behavior in the enc command path: when -pass is given an unsupported password source (e.g., env:, file:, fd:), the tool must fail instead of silently proceeding with an all-zero/empty password. It also adds regression tests to ensure unsupported sources fail and the supported pass: source continues to work.

Changes:

  • Gate the WOLFCLU_PASSWORD_SOURCE (-pass) flow on wolfCLU_GetPassword()’s return value and bail out on failure.
  • Add regression tests covering unsupported -pass sources and a successful pass: round-trip.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/crypto/clu_crypto_setup.c Adds early-exit error handling for unsupported -pass sources to prevent encrypting with an empty key.
tests/encrypt/enc-test.py Adds EncPassSourceTest regression tests for unsupported password sources and the supported pass: source.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/crypto/clu_crypto_setup.c Outdated
The other early error returns in wolfCLU_setup do not free mode, so
freeing it only in this path was inconsistent. Keep the error handling
minimal and uniform with the sibling -key/-iv/-inkey error returns.
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.

3 participants