File explanation-format.patch of Package rabbitmq-server
From 4b644692a41732dff21970ed1cfe640a848e61b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?=
<jean-sebastien@rabbitmq.com>
Date: Thu, 31 Oct 2019 14:00:18 +0100
Subject: [PATCH] rabbit_reader: Format `Explanation` before passing it
... to `rabbit_misc:amqp_error()`.
`Explanation` can be a user input. Therefore, we don't want to pass it
as a format string to `rabbit_misc:amqp_error()`, as we can't trust its
content.
Now, we pass our own format string ("~s") and `Explanation` becomes
the argument to that format string. This ensures we don't interpret
untrusted user input.
Discussed with: @dcorbacho, @essen and @michaelklishin.
---
src/rabbit_reader.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/deps/rabbit/src/rabbit_reader.erl b/deps/rabbit/src/rabbit_reader.erl
index 39ac0ef8ac..116dcf89e6 100644
--- a/deps/rabbit/src/rabbit_reader.erl
+++ b/deps/rabbit/src/rabbit_reader.erl
@@ -646,7 +646,7 @@ switch_callback(State, Callback, Length) ->
terminate(Explanation, State) when ?IS_RUNNING(State) ->
{normal, handle_exception(State, 0,
rabbit_misc:amqp_error(
- connection_forced, Explanation, [], none))};
+ connection_forced, "~s", [Explanation], none))};
terminate(_Explanation, State) ->
{force, State}.