Skip to content

fix: avoid logging plaintext value when encrypt/decrypt fails#13298

Merged
nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:fix/encrypt-fields-plaintext-log-leak
Apr 27, 2026
Merged

fix: avoid logging plaintext value when encrypt/decrypt fails#13298
nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:fix/encrypt-fields-plaintext-log-leak

Conversation

@nic-6443

@nic-6443 nic-6443 commented Apr 25, 2026

Copy link
Copy Markdown
Member

When a plugin field is newly marked as encrypt_fields, pre-existing plaintext configs in etcd will fail to decrypt. The base64 decode and encrypt failure paths in ssl.lua previously logged the original value (e.g. key[<plaintext>]), leaking sensitive data to the error log.

This PR removes the raw value from all error log messages in encrypt() and aes_decrypt_pkey().

Changes

  • apisix/ssl.lua: Remove origin from error logs in encrypt() and aes_decrypt_pkey()
  • t/lib/test_admin.lua: Same fix in the test helper's aes_encrypt()
  • t/node/data_encrypt.t: Add no_error_log assertions to verify plaintext is not logged

Fixes #11565

Copilot AI review requested due to automatic review settings April 25, 2026 03:14
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Apr 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Prevents sensitive plaintext from being written to error logs when encryption/decryption fails for newly encrypt_fields-marked plugin fields.

Changes:

  • Remove logging of raw key material/plaintext values in apisix/ssl.lua encryption/decryption error paths.
  • Apply the same log-sanitization in the test helper t/lib/test_admin.lua.
  • Add no_error_log assertions in t/node/data_encrypt.t to ensure plaintext does not appear in logs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
apisix/ssl.lua Removes plaintext from encryption/decryption failure logs.
t/lib/test_admin.lua Updates test helper logging to avoid printing plaintext on encrypt failure.
t/node/data_encrypt.t Adds assertions intended to ensure plaintext isn’t leaked to error logs.

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

Comment thread t/node/data_encrypt.t Outdated
Comment thread t/node/data_encrypt.t Outdated
@nic-6443
nic-6443 force-pushed the fix/encrypt-fields-plaintext-log-leak branch from 71d1920 to f2d8872 Compare April 25, 2026 03:18
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Apr 25, 2026
When a plugin field is newly marked as encrypt_fields, pre-existing
plaintext configs in etcd will fail to decrypt. The base64 decode and
encrypt failure paths in ssl.lua previously logged the original value
(e.g. 'key[<plaintext>]'), leaking sensitive data to the error log.

Remove the raw value from all error log messages in encrypt() and
aes_decrypt_pkey().
@nic-6443
nic-6443 force-pushed the fix/encrypt-fields-plaintext-log-leak branch from f2d8872 to 89fe41a Compare April 25, 2026 03:21
@nic-6443
nic-6443 merged commit c8bab5d into apache:master Apr 27, 2026
19 checks passed
@nic-6443
nic-6443 deleted the fix/encrypt-fields-plaintext-log-leak branch April 27, 2026 02:07
wistefan pushed a commit to wistefan/apisix that referenced this pull request Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: error decrypting config file

5 participants