-
-
Notifications
You must be signed in to change notification settings - Fork 61
chore: adding a logger masking filter #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @staaldraad,
Since the pattern is static, it might also be beneficial to precompile it. |
For the
|
Unfortunately it doesn't work in the current form because the websockets logging is coming in as |
ffe8003
to
325e30a
Compare
Use a logging.Filter to redact JWT tokens that may be in log messages.
325e30a
to
053221b
Compare
I know I'm late to this, but I do not like the approach of this PR. Not only it forces every argument to every logger to be deep copied (which is not cheap), but it also applies a regex to any and all arguments, regardless of whether or not they may contain a JWT, which does raise some performance considerations. In realtime-py, most messages won't contain JWTs so it is simple to in-place patch places that may log these tokens, without the need for a catchall solution. Furthermore, I'd like to understand more the threat model behind this reasoning. Any python client that sees these logs should already have unrestricted access to the Either way, I'm not against this change per se, as logging access tokens does not seem like a great idea, but I'll close this specific PR in favor of better approaches that are a little more specific and have lesser performance considerations. |
Hi @o-santi. I initially reported this through HackerOne because this was the issue we were facing: In a Kubernetes cluster with centralized logging and monitoring, logs containing sensitive information like the As another example, I also linked in the HackerOne report a public GitHub issue, which disclosed a There also exists a Common Weakness Enumeration for this type of issue: CWE-532: Insertion of Sensitive Information into Log File I do not have a concrete solution in mind for how to fix it, but I strongly believe it should be addressed. |
What kind of change does this PR introduce?
Bug fix / feature
What is the current behavior?
INFO log lines may contain the access_token jwt
What is the new behavior?
Use a
logging.Filter
to redact JWT tokens that may be in log messages.JWT's will be displayed as
eyJh.REDACTED.2j7_78f
whereeyJh
would be the full header and2j7_78f
would be the full signature.Additional context
Doesn't address the fact that logging set toDEBUG
will have the JWT in the connection log line created bywebsockets
.Websocket DEBUG logs are also redacted after adding 053221b