Open
Conversation
… logging
- Updated all backend client files to log only SQL queries without parameter values
- Changed logging from `self.log.debug("%s: %s", query, values)` to `self.log.debug("%s", query)`
- Affects 7 backend clients: MySQL, SQLite, PostgreSQL (psycopg), ODBC, Oracle, MSSQL, AsyncPG
- Prevents exposure of sensitive data like passwords, tokens, etc. in debug logs
- Maintains debugging capability by still logging the SQL query structure
Co-authored-by: bddap <2702854+bddap@users.noreply.github.com>
Member
|
Do I understand correctly that this solution is basically just "not log any params for any queries ever"? |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR ports the changes from the approved but stale PR #1997 (by @bddap)
fixes #1996
FYI @henadzit
Description
This PR fixes a security vulnerability where sensitive data (passwords, tokens, API keys, personal information) was being exposed in debug logs through SQL query parameters. The fix removes parameter values from debug logging while preserving the SQL query structure for debugging purposes.
Changes made:
self.log.debug("%s: %s", query, values)toself.log.debug("%s", query)Before:
After:
Motivation and Context
Fixes #1996
SQL query parameters often contain sensitive information that should never be logged:
This creates a significant security risk, especially in:
The current implementation logs both the SQL structure AND the parameter values, which unnecessarily exposes this sensitive data.
How Has This Been Tested?
1. Added comprehensive test suite (
tests/test_logging_security.py):2. Manual verification:
3. Existing test compatibility:
Checklist: