You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
server: a NUL byte or a relative location directory returns an empty HTTP 500 #59164
The server passes the location directory to the filesystem and the database without checking it. A NUL byte or a relative path makes those layers throw, and the client gets HTTP 500 with an empty body.
Expected
HTTP 400 with an InvalidRequestError body that names the location directory.
Actual
Both requests return HTTP 500 with an empty body. The server log shows:
PlatformError: FileSystem.realPath: The argument 'path' must be ... without null bytes from Project.resolve (packages/core/src/project.ts)
Error: Path is not absolute: relative/dir from packages/core/src/database/path.ts
An HTTP fuzzer got the same empty 500 for the NUL query on 397 routes.
Thanks for the clear report. I reproduced this on 2.1.4:
GET /api/agent?location[directory]=%00 returns HTTP 500 with an empty body. The server log shows the FileSystem.realPath ... without null bytes error.
POST /api/session with {"location":{"directory":"relative/dir"}} returns HTTP 500 with an empty body, and the log shows Path is not absolute: relative/dir.
It still happens on the latest dev (c54677b). The directory from the query, the x-opencode-directory header or the request body reaches the filesystem and database layers without being checked. The script below reproduces it against opencode on PATH, or against another command passed as arguments.
Related: #59162 (your open PR, which aims to fix this) and #53991 (a NUL-byte project ID breaking fromDirectory).
Reproduction script (repro.sh)
#!/usr/bin/env bash# Usage: repro.sh [opencode command...] (defaults to `opencode` on PATH)set -u
PORT=${PORT:-18432}
CMD=("${@:-opencode}")
DIR=$(mktemp -d);cd"$DIR"; git init -q
OPENCODE_PASSWORD=pw "${CMD[@]}" serve --port "$PORT">"$DIR/server.log"2>&1&
PID=$!foriin$(seq 1 60);do curl -s -o /dev/null -u opencode:pw "http://127.0.0.1:$PORT/api/agent"&&break; sleep 1;doneecho"== GET /api/agent?location[directory]=%00"
curl -s -i -u opencode:pw "http://127.0.0.1:$PORT/api/agent?location%5Bdirectory%5D=%00";echoecho"== POST /api/session with relative location directory"
curl -s -i -u opencode:pw -H content-type:application/json -X POST "http://127.0.0.1:$PORT/api/session" \
-d '{"location":{"directory":"relative/dir"}}';echokill$PID;wait$PID2>/dev/null
echo"== server log (errors)"; grep -iE "null bytes|not absolute""$DIR/server.log"| head -5
Activity
opencode-agent commentedon Oct 26, 2026
Thanks for the clear report. I reproduced this on 2.1.4:
GET /api/agent?location[directory]=%00returns HTTP 500 with an empty body. The server log shows theFileSystem.realPath ... without null byteserror.POST /api/sessionwith{"location":{"directory":"relative/dir"}}returns HTTP 500 with an empty body, and the log showsPath is not absolute: relative/dir.It still happens on the latest
dev(c54677b). The directory from the query, thex-opencode-directoryheader or the request body reaches the filesystem and database layers without being checked. The script below reproduces it againstopencodeon PATH, or against another command passed as arguments.Related: #59162 (your open PR, which aims to fix this) and #53991 (a NUL-byte project ID breaking
fromDirectory).Reproduction script (repro.sh)
Run it:
bash repro.sh