Hide user data from log (#13400)
This PR is based on the commits from PR #11747. In the event of an assertion failure, hide command arguments from the operator. In some cases, private client information can be voluntarily exposed when a redis instance crashes due to an assertion failure. This commit prevent וnintentional client info exposure. Operators can still access the hidden data, but they must actively request it. Any of the client info commands remains the unchanged. ### Config Add a new config `hide-user-data-from-log` to turn this feature on and off, default off. --------- Co-authored-by: naglera <anagler123@gmail.com> Co-authored-by: naglera <58042354+naglera@users.noreply.github.com>
This commit is contained in:
co-authored by
naglera
naglera
parent
b699e8bfe0
commit
69b480cb7a
+19
@@ -4,6 +4,8 @@
|
||||
*
|
||||
* Licensed under your choice of the Redis Source Available License 2.0
|
||||
* (RSALv2) or the Server Side Public License v1 (SSPLv1).
|
||||
*
|
||||
* Portions of this file are available under BSD3 terms; see REDISCONTRIBUTIONS for more information.
|
||||
*/
|
||||
|
||||
#include "server.h"
|
||||
@@ -1067,6 +1069,11 @@ void _serverAssert(const char *estr, const char *file, int line) {
|
||||
bugReportEnd(0, 0);
|
||||
}
|
||||
|
||||
/* Returns the amount of client's command arguments we allow logging */
|
||||
int clientArgsToLog(const client *c) {
|
||||
return server.hide_user_data_from_log ? 1 : c->argc;
|
||||
}
|
||||
|
||||
void _serverAssertPrintClientInfo(const client *c) {
|
||||
int j;
|
||||
char conninfo[CONN_INFO_LEN];
|
||||
@@ -1077,6 +1084,10 @@ void _serverAssertPrintClientInfo(const client *c) {
|
||||
serverLog(LL_WARNING,"client->conn = %s", connGetInfo(c->conn, conninfo, sizeof(conninfo)));
|
||||
serverLog(LL_WARNING,"client->argc = %d", c->argc);
|
||||
for (j=0; j < c->argc; j++) {
|
||||
if (j >= clientArgsToLog(c)) {
|
||||
serverLog(LL_WARNING,"client->argv[%d] = *redacted*",j);
|
||||
continue;
|
||||
}
|
||||
char buf[128];
|
||||
char *arg;
|
||||
|
||||
@@ -1275,6 +1286,10 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
|
||||
|
||||
REDIS_NO_SANITIZE("address")
|
||||
void logStackContent(void **sp) {
|
||||
if (server.hide_user_data_from_log) {
|
||||
serverLog(LL_NOTICE,"hide-user-data-from-log is on, skip logging stack content to avoid spilling PII.");
|
||||
return;
|
||||
}
|
||||
int i;
|
||||
for (i = 15; i >= 0; i--) {
|
||||
unsigned long addr = (unsigned long) sp+i;
|
||||
@@ -2050,6 +2065,10 @@ void logCurrentClient(client *cc, const char *title) {
|
||||
sdsfree(client);
|
||||
serverLog(LL_WARNING|LL_RAW,"argc: '%d'\n", cc->argc);
|
||||
for (j = 0; j < cc->argc; j++) {
|
||||
if (j >= clientArgsToLog(cc)) {
|
||||
serverLog(LL_WARNING|LL_RAW,"argv[%d]: *redacted*\n",j);
|
||||
continue;
|
||||
}
|
||||
robj *decoded;
|
||||
decoded = getDecodedObject(cc->argv[j]);
|
||||
sds repr = sdscatrepr(sdsempty(),decoded->ptr, min(sdslen(decoded->ptr), 128));
|
||||
|
||||
Reference in New Issue
Block a user