You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe:
Sensitive data can be written to the error log in many cases. This is problematic for environments where strict controls must be placed on sensitive, identifying, or financial data.
Describe the feature you'd like:
We should ensure that sensitive data is not written to error and other informational logs. These are different from logs that are explicitly enabled by the user (the general query log, slow query log, etc.), for which desensitization procedures would be different.
To resolve this issue will require an extensive audit of how we write log entries. There are many cases where the contents of SQL statements are written to the log (permission failures, syntax errors, etc.), and all of those need to be dealt with to resolve this task.
In particular, server/conn.go is often responsible for printing the full query text if there is an execution problem. This would be a good place to start with masking query content. Perhaps a system variable to control whether error log output is desensitized (default ON) and some changes to func (cc getLastStmtInConn) String() string (https://github.com/pingcap/tidb/blob/release-4.0/server/conn.go#L1604) would be a good start.
when tidb_log_desensitization is set to 1, the duplicated key is printed to the log. I'm going to reopen this since it has not been fixed totally.
Here is an example:
createtablet(a bigintprimary key, b bigint);
insert into t values(1, 1);
insert into t values(1, 1); -- returns: ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
when tidb_log_desensitization is set to 1, the duplicated key is printed to the log. I'm going to reopen this since it has not been fixed totally.
Here is an example:
createtablet(a bigintprimary key, b bigint);
insert into t values(1, 1);
insert into t values(1, 1); -- returns: ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
the privilege of turning the global variable tidb_log_desensitization also needs careful design. for example, only users with super privilege can turn on or turn off this variable.
I think it might be more practical to document that it is only supported for INFO and higher levels? Debug implies verbose, so as a user I don't have a full expectation I can have both. But for safety, it might be useful to handle this in config check, and refuse to allow DEBUG if tidb_log_desensitization is enabled.
Activity
kolbe commentedon Jul 14, 2020
In particular, server/conn.go is often responsible for printing the full query text if there is an execution problem. This would be a good place to start with masking query content. Perhaps a system variable to control whether error log output is desensitized (default ON) and some changes to
func (cc getLastStmtInConn) String() string(https://github.com/pingcap/tidb/blob/release-4.0/server/conn.go#L1604) would be a good start.nolouch commentedon Jul 31, 2020
closed by #18578
zz-jason commentedon Aug 6, 2020
when
tidb_log_desensitizationis set to1, the duplicated key is printed to the log. I'm going to reopen this since it has not been fixed totally.Here is an example:
the log printed for the last insert statement:
zz-jason commentedon Aug 6, 2020
@zanmato1984 PTAL, thanks.
zz-jason commentedon Aug 6, 2020
maybe we can write a tool to monitor the log file. report a security issue if it prints data in the table or from the query.
zz-jason commentedon Aug 7, 2020
It exposes another issue: we can reduce the logs of
Duplicate entryerror. #19052 was created to track this log expansion.zz-jason commentedon Aug 7, 2020
I noticed that it's a P0 sub-task in #18084, also we'd better backport this security improvement to release 4.0
zz-jason commentedon Aug 7, 2020
we also need to consider the
debuglevel logs.zz-jason commentedon Aug 7, 2020
the privilege of turning the global variable
tidb_log_desensitizationalso needs careful design. for example, only users withsuperprivilege can turn on or turn off this variable.nolouch commentedon Aug 7, 2020
cc @crazycs520
kolbe commentedon Aug 7, 2020
@nullnotnil I agree. I like the idea of disallowing DEBUG logs if the tidb_log_desensitization is set.
@zz-jason only a user with SUPER can change the value of a GLOBAL variable, so this is already the case, but good point and it's important to mention!
crazycs520 commentedon Aug 10, 2020
Already cherry-pick to release-4.0: #18581
crazycs520 commentedon Aug 10, 2020
This check is added in #19103
shenli commentedon Aug 19, 2020
Here is another place that may leak the arguments in log: https://github.com/pingcap/tidb/blob/master/executor/adapter.go#L759
ilovesoup commentedon Aug 20, 2020
With tidb_slow_log_masking slow logs no longer show the arguments to the current query, but it's still printing the arguments to the previous query.
Anyone following this? @zz-jason
crazycs520 commentedon Aug 24, 2020
#19392 should fix the
previous query doesn't desensitizationproblem.SunRunAway commentedon Oct 22, 2020
After #20436 merged, we are now working together to review all errors which may have sensitive information and redact them. See https://docs.google.com/document/d/1dOVzkaahH-P8fTYgtuBdKRTRlT8BEV7DM8LJPQwZaAQ/edit#heading=h.x2vdsn83mi0d