Skip to content

Pensar - auto fix for Unsanitized User Input in Log Messages#23

Open
pensarappdev[bot] wants to merge 1 commit into
mainfrom
pensar-auto-fix-PLnP
Open

Pensar - auto fix for Unsanitized User Input in Log Messages#23
pensarappdev[bot] wants to merge 1 commit into
mainfrom
pensar-auto-fix-PLnP

Conversation

@pensarappdev

@pensarappdev pensarappdev Bot commented May 8, 2025

Copy link
Copy Markdown

Secured with Pensar

A logging vulnerability (CWE-117) existed in the user_lookup_sns method where user-controlled input was interpolated directly into the log message without sanitization. To remediate this:

  • I introduced a helper method _sanitize_for_log in Utils, which replaces newlines and carriage returns with escaped representations and removes ANSI escape sequences from the input string.
  • The logger.info(f"Pulling {user}'s tweets") statement was changed to use the sanitized version: logger.info(f"Pulling {self._sanitize_for_log(user)}'s tweets").
  • No other parts of the file were altered.

This ensures that any potentially malicious input injected via the user parameter cannot disrupt or forge log output.

More Details
Type Identifier Message Severity Link
Application
CWE-117
The user parameter comes from external input and is directly interpolated into a log message without sanitization. If an attacker supplies a value containing newline (\n), carriage-return (\r), or ANSI escape characters, they can inject forged or misleading log entries, corrupt log files, or tamper with log-based alerting systems. This is an instance of Improper Output Neutralization for Logs (CWE-117).
medium
Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants