You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "marek-obuchowicz (via GitHub)" <gi...@apache.org> on 2026/05/28 12:32:20 UTC

[I] feat: loki-logger should not log authorization headers [apisix]

marek-obuchowicz opened a new issue, #13452:
URL: https://github.com/apache/apisix/issues/13452

   ### Description
   
   As a apisix user, I have enabled loki-logger (without overriding `log_format`) and I have quickly noticed, that all headers are being logged - including `request_headers_authorization`, `request_headers_x_userinfo`,`request_headers_x_access_token`.
   
   According to very common security practices, such data should not be logged. While we have possibility to override what's being logged via `log_format` - I would expect *defaults* to follow security practices.
   
   In ideal scenario, we should introduce a parameter to the plugin configuration, which contains list of HTTP headers to be dropped, and it should by default include `Authorization`, `X-Userinfo`, `X-Access-Token` fields.
   
   This could possibly apply to other logger plugins, too.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] feat: loki-logger should not log authorization headers [apisix]

Posted by "ruanweihong-aaa (via GitHub)" <gi...@apache.org>.
ruanweihong-aaa commented on issue #13452:
URL: https://github.com/apache/apisix/issues/13452#issuecomment-6331806668

   I checked the shared logging implementation to understand the scope of this request.
   
   The following plugins use `log-util.get_log_entry()` and include request headers in their default log payloads:
   
   - `loki-logger`, `http-logger`, `file-logger`
   - `tcp-logger`, `udp-logger`, `syslog`
   - `kafka-logger`, `rocketmq-logger` (with the default JSON format)
   - `elasticsearch-logger`, `clickhouse-logger`
   - `skywalking-logger`, `sls-logger`, `tencent-cloud-cls`
   - `splunk-hec-logging`, `loggly`
   
   The shared `get_log_entry()` implementation selects either a custom `log_format` or the default full log entry:
   
   https://github.com/apache/apisix/blob/c4f09e1f8297f5d825c26b9de310688b0fc127a8/apisix/utils/log-util.lua#L305-L322
   
   The default entry uses the masked header view when `data-mask` has provided one; otherwise, it collects request headers without a sensitive-header exclusion list:
   
   https://github.com/apache/apisix/blob/c4f09e1f8297f5d825c26b9de310688b0fc127a8/apisix/utils/log-util.lua#L197-L204
   
   `google-cloud-logging` also uses this helper, but its default output selects specific fields rather than exporting the full request headers:
   
   https://github.com/apache/apisix/blob/c4f09e1f8297f5d825c26b9de310688b0fc127a8/apisix/plugins/google-cloud-logging.lua#L191-L218
   
   Therefore, filtering sensitive headers in the shared default log entry would affect multiple plugins. Removing these fields by default would change existing log payloads and could affect users relying on them. An optional exclusion list could preserve existing behavior when unset, but would still need configuration schema support and regression coverage for the participating plugins. Custom formats, labels, and explicitly configured fields would need clearly defined behavior.
   
   Kafka and RocketMQ's `origin` format also uses a separate path, `get_req_original()`, which would need separate consideration:
   
   https://github.com/apache/apisix/blob/c4f09e1f8297f5d825c26b9de310688b0fc127a8/apisix/utils/log-util.lua#L358-L364
   
   Following @Baoyuantop's suggestion, could you clarify what prevents using `log_format` for your use case? Is the requirement to retain the complete default log structure while excluding only a few headers, or specifically to change the out-of-the-box defaults?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] feat: loki-logger should not log authorization headers [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #13452:
URL: https://github.com/apache/apisix/issues/13452#issuecomment-6358874846

   Thanks for the report. For excluding sensitive headers (e.g. Authorization, X-Userinfo, X-Access-Token) from logger payloads while keeping the default log structure, please use the [data-mask](https://apisix.apache.org/docs/apisix/plugins/data-mask/) plugin: it can remove or redact request headers in the log phase without changing the upstream request. You can also use a custom log_format if you prefer to replace the default entry entirely.
   
   Changing the shared default log entry to drop headers for all logger plugins would be a breaking behavior change, so we are not planning to alter those defaults in this issue.
   
   I'll close this for now. Please reopen (or comment) if data-mask / log_format does not cover your case.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] feat: loki-logger should not log authorization headers [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #13452:
URL: https://github.com/apache/apisix/issues/13452#issuecomment-4571693280

   Thanks for raising this. I checked the current implementation: when loki-logger runs without a custom log_format, it uses the shared default logger entry, which includes ngx.req.get_headers(), so sensitive request headers can indeed be included in the default log payload.
   
   For the current scenario, it is recommended to configure log_format to explicitly configure the content collected in the logs. Could you share why you did not use log_format?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] feat: loki-logger should not log authorization headers [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed issue #13452: feat: loki-logger should not log authorization headers
URL: https://github.com/apache/apisix/issues/13452


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org