Skip to content

[Bug] Unix CLI secret and capability fds read without pipe, size, or time bounds #216

Open

Description

@nillikechatchat

What happened?

On Unix, hiroute protected-input register --secret-fd and general --capability-fd (everything except work-plans.list / tasks.*) call read_protected_fd in crates/cli/src/client.rs. That helper:

  • opens /dev/fd/{n} with unbounded std::fs::read
  • checks the 512-byte limit only after the whole descriptor has been consumed
  • accepts a regular file, device, or blocking pipe as credential material

The sibling path crates/cli/src/work_plans.rs credential() already requires an inherited FIFO, uses O_NONBLOCK | O_NOCTTY, caps the read at 257 bytes, and applies a 2s deadline. Windows read_protected_handle also bounds bytes and waits 2s. The secret channel used by documented --secret-fd 3 examples does not.

Expected: the protected secret/capability reader rejects stdio, regular files, and non-pipes, and never blocks or loads more than 512 bytes.

Reproduction steps

Synthetic only; do not pass real credentials.

  1. On Linux or macOS, leave a pipe open without EOF, or point --secret-fd at a regular file / /dev/zero.
  2. Run:
    hiroute protected-input register --candidate candidate/example --secret-fd 3 --output json
  3. Observe either an unbounded hang until EOF, a large allocation before the 512-byte check, or acceptance of a regular file as secret material.
  4. Compare with hiroute work-plans list --capability-fd <fd> ..., which already rejects a regular file.

HiRoute version or commit

d9fe4c04 (higress-group/HiRoute main, after v0.3.1)

Operating system and architecture

Linux/macOS Unix CLI. Windows handle reader is already bounded.

Data check

  • I removed credentials, private conversation content, and other sensitive data.

Activity

  1. nillikechatchat commented on Oct 25, 2026

    @nillikechatchat
    ContributorAuthor

    Correction from the implementation pass: documented --secret-fd usage is an inherited regular file (3< KEY_FILE in the CLI guide) as well as a pipe. Product tests also feed --capability-fd from a regular file. The defect is the unbounded std::fs::read and missing time/type bounds, not acceptance of a regular file.

    The intended Unix contract is: reject stdio and non-file/non-pipe nodes (/dev/zero), cap at 512 bytes before loading the rest of the descriptor, and fail a pipe without EOF within 2s. work-plans/tasks capability material stays pipe-only.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions