-
Notifications
You must be signed in to change notification settings - Fork 1
🛡️ Sentinel: Redact credentials from URLs in logs #160
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ## 2025-05-23 - URL Credential Leakage in Logs | ||
| **Vulnerability:** `sanitize_for_log` only redacted the API token but allowed URLs containing Basic Auth credentials (e.g. `https://user:pass@host`) to be logged in plain text. | ||
| **Learning:** Sanitization functions often focus on known secrets (like specific tokens) but miss pattern-based leaks like standard URI credentials. | ||
| **Prevention:** Always scrub user:password combinations from any URL before logging. Use regex or URL parsing libraries to identifying and redact the authority section. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,11 @@ | |
| s = str(text) | ||
| if TOKEN and TOKEN in s: | ||
| s = s.replace(TOKEN, "[REDACTED]") | ||
|
|
||
| # Redact credentials in URLs (e.g. https://user:pass@host) | ||
| # Pattern: scheme://user:pass@host -> scheme://[REDACTED]@host | ||
| s = re.sub(r"(https?://)[^/\s@]+@([^/\s]+)", r"\1[REDACTED]@\2", s) | ||
Check warningCode scanning / Pylintpython3 (reported by Codacy) Variable name "s" doesn't conform to snake_case naming style Warning
Variable name "s" doesn't conform to snake_case naming style
Check warningCode scanning / Pylint (reported by Codacy) Variable name "s" doesn't conform to snake_case naming style Warning
Variable name "s" doesn't conform to snake_case naming style
Comment on lines
+155
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the current regular expression effectively redacts credentials in many common URL formats, using
Comment on lines
+155
to
+157
|
||
|
|
||
| # repr() safely escapes control characters (e.g., \n -> \\n, \x1b -> \\x1b) | ||
| # This prevents log injection and terminal hijacking. | ||
| safe = repr(s) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the documentation: "identifying" should be "identify" to maintain parallel structure with "Use regex or URL parsing libraries to identify..."