From b6689d178f369bb2ba72d575e30eff5d4c615e7c Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 20 Feb 2024 12:52:12 -0300 Subject: [PATCH] fix(http_bridge): redact headers Fixes https://emqx.atlassian.net/browse/EMQX-11864 ``` 2024-02-20T15:51:34.744509+00:00 [debug] msg: http_connector_received, mfa: emqx_bridge_http_connector:on_query_async/4(471), tag: QUERY_ASYNC, request: {"/bah",[{<<"Authorization">>,<<"******">>},{<<"content-type">>,<<"application/json">>},{<<"authorization">>,<<"******">>},{<<"content-type">>,<<"application/json">>}],<<"******">>}, state: #{port => 18083,request => #{path => [<<>>],body => undefined,headers => [{[<<"content-type">>],[<<"application/json">>]},{[<<"Authorization">>],#Fun}],method => [<<"undefined">>],max_retries => 2,request_timeout => 30000},host => "localhost",connect_timeout => 15000,pool_type => random,pool_name => <<"connector:http:p1">>,base_path => "/",installed_actions => #{<<"action:http:p1:connector:http:p1">> => #{path => [<<"/bah">>],body => undefined,headers => [{[<<"authorization">>],#Fun},{[<<"content-type">>],[<<"application/json">>]}],method => [<<"post">>],max_retries => 2,request_timeout => 30000,render_template_func => fun emqx_bridge_http_connector:render_template/2}}}, connector: <<"connector:http:p1">>, note: the request body is redacted due to security reasons ``` --- apps/emqx_bridge_http/src/emqx_bridge_http.app.src | 2 +- apps/emqx_bridge_http/src/emqx_bridge_http_connector.erl | 4 ++-- changes/ce/fix-12542.en.md | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changes/ce/fix-12542.en.md diff --git a/apps/emqx_bridge_http/src/emqx_bridge_http.app.src b/apps/emqx_bridge_http/src/emqx_bridge_http.app.src index 0c355691b..0876d5737 100644 --- a/apps/emqx_bridge_http/src/emqx_bridge_http.app.src +++ b/apps/emqx_bridge_http/src/emqx_bridge_http.app.src @@ -1,6 +1,6 @@ {application, emqx_bridge_http, [ {description, "EMQX HTTP Bridge and Connector Application"}, - {vsn, "0.2.2"}, + {vsn, "0.2.3"}, {registered, []}, {applications, [kernel, stdlib, emqx_resource, ehttpc]}, {env, [{emqx_action_info_modules, [emqx_bridge_http_action_info]}]}, diff --git a/apps/emqx_bridge_http/src/emqx_bridge_http_connector.erl b/apps/emqx_bridge_http/src/emqx_bridge_http_connector.erl index a148a4d16..ac9b18ace 100644 --- a/apps/emqx_bridge_http/src/emqx_bridge_http_connector.erl +++ b/apps/emqx_bridge_http/src/emqx_bridge_http_connector.erl @@ -876,9 +876,9 @@ redact(Data) -> %% and we also can't know the body format and where the sensitive data will be %% so the easy way to keep data security is redacted the whole body redact_request({Path, Headers}) -> - {Path, Headers}; + {Path, redact(Headers)}; redact_request({Path, Headers, _Body}) -> - {Path, Headers, <<"******">>}. + {Path, redact(Headers), <<"******">>}. clientid(Msg) -> maps:get(clientid, Msg, undefined). diff --git a/changes/ce/fix-12542.en.md b/changes/ce/fix-12542.en.md new file mode 100644 index 000000000..1ad493d49 --- /dev/null +++ b/changes/ce/fix-12542.en.md @@ -0,0 +1 @@ +Redacted authorization headers from debug logs from HTTP bridge.