Conversation
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.
|
@carllerche can you elaborate on "while preserving the ability for applications to deliberately include formatting in trusted contexts"? I have hundreds (thousands?) of traces with For example: info!("This is red: {}", "color test".red());now escapes the color sequence despite Thanks! Edit: Looking at the PR, does this still accomplish what you're looking for if Created followup issue: Regression: New tracing-subscriber breaks ANSI color and styling support |
Update all dependencies to latest compatible versions.
This resolves the following crate vulnerability error:
```
error[vulnerability]: Logging user input may result in poisoning logs with ANSI escape sequences
┌─ /Volumes/scratch/repos/steam/Cargo.lock:251:1
│
251 │ tracing-subscriber 0.3.19 registry+https://github.com/rust-lang/crates.io-index
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ security vulnerability detected
│
├ ID: RUSTSEC-2025-0055
├ Advisory: https://rustsec.org/advisories/RUSTSEC-2025-0055
├ Previous versions of tracing-subscriber were vulnerable to ANSI escape sequence injection attacks. Untrusted user input containing ANSI escape sequences could be injected into terminal output when logged, potentially allowing attackers to:
- Manipulate terminal title bars
- Clear screens or modify terminal display
- Potentially mislead users through terminal manipulation
In isolation, impact is minimal, however security issues have been found in terminal emulators that enabled an attacker to use ANSI escape sequences via logs to exploit vulnerabilities in the terminal emulator.
This was patched in [PR #3368](tokio-rs/tracing#3368) to escape ANSI control characters from user input.
├ Announcement: GHSA-xwfj-jgwm-7wp5
├ Solution: Upgrade to >=0.3.20 (try `cargo update -p tracing-subscriber`)
├ tracing-subscriber v0.3.19
└── loom v0.5.6
└── state v0.6.0
├── rocket v0.5.1
│ └── steam-spotter v0.3.0
└── rocket_http v0.5.1
├── rocket v0.5.1 (*)
└── rocket_codegen v0.5.1
└── rocket v0.5.1 (*)
advisories FAILED, bans ok, licenses ok, sources ok
```
Fixing the following error when integrating the code on desktop: ``` TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/Cargo.lock:-1:-1 | Crate depends on a vulnerable version of tracing-subscriber. Advisory: Logging user input may result in poisoning logs with ANSI escape sequences Package: tracing-subscriber ID: RUSTSEC-2025-0055 Report date: 2025-08-29 Previous versions of tracing-subscriber were vulnerable to ANSI escape sequence injection attacks. Untrusted user input containing ANSI escape sequences could be injected into terminal output when logged, potentially allowing attackers to: - Manipulate terminal title bars - Clear screens or modify terminal display - Potentially mislead users through terminal manipulation In isolation, impact is minimal, however security issues have been found in terminal emulators that enabled an attacker to use ANSI escape sequences via logs to exploit vulnerabilities in the terminal emulator. This was patched in [PR mozilla#3368](tokio-rs/tracing#3368) to escape ANSI control characters from user input. URL: GHSA-xwfj-jgwm-7wp5 Patched versions: [ ">=0.3.20" ] ```
Update all dependencies to latest compatible versions.
This resolves the following crate vulnerability error:
```
error[vulnerability]: Logging user input may result in poisoning logs with ANSI escape sequences
┌─ /Volumes/scratch/repos/steam/Cargo.lock:251:1
│
251 │ tracing-subscriber 0.3.19 registry+https://github.com/rust-lang/crates.io-index
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ security vulnerability detected
│
├ ID: RUSTSEC-2025-0055
├ Advisory: https://rustsec.org/advisories/RUSTSEC-2025-0055
├ Previous versions of tracing-subscriber were vulnerable to ANSI escape sequence injection attacks. Untrusted user input containing ANSI escape sequences could be injected into terminal output when logged, potentially allowing attackers to:
- Manipulate terminal title bars
- Clear screens or modify terminal display
- Potentially mislead users through terminal manipulation
In isolation, impact is minimal, however security issues have been found in terminal emulators that enabled an attacker to use ANSI escape sequences via logs to exploit vulnerabilities in the terminal emulator.
This was patched in [PR #3368](tokio-rs/tracing#3368) to escape ANSI control characters from user input.
├ Announcement: GHSA-xwfj-jgwm-7wp5
├ Solution: Upgrade to >=0.3.20 (try `cargo update -p tracing-subscriber`)
├ tracing-subscriber v0.3.19
└── loom v0.5.6
└── state v0.6.0
├── rocket v0.5.1
│ └── steam-spotter v0.3.0
└── rocket_http v0.5.1
├── rocket v0.5.1 (*)
└── rocket_codegen v0.5.1
└── rocket v0.5.1 (*)
advisories FAILED, bans ok, licenses ok, sources ok
```
…vulnerability
Logs from cargo deny:
error[vulnerability]: Logging user input may result in poisoning logs with ANSI escape sequences
┌─ /home/runner/work/axelar-relayer-core/axelar-relayer-core/Cargo.lock:330:1
│
330 │ tracing-subscriber 0.3.19 registry+https://github.com/rust-lang/crates.io-index
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ security vulnerability detected
│
├ ID: RUSTSEC-2025-0055
├ Advisory: https://rustsec.org/advisories/RUSTSEC-2025-0055
├ Previous versions of tracing-subscriber were vulnerable to ANSI escape sequence injection attacks. Untrusted user input containing ANSI escape sequences could be injected into terminal output when logged, potentially allowing attackers to:
- Manipulate terminal title bars
- Clear screens or modify terminal display
- Potentially mislead users through terminal manipulation
In isolation, impact is minimal, however security issues have been found in terminal emulators that enabled an attacker to use ANSI escape sequences via logs to exploit vulnerabilities in the terminal emulator.
This was patched in [PR #3368](tokio-rs/tracing#3368) to escape ANSI control characters from user input.
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.
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.
Revert "fmt: fix ANSI escape sequence injection vulnerability (tokio-rs#3368)" This reverts commit 4c52ca5.
Revert "fmt: fix ANSI escape sequence injection vulnerability (tokio-rs#3368)" This reverts commit 4c52ca5.
|
how to re-enable it? or rather, how should I output escape sequences in my logs? edit: ok I see #3369 |
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:
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.