Repository navigation
fix(agent): reject FIFO file previews without blocking - #46787
Merged
BeautyyuYanli merged 1 commit intoNov 26, 2026
Merged
Conversation
BeautyyuYanli
approved these changes
Nov 20, 2026
BeautyyuYanli
left a comment
Contributor
There was a problem hiding this comment.
(This message is automated while I'm responsible for it.)
LGTM. Opening the target path with os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK in _READ_BINDING_FILE_SCRIPT keeps the TOCTOU-safe fstat / stat.S_ISREG check intact while preventing writerless FIFOs from blocking open(2) until the browse timeout, ensuring immediate 400 invalid_binding_path rejection and prompt descriptor/lease cleanup.
Verified locally (pytest tests/local/dify_agent/server/test_binding_files.py, make check, make typecheck, and real FIFO verification against both the inspection script and FastAPI read route) with all remote CI checks green on e5a2e0b09f04.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #46786
Summary
Reject a FIFO preview without waiting for a writer. The Binding read script opens a path before checking
fstat, so blockingO_RDONLYcould stall on a named pipe and never reach its existing regular-file check.Add
O_NONBLOCKalongsideO_NOFOLLOW, allowing the existing rejection to produce400 invalid_binding_path. The regular-file check and descriptor cleanup remain in the same place. The production diff is one open flag plus a comment, with a real-FIFO regression and a short Binding file documentation update.Precondition: the inspection script runs in the existing POSIX Binding runtime. Postcondition: a writerless FIFO is rejected before reading, its descriptor is closed, and regular-file preview output retains its existing contract.
Verification
Linux / Python 3.13.17, with test dependencies aligned to the locked Agent environment:
subprocess.TimeoutExpired; its child is automatically killed and reaped.git diff --check: passed.An isolated check also sent real requests through
create_binding_files_routerandBindingFileService, using ASGI transport and a local subprocess command adapter:invalid_binding_pathbefore the guardAll five operations released their leases in both runs. No remote sandbox/provider deployment, full Agent package suite, or full Dify API suite was exercised for this change. The FIFO regression skips platforms without
os.mkfifo.From
dify-agenton Linux:Checklist
From Codex