From 13585d1005ae8c82044d2020cd4bdb4324a4fe97 Mon Sep 17 00:00:00 2001 From: Maria <maria.khaydich@tarantool.org> Date: Fri, 29 Nov 2019 00:59:18 +0300 Subject: [PATCH] box: replication shouldn't leak user password It was possible to leak user password through setting 'replication' configuration option in first box.cfg invocation. This happened due to unconditional logging in load_cfg function. The patch introduces conditional logging. Closes #4493 (cherry picked from commit 3ce08a3e9cf0386d93ecc694aa4c4f99056ae7ca) --- src/box/lua/load_cfg.lua | 3 +++ test/box/cfg.result | 30 ++++++++++++++++++++++++++++++ test/box/cfg.test.lua | 12 ++++++++++++ test/box/lua/cfg_test6.lua | 10 ++++++++++ 4 files changed, 55 insertions(+) create mode 100644 test/box/lua/cfg_test6.lua diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 85617c8f0b..5aa6ce7035 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -548,6 +548,9 @@ local function load_cfg(cfg) fun() end if not compare_cfg(val, default_cfg[key]) then + if log_cfg_option[key] ~= nil then + val = log_cfg_option[key](val) + end log.info("set '%s' configuration option to %s", key, json.encode(val)) end end diff --git a/test/box/cfg.result b/test/box/cfg.result index 5370bb8703..fe20eea011 100644 --- a/test/box/cfg.result +++ b/test/box/cfg.result @@ -580,3 +580,33 @@ test_run:cmd("cleanup server cfg_tester6") | --- | - true | ... + +-- +-- gh-4493: Replication user password may leak to logs +-- +test_run:cmd('create server cfg_tester7 with script = "box/lua/cfg_test6.lua"') + | --- + | - true + | ... +test_run:cmd("start server cfg_tester7") + | --- + | - true + | ... +-- test there is replication log in log +test_run:grep_log('cfg_tester7', 'set \'replication\' configuration option to', 1000) + | --- + | - set 'replication' configuration option to + | ... +-- test there is no password in log +test_run:grep_log('cfg_tester7', 'test%-cluster%-cookie', 1000) + | --- + | - null + | ... +test_run:cmd("stop server cfg_tester7") + | --- + | - true + | ... +test_run:cmd("cleanup server cfg_tester7") + | --- + | - true + | ... diff --git a/test/box/cfg.test.lua b/test/box/cfg.test.lua index 56ccb6767d..ba273bb739 100644 --- a/test/box/cfg.test.lua +++ b/test/box/cfg.test.lua @@ -141,3 +141,15 @@ test_run:cmd("start server cfg_tester6") test_run:grep_log('cfg_tester6', 'set \'vinyl_memory\' configuration option to 1073741824', 1000) test_run:cmd("stop server cfg_tester6") test_run:cmd("cleanup server cfg_tester6") + +-- +-- gh-4493: Replication user password may leak to logs +-- +test_run:cmd('create server cfg_tester7 with script = "box/lua/cfg_test6.lua"') +test_run:cmd("start server cfg_tester7") +-- test there is replication log in log +test_run:grep_log('cfg_tester7', 'set \'replication\' configuration option to', 1000) +-- test there is no password in log +test_run:grep_log('cfg_tester7', 'test%-cluster%-cookie', 1000) +test_run:cmd("stop server cfg_tester7") +test_run:cmd("cleanup server cfg_tester7") diff --git a/test/box/lua/cfg_test6.lua b/test/box/lua/cfg_test6.lua new file mode 100644 index 0000000000..efcfc6f3e1 --- /dev/null +++ b/test/box/lua/cfg_test6.lua @@ -0,0 +1,10 @@ +#!/usr/bin/env tarantool +os = require('os') + +box.cfg{ + listen = os.getenv("LISTEN"), + replication = "admin:test-cluster-cookie@" .. os.getenv("LISTEN"), + replication_connect_timeout = 0.1, +} + +require('console').listen(os.getenv('ADMIN')) -- GitLab