deerflow2/src
Willem Jiang 5b9e0a879c security: add log injection attack prevention with input sanitization (#667)
* security: add log injection attack prevention with input sanitization

- Created src/utils/log_sanitizer.py to sanitize user-controlled input before logging
- Prevents log injection attacks using newlines, tabs, carriage returns, etc.
- Escapes dangerous characters: \n, \r, \t, \0, \x1b
- Provides specialized functions for different input types:
  - sanitize_log_input: general purpose sanitization
  - sanitize_thread_id: for user-provided thread IDs
  - sanitize_user_content: for user messages (more aggressive truncation)
  - sanitize_agent_name: for agent identifiers
  - sanitize_tool_name: for tool names
  - sanitize_feedback: for user interrupt feedback
  - create_safe_log_message: template-based safe message creation

- Updated src/server/app.py to sanitize all user input in logging:
  - Thread IDs from request parameter
  - Message content from user
  - Agent names and node information
  - Tool names and feedback

- Updated src/agents/tool_interceptor.py to sanitize:
  - Tool names during execution
  - User feedback during interrupt handling
  - Tool input data

- Added 29 comprehensive unit tests covering:
  - Classic newline injection attacks
  - Carriage return injection
  - Tab and null character injection
  - HTML/ANSI escape sequence injection
  - Combined multi-character attacks
  - Truncation and length limits

Fixes potential log forgery vulnerability where malicious users could inject
fake log entries via unsanitized input containing control characters.
2025-10-27 20:57:23 +08:00
..
agents security: add log injection attack prevention with input sanitization (#667) 2025-10-27 20:57:23 +08:00
config feat: implement tool-specific interrupts for create_react_agent (#572) (#659) 2025-10-26 09:47:03 +08:00
crawler security: add log injection attack prevention with input sanitization (#667) 2025-10-27 20:57:23 +08:00
graph feat: add comprehensive debug logging for issue #477 hanging/freezing diagnosis (#662) 2025-10-27 08:21:30 +08:00
llms feat: add context compress (#590) 2025-09-27 21:42:22 +08:00
podcast refactor: refactor the prompt management mechanism (#17) 2025-05-09 15:50:46 +08:00
ppt/graph fix: some lint fix using tools (#98) 2025-07-12 13:59:02 +08:00
prompt_enhancer feat: Add comprehensive Chinese localization support for issue #412 (#649) 2025-10-24 16:31:19 +08:00
prompts fix: repair missing step_type fields in Plan validation (#653) 2025-10-24 21:26:48 +08:00
prose/graph feat: 1. replace black with ruff for fomatting and sort import (#489) 2025-08-17 22:57:23 +08:00
rag feat: add strategic_investment report style (#595) 2025-09-24 09:50:36 +08:00
server security: add log injection attack prevention with input sanitization (#667) 2025-10-27 20:57:23 +08:00
tools Fix: clarification bugs - max rounds, locale passing, and over-clarification (#647) 2025-10-24 16:43:39 +08:00
utils security: add log injection attack prevention with input sanitization (#667) 2025-10-27 20:57:23 +08:00
__init__.py docs: refine readme 2025-04-17 11:54:24 +08:00
workflow.py fix: Refine clarification workflow state handling (#641) 2025-10-22 22:49:07 +08:00