Repository navigation
fix(cli): bound Unix secret and capability fd reads - #219
nillikechatchat wants to merge 5 commits into
Conversation
Unix --secret-fd and non-task --capability-fd already reject decoded material over 512 bytes, but std::fs::read waited for EOF and loaded the whole file first. A FIFO that never closed, /dev/zero, or a huge regular file could hang or exhaust memory. Keep the documented 3< KEY_FILE regular-file redirect and inherited pipes, reject stdio and non-file/fifo types, and stop at 512 bytes or 2s. Fixes higress-group#216 Signed-off-by: nillikechatchat <yuanhenglizhen2050@163.com> Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
|
@johnlanni ready for review. Fixes #216. Candidate SHA |
Review: valid input-bounding defect; macOS timeout needs correctionReviewed commit: Importance of the original issue: medium (P2). The original reader consumes the entire input before enforcing the 512-byte limit. A large file or endless device can consume excessive memory, and a pipe whose writer stays open can hang the CLI and its calling automation. This is worth fixing in the normal maintenance cycle. The report and current evidence do not establish a production incident or remotely triggered daemon outage. Preserving documented regular-file redirection ( Change needed before merge: the new timeout still does not work for inherited blocking pipes on macOS. In An isolated syscall probe matching this PR's open flags and deadline loop confirmed this on macOS 26.3.2 arm64: both an empty pipe with its writer retained and a pipe containing synthetic credential bytes without EOF remained blocked beyond an external 3-second watchdog. The same cases rejected after about 2 seconds on Linux. This is OS-level reproduction, not an execution of the candidate CLI on macOS; the existing green CI does not cover this behavior. Please:
The size/type checks are useful improvements. Recommendation: keep the fix, address the macOS deadline gap, then re-review. The same deadline issue also applies to #220, so a shared bounded reader would help keep the behavior consistent. |
macOS /dev/fd/N follows dup semantics, so opening with O_NONBLOCK does not make an inherited blocking pipe nonblocking. poll waits for readiness without changing file-status flags. Keep the 512-byte / 2s bound, regular-file and pipe acceptance, and stdio/device rejection. Watchdog subprocesses cover empty and partial pipes whose writer stays open. Signed-off-by: nillikechatchat <yuanhenglizhen2050@163.com> Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com> Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
|
@johnlanni follow-up for the macOS deadline gap is on Inherited Unix secret/capability reads now use Linux focused tests: Hosted on this SHA:
This checkout has no macOS validation target, so the watchdog tests have not been executed on macOS here. The same tests are in the candidate. Shared reader: |
Follow-up review (2026-10-29): macOS fix verified; Linux FIFO opening still needs a boundReviewed commit: The previous macOS pipe-read finding is addressed for the tested scenarios. I ran Remaining P2 finding: I reproduced this with the actual public CLI built from this head, using a private runtime and empty synthetic input:
Please make the descriptor-acquisition step nonblocking/bounded as well, while preserving the caller's descriptor ownership and file-status flags on both operating systems. Add subprocess-watchdog regressions for named FIFOs with no writer and with a writer that has already closed; retain the passing macOS cases. #220 contains the identical helper and should receive the same correction. Importance and merge recommendation: this remains a medium-priority CLI/automation reliability issue, suitable for normal maintenance. The macOS repair and size/type bounds are improvements, but this supported FIFO input still violates the promised deadline, so I recommend correcting it before merge. Current CI is green; GitHub also reports this branch behind main, so refresh the base and satisfy the required checks and code-owner approval on the final candidate. |
…d-boundsCo-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
Linux File::open("/dev/fd/N") can stall on a named FIFO before poll
sees the 2s deadline. Reopen with O_NONBLOCK so acquisition stays
bounded; inherited file-status flags are unchanged.
Watchdog coverage includes an empty named FIFO and a closed writer
that must finish inside the deadline.
Signed-off-by: nillikechatchat <yuanhenglizhen2050@163.com>
Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
|
@johnlanni Linux named-FIFO follow-up is on
Watchdog coverage:
Linux focused tests at This checkout has no macOS validation target, so the watchdog tests have not been executed on macOS here. Hosted CI after this push is the remaining remote evidence. Human review remains the default. Shared reader: |
Problem
Unix
--secret-fdand non-task--capability-fdalready rejected decoded material over 512 bytes, butstd::fs::readwaited for EOF and loaded the whole file first. A FIFO that never closed,/dev/zero, or a huge regular file could hang or exhaust memory.Change
pollon/dev/fd/N./dev/fd/Nfollows dup semantics, so opening withO_NONBLOCKdoes not make a blocking pipe nonblocking.3< KEY_FILE) and inherited pipes.work-plans/taskscapability material stays pipe-only.Fixes #216
Validation
cargo test --locked -p hiroute-cli --lib -- unix_bounded_fd protected_fd