Skip to content

Table output doesn't neutralize terminal control characters in server data #206

Closed

Description

@thomaschristory

nsc/output/table.py (_format_cell, _format_colored) runs cell values through Rich's markup escape(). That stops [..] markup, but control characters such as ESC (\x1b) and BEL, and bidi overrides, still reach the terminal. A NetBox object whose name or description contains a terminal escape sequence can therefore drive the user's terminal when listed in table output: retitle it, clear the screen, or spoof text.

#205 fixed the same class of problem for the TTY error panel with _printable in nsc/output/errors.py, which shows control and format characters as visible \x.. escapes. The table formatter, and any other Rich-rendered path that prints server text (e.g. the --explain panel in nsc/output/explain.py and the TUI), should get the same treatment. Moving _printable to a shared helper would cover all of them.

JSON, JSONL, YAML and CSV output already escape or quote these characters, or don't target a terminal, so they're out of scope.

Found during the security review of #205.

Activity

  1. thomaschristory commented on Oct 24, 2026

    @thomaschristory
    OwnerAuthor

    Claiming: shared control-char sanitizer for Rich table/explain/error output and the TUI (also fixes TUI markup injection in DataTable/Label cells). Branch: fix/sanitize-terminal-output.

  2. thomaschristory commented on Oct 24, 2026

    @thomaschristory
    OwnerAuthor

    PR opened: #207

  3. thomaschristory commented on Oct 24, 2026

    @thomaschristory
    OwnerAuthor

    Fixed by #207 (merged). Shipping in v1.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions