Repository navigation
Description
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is a bug report.
- I searched existing open/closed issues and PRs for duplicates.
- I am submitting this report in English.
- I have filled the required bug-report fields.
Dify version
Agent package 1.20.0; main at 6b8e067e6690860e76a3622de1021fc3202dc54f.
Cloud or Self Hosted
Self Hosted (Source). Reproduced on Linux / Python 3.13.17 using a temporary POSIX filesystem.
Steps to reproduce
The private POST /execution-bindings/files/read endpoint calls BindingFileService.read_file, which runs _READ_BINDING_FILE_SCRIPT inside the Binding. The script intends to reject non-regular files using fstat, but first opens the path with blocking O_RDONLY. Opening a FIFO with no writer never reaches that type check.
From dify-agent, run this standard-library-only reproduction on Linux. It executes the inspection script extracted from the actual source, creates its FIFO in a temporary directory, and kills the child after two seconds if it is blocked:
import ast
import os
from pathlib import Path
import subprocess
import sys
import tempfile
tree = ast.parse(Path("src/dify_agent/server/binding_files.py").read_text())
script = next(
ast.literal_eval(node.value)
for node in tree.body
if isinstance(node, ast.Assign)
and any(isinstance(t, ast.Name) and t.id == "_READ_BINDING_FILE_SCRIPT" for t in node.targets)
)
with tempfile.TemporaryDirectory() as directory:
fifo = Path(directory) / "pipe"
os.mkfifo(fifo)
try:
result = subprocess.run(
[sys.executable, "-c", script, str(fifo), "pipe", "1024"],
capture_output=True, text=True, timeout=2, check=False,
)
except subprocess.TimeoutExpired:
print("inspection blocked waiting for a FIFO writer")
else:
print(result.stdout)✔️ Expected Behavior
A preview accepts regular files only. A FIFO should reach the existing non-regular-file rejection immediately and map to 400 invalid_binding_path, without waiting for another process to open the pipe or for the browse timeout.
❌ Actual Behavior
On unchanged main the script remains blocked and the reproduction prints:
inspection blocked waiting for a FIFO writer
Adding O_NONBLOCK to the same open lets fstat run and the existing FileNotFoundError rejection complete. Regular-file reads are unaffected by this flag.
I also exercised the real private read route through FastAPI's ASGI transport and a local subprocess-backed command adapter. The adapter had a two-second guard to avoid waiting for the production 60-second browse timeout: unchanged source reached that guard and returned 502 binding_unavailable; fixed source returned 400 invalid_binding_path before the guard. Plain UTF-8 text, truncation inside a multibyte character, binary preview, and symlink responses were identical in both runs; all five operations released their leases. This was an isolated route/inspection check, not a deployed remote-provider test.
Activity