Skip to content

fix(editor): prevent terminal control injection - #365

Merged
fcoury merged 1 commit into
mainfrom
fix/terminal-control-rendering
Sep 19, 2026
Merged

fcoury merged 1 commit into
mainfrom
fix/terminal-control-rendering

Conversation

@fcoury

@fcoury fcoury commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Files containing terminal control characters could place those bytes in RenderBuffer cells and pass them through crossterm::Print. ANSI-colored logs could therefore alter terminal state, corrupt source rows and overlays, and replay the corruption on resize.

This change treats control graphemes as zero-width during layout and source rendering, normalizes unsafe direct cell writes, and adds a final guard before cell text reaches the terminal. It adds focused coverage for the wireproxy SGR pattern and for CSI, OSC, DCS, BEL, DEL, and C1 controls.

How to Test

  1. Run cargo test -p red --lib wireproxy_ansi_log_controls_never_enter_rendered_cells; the minimized ANSI log line should render with literal [2m and [32m text and no control bytes in cells.
  2. Run cargo test -p red --lib terminal_diff_never_prints_control_payloads_from_a_cell; CSI, OSC, DCS, BEL, and C1 payloads should be replaced before terminal output.
  3. Run cargo run -- /tmp/wireproxy/proxy.log, open :whats-new, and resize the terminal narrower and back. Source rows and the release panel should remain aligned.

Validation

  • cargo test --all-targets --all-features
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • Manual PTY smoke test with /tmp/wireproxy/proxy.log, :whats-new, and a 136 to 110 to 136-column resize sequence

@fcoury

fcoury commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-19T17:31:55.199583Z b0dc4a5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: b0dc4a59af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fcoury
fcoury merged commit 9a0a17b into main Sep 19, 2026
22 of 24 checks passed
@fcoury
fcoury deleted the fix/terminal-control-rendering branch September 19, 2026 17:32
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.

1 participant