mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-02 15:24:47 +00:00

Fixes a security vulnerability where ANSI escape sequences in user input could be injected into terminal output, potentially allowing attackers to manipulate terminal behavior through log messages and error displays. The vulnerability occurred when user-controlled content was formatted using Display (`{}`) instead of Debug (`{:?}`) formatting, allowing raw ANSI sequences to pass through unescaped. Changes: - Add streaming ANSI escape wrapper to avoid string allocations - Escape message content in default and pretty formatters - Escape error Display content in all error formatting paths - Add comprehensive integration tests for all formatter types The fix specifically targets untrusted user input while preserving the ability for applications to deliberately include formatting in trusted contexts like thread names. Security impact: Prevents terminal injection attacks such as title bar manipulation, screen clearing, and other malicious terminal control sequences that could be injected through log messages.