Pensar - auto fix for Unsanitized User Input in Log Messages Enabling Log Injection#8
Open
pensarappdev[bot] wants to merge 1 commit into
Open
Pensar - auto fix for Unsanitized User Input in Log Messages Enabling Log Injection#8pensarappdev[bot] wants to merge 1 commit into
pensarappdev[bot] wants to merge 1 commit into
Conversation
…og Injection (CWE-117)
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.
Security Issue Fixed (CWE-117: Log Injection via Untrusted User Input):
userandusers) directly with f-strings. An attacker could supply input with newlines, control, or escape characters, resulting in log forging, misleading log output, or log parsing errors.Profile._safe_log_strto sanitize user-controlled input before logging. This method:\n,\r, and\tto their literal string forms.logger.info(f"Loading {user}'s tweets from disk")→logger.info(f"Loading {self._safe_log_str(user)}'s tweets from disk")logger.info(f"Not on disk! scraping {users}'s tweets now")→ includes both sanitizeduserand a sanitized comma-separated user list.No dependency issues were present, and only the logging vulnerability identified in the metadata was addressed. The rest of the code was unchanged and all formatting/indentation was preserved.
More Details
userandusers) directly into log messages without any neutralisation or encoding. If an attacker supplies a string containing newline characters, ANSI escape codes, or log-format delimiters (e.g., "evilUser\n[ERROR] System failure"), they can forge or tamper with subsequent log entries. This constitutes Improper Output Neutralisation for Logs (CWE-117) and can:• Inject spoofed log lines that mislead operators
• Hide malicious activity by overwriting or obfuscating real events
• Break downstream log parsers or SIEM pipelines