Skip to content

Bound terminal output by bytes as well as line count #477

Done

Description

@samuelmbabhazi

Problem and impact

The terminal limits its screen to 2,000 lines but does not bound bytes per line or total retained bytes. Repeated output without a newline is appended to the same line indefinitely. Container output can therefore consume increasing browser memory and rendering work, eventually freezing or exhausting the operator's tab.

Priority: P2, from the 2026-11-25 security audit. Affected change: #468, initially audited at 4115dce4ca381a6bd3aa375282461bca58aa0173; the terminal-view.ts implementation is unchanged at pre-publication head 54bca96e6224254fb57c599b8e63ddf7c168dd0b. Related feature: #232.

This affects an authorized user viewing a container's terminal output. No XSS, server-side memory exhaustion or permission bypass was demonstrated.

Evidence

appendOutput concatenates into the last line and then limits only the number of lines with slice(-MAX_TERMINAL_LINES).

A bounded local probe used the real function with 32 KiB output fragments and no newline:

Fragments Retained lines Retained text bytes
32 1 1,048,576
256 1 8,388,608
1,024 1 33,554,432

The probe stopped at 32 MiB; it did not intentionally exhaust a browser. ANSI/control-character stripping does not bound an ordinary printable line.

Proposed correction

Bound both per-line and total retained text, show a truncation indicator and bound rendering work per update. Preserve normal streaming behavior and handle multibyte text safely. Decide whether to retain the newest tail or another documented portion of a long line.

Acceptance criteria

  • Continuous output without line breaks cannot grow the retained screen beyond the documented byte budget.
  • Many short lines are also bounded by both count and total bytes.
  • A regression test streams bounded chunks across several updates and verifies stable retention after reaching the limit.
  • Normal output, ANSI/control stripping, multibyte characters and truncation indication remain correct.
  • A disposable browser check confirms the UI stays responsive under sustained output.

Activity

  1. added
    bug
    priority:P2
    on Nov 25, 2026
  2. added a commit that references this issue on Nov 25, 2026
    986a52d
  3. samuelmbabhazi commented on Nov 25, 2026

    @samuelmbabhazi
    CollaboratorAuthor

    Fixed in #468 (986a52d), before that PR merges: appendOutput keeps a line's first 4096 characters, marks it truncated (shown as …), never cuts a character in two, and drops the rest up to its newline. The screen keeps at most 2000 lines and 1 Mi characters, newest first. Tests reproduce the audit's probe, 32 KiB chunks without a newline: 64 of them (2 MiB) leave one 4096-character line. They also cover 1000 long lines, which stay within the character budget, and an emoji at the cut.

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

    bugpriority:P2securitytrack:web

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions