Skip to content

fix: redact sensitive data from plugin log output#13123

Merged
Baoyuantop merged 8 commits into
apache:masterfrom
Baoyuantop:fix-log-key
Apr 7, 2026
Merged

fix: redact sensitive data from plugin log output#13123
Baoyuantop merged 8 commits into
apache:masterfrom
Baoyuantop:fix-log-key

Conversation

@Baoyuantop

Copy link
Copy Markdown
Contributor

Description

I reviewed all the code and removed any instances where the key might have been printed in the logs.

Which issue(s) this PR fixes:

Fixes #13118

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Mar 27, 2026
Baoyuantop and others added 2 commits March 30, 2026 11:15
- jwt-auth-more-algo.t: update error_log patterns from JSON format
  '"alg":"XXX"' to plain text 'parsed jwt alg: XXX'
- wolf-rbac.t: reduce grep_error_log_out expected count from 3 to 2
  since res.body log was removed
- ext-plugin/sanity.t: remove ' conf: [...]' from regex since conf
  is no longer logged after token redaction

Co-authored-by: Copilot <[email protected]>
Baoyuantop and others added 4 commits April 1, 2026 17:08
- proxy-cache/proxy-mirror: revert over-restrictive log changes; cache
  key and mirror conf contain no sensitive data (per review comments)
- wolf-rbac: remove wolf_token from perm_item to prevent accidental
  serialization, remove consumers dump, strip request body/headers/
  response body from request_to_wolf_server logs, replace consumer
  object dump with appid-only log in wolf_rbac_login
- ai-aliyun-content-moderation: replace str_to_sign debug log (which
  contained AccessKeyId and user content) with params count only

Co-authored-by: Copilot <[email protected]>
The wolf server returns error codes (e.g., ERR_USERNAME_MISSING) in
body.reason. Log this non-sensitive field instead of 'ok=false' so
that existing grep_error_log test patterns continue to match.

Co-authored-by: Copilot <[email protected]>
nic-6443
nic-6443 previously approved these changes Apr 7, 2026
Comment thread apisix/plugins/ext-plugin/init.lua Outdated
local token = fetch_token(unique_key)
if token then
core.log.info("fetch token from shared dict, token: ", token)
core.log.info("fetch token from shared dict, token: [REDACTED]")

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.

how about this?

Suggested change
core.log.info("fetch token from shared dict, token: [REDACTED]")
core.log.info("successfully fetched token from shared dict.")

Comment thread apisix/plugins/ext-plugin/init.lua Outdated
if token then
lock:unlock()
core.log.info("fetch token from shared dict, token: ", token)
core.log.info("fetch token from shared dict, token: [REDACTED]")

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.

ditto

Comment thread apisix/plugins/ext-plugin/init.lua Outdated
token = pcr:ConfToken()

core.log.notice("get conf token: ", token, " conf: ", core.json.delay_encode(conf.conf))
core.log.notice("get conf token: [REDACTED]")

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.

ditto

we don't need to mention "REDACTED" as it serves no real purpose, instead removing it entirely makes more sense.

local function content_moderation(ctx, conf, provider, model, content, length_limit,
stream, usage, service_name)
core.log.debug("execute content moderation, content: ", content)
core.log.debug("execute content moderation")

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.

nice

Address review feedback: remove [REDACTED] tokens from log output
as they serve no real purpose. Replace with clear status messages:
- 'successfully fetched token from shared dict.'
- 'successfully obtained conf token.'

Co-authored-by: Copilot <[email protected]>
@Baoyuantop
Baoyuantop merged commit 1e765b8 into apache:master Apr 7, 2026
21 of 23 checks passed
@Baoyuantop
Baoyuantop deleted the fix-log-key branch April 7, 2026 08:51
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ai plugins log summaries and payloads even when logging options are set to false

4 participants