Skip to content

Interactive capability approval corrupts terminal output when stdin is a TTY #1526

Description

@wswsmao

What happened?

When running nono interactively with --capability-elevation, the capability approval prompt can corrupt the terminal layout when stdin, stdout, and stderr are connected to a TTY.

The output lines become misaligned or shifted around the approval prompt. The process then waits for an approval decision, but the prompt is difficult to read or interact with.

Redirecting stdin from /dev/null avoids the PTY path and makes the prompt render normally.

What did you expect to happen?

The capability approval prompt should be rendered at a stable terminal position.

After entering y or n, the request should be granted or denied normally, and the terminal layout should remain usable.

Waiting for the user to answer Grant access? [y/N] is expected behavior. The issue is the corrupted terminal output and interaction experience.

Steps to reproduce

  1. Run the following command from an interactive terminal:

    "$NONO_BIN" run --allow-cwd --capability-elevation -- cat /etc/hostname
  2. Wait until a capability approval request is displayed.

  3. Observe that the output around the prompt may be shifted or interleaved.

  4. Compare it with the following command:

    "$NONO_BIN" run --allow-cwd --capability-elevation -- cat /etc/hostname </dev/null
  5. The second command does not use the same interactive PTY path, and the prompt is rendered normally.

Relevant output or logs

Capabilities:
────────────────────────────────────────────────────
  r   /mock/code/sandbox/nono/scratch/audit-demo/work (dir)
     + 43 system/group paths (-v to show)
 net  outbound allowed
────────────────────────────────────────────────────

 kernel  Landlock V3
        degraded: TCP filtering, IoctlDev, Scoping (upgrade kernel for full support)
 Applying sandbox...

[nono] The sandboxed process is requesting additional access:
[nono]   Path:   /proc/3389245/cmdline
[nono]   Access: read-only
[nono]   Reason: Sandbox intercepted file operation (seccomp-notify)
[nono]
[nono] Grant access? [y/N]


Without `</dev/null`, the output may be displayed with incorrect line positioning and the process appears to remain stuck until manually terminated.

With `</dev/null`, the approval prompt is displayed normally.

nono version

0.70.0

Operating system

Linux

OS version / distro

OpenCloudOS Stream 23

Kernel version (Linux only)

6.6.119-49.20.tl4.x86_64

Profile (if relevant)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNewly opened, not yet reviewed or assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions