Skip to content

Potential fix for code scanning alert no. 36: Log Injection#166

Merged
Zochory merged 1 commit intomainfrom
alert-autofix-36
Oct 12, 2025
Merged

Potential fix for code scanning alert no. 36: Log Injection#166
Zochory merged 1 commit intomainfrom
alert-autofix-36

Conversation

@Zochory
Copy link
Member

@Zochory Zochory commented Oct 12, 2025

Potential fix for https://github.com/Qredence/AgenticFleet/security/code-scanning/36

To prevent log injection, all user input that is logged must be sanitized to remove line breaks and other characters that could adversely affect log parsing or display. The best practice is to replace \r and \n with empty strings before including user data in a log entry. This change should be performed just before logging on line 33—either by using a cleaned variable or directly inline. No additional dependencies are required for this simple sanitization. Only the line that constructs the log message with user input needs to be changed.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Zachary BENSALEM <zachary@qredence.ai>
@github-actions
Copy link
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions bot added area: cli Command-line interface python Python-related changes labels Oct 12, 2025
@Zochory Zochory marked this pull request as ready for review October 12, 2025 15:42
Copilot AI review requested due to automatic review settings October 12, 2025 15:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a security vulnerability (log injection) by sanitizing user input before logging. The fix prevents malicious line breaks in user input from corrupting log entries or affecting log parsing.

Key Changes

  • Sanitizes user input by removing carriage returns and newlines before logging
  • Implements the fix directly in the REPL module where user input is processed

continue

logger.info(f"Processing: '{user_input}'")
safe_user_input = user_input.replace('\r', '').replace('\n', '')
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more comprehensive sanitization approach. The current fix only removes \r and \n, but other control characters like \t (tab) could also be problematic for log parsing. Consider using user_input.replace('\r', '').replace('\n', '').replace('\t', ' ') or a regex approach to handle all control characters.

Copilot uses AI. Check for mistakes.
@Zochory Zochory merged commit 97baf46 into main Oct 12, 2025
10 of 15 checks passed
@Zochory Zochory deleted the alert-autofix-36 branch October 12, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command-line interface python Python-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants