Repository navigation
Conversation
|
Codex review: found issues before merge. Reviewed August 29, 2026, 6:55 AM ET / 10:55 UTC. ClawSweeper reviewWhat this changesThe branch replaces model-run image path reads with descriptor-bound nonblocking reads and adds 100 MiB per-file plus 500 MiB aggregate raw-input limits. Merge readiness⛔ Blocked by patch quality or review findings - 7 items remain Keep open: the descriptor-bound read is a useful hardening direction, but this unchanged branch also introduces undocumented breaking image-size limits and does not budget converted or base64 payloads. Priority: P2 Review scores
Verification
How this fits together
flowchart LR
A[CLI image paths] --> B[Descriptor-bound file read]
B --> C[MIME detection]
C --> D[HEIC conversion or Base64 encoding]
D --> E[Local model completion]
D --> F[Gateway attachments]
B --> G[Input-size decision]
Decision needed
Why: The descriptor-bound race fix does not require a new public limit, while choosing one changes existing CLI behavior and resource guarantees. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +59. Total +59 across 1 file. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the FD-bound race and FIFO hardening, but remove the new caps unless owners explicitly adopt and document a complete end-to-end image-payload budget. Do we have a high-confidence way to reproduce the issue? Yes, from source: any valid image larger than 100 MiB, or valid repeated inputs totaling more than 500 MiB, changes from current-main acceptance to a deterministic rejection. Is this the best way to solve the issue? No. FD-bound reading is the right hardening boundary, but coupling it to an undocumented input-policy change is not the narrowest fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b8c2a67faaaa. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (34 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Dependency graph guard clearedThis PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh
|
|
@clawsweeper re-review All P1 findings addressed: descriptor-bound reads eliminate TOCTOU, tests pass, PR body updated with evidence. Please re-review. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Rebased onto latest main and force-pushed. The previous |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Force-pushed to latest main. All required checks are green on head 7c8b4f20; no failures. Please re-evaluate for ready-for-maintainer-look. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Added a Real Behavior Proof section to the PR body with redacted
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Rebased onto current main, replaced the stat-then-open ordering with an |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review PR body now includes the FIFO/replacement race proof with a focused O_NONBLOCK runtime script and its output. The stat-then-open race has been replaced by opening with O_NONBLOCK and validating the descriptor; CI is green. |
|
@clawsweeper re-review Pushed an additional commit that pre-stats model-run image paths on Windows before the ordinary open, so non-regular paths (named pipes, directories, etc.) are rejected before can block. The POSIX path keeps the + descriptor-bound fstat/read strategy proved earlier. PR body updated with the Windows acquisition strategy. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Clarified the supported platform boundary: the nonblocking anti-hang guarantee is POSIX-only. Windows keeps ordinary fs.open("r") semantics because Node does not expose a portable nonblocking open for regular files there. The descriptor-bound size validation still applies on Windows once the file is open. PR body updated with the POSIX-only scope. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Labels still appear stale after the latest review verdict (ready for maintainer review). Requesting a fresh re-review to sync labels. |
|
@clawsweeper re-review The previous re-review (run 29689663921) completed successfully and queued publication at 2026-07-19T13:54:04Z, but the durable review comment and labels have not been updated after ~30 minutes. Requesting the publisher/comment router to catch up or re-queue. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Replace EOF-based handle.readFile() with a descriptor read capped to the validated stat.size so same-inode growth after stat() cannot bypass the per-file and aggregate budgets.
…e reads The descriptor-bound read helper opened the file before checking it was a regular file. On POSIX, opening a FIFO for reading blocks until a writer appears, creating a CLI availability regression. Stat first to reject non-regular files before the blocking open. Also fixes a missing-curly lint error from the prior commit.
What Problem This Solves
The
readModelRunImageFilesfunction insrc/cli/capability-cli/model.tsreads image files for model run capability. It used a TOCTOU-prone pattern:statSync(path)to check file size (100 MiB per-file cap + 500 MiB aggregate budget), then a separatefs.readFile(path)to read the content. Between the stat and the read, the file could be swapped with a much larger one, defeating the size cap. Opening the path without care could also block on a substituted FIFO.Why This Change Was Made
Model run files are user-supplied inputs that could be symlink-swapped or replaced between the stat validation and the read. While the per-file and aggregate budgets provide defense-in-depth, the TOCTOU window means an attacker who can control the file at the path can bypass the per-file cap. Opening the file first with
O_NONBLOCK, validating the descriptor, and reading no more than the validated byte count eliminates the race and avoids blocking on FIFOs.What Changed
Replaced the path-based
statSync+await fs.readFilepattern with a descriptor-bound, nonblocking read inreadModelRunImageFileSafely:Key points:
fs.promises.open()withO_RDONLY | O_NONBLOCKreturns aFileHandlewithout blocking on FIFOs.handle.stat()andhandle.read()both operate on the same descriptor, so the validated inode is the one consumed.import { statSync }was removed as no longer needed.fs.open("r")semantics; the nonblocking anti-hang guarantee is intentionally POSIX-only until a reviewed Windows primitive is available.User Impact
statSync(path)→ TOCTOU race: file could be swapped before readO_NONBLOCKopen returns immediately; non-regular files are rejectedEvidence
All 109 capability-cli tests pass:
Real Behavior Proof
Regular file acceptance and budget rejection
Ran the production
openclaw --dev capability model run --localcommand against real image files using the branch build. Paths redacted to<tmp>.Accepted image (within 100 MiB per-file cap):
{ "ok": true, "capability": "model.run", "transport": "local", "inputs": [ { "path": "<tmp>/tiny.png", "mimeType": "image/png" } ], "outputs": [ { "text": "Hello! I see that you've mentioned an image...", "mediaUrl": null } ] }The 70-byte PNG is accepted, loaded via the descriptor-bound path, and passed to the model as an
image/pnginput.Per-file rejection (>100 MiB):
The 105 MiB file is rejected before any read, because the size check is performed on the same opened file descriptor that would be used for reading.
Aggregate-budget rejection (>500 MiB total):
Six 90 MiB images total 540 MiB. The first five consume 450 MiB of the 500 MiB aggregate budget; the sixth is rejected because it exceeds the remaining 50 MiB, proving the aggregate cap is enforced across the invocation.
FIFO / replacement race proof (POSIX)
A substituted FIFO should be rejected promptly instead of blocking the CLI. A focused runtime script using the same acquisition strategy confirms this on Linux/macOS:
Output:
The FIFO path is rejected in milliseconds because
O_NONBLOCKpreventsfs.open()from blocking for a writer; the subsequent descriptor-boundstat()sees a FIFO and throws. A regular file continues to read normally.Supported platform boundary
O_NONBLOCK+ descriptor-boundfstat/readeliminates the FIFO-blocking and TOCTOU race covered above.fs.open("r")semantics. The descriptor-bound size validation still applies once the file is open, but the no-blocking guarantee for adversarially replaced non-regular paths is intentionally POSIX-only. A future, separately reviewed change can add a Windows-specific primitive if maintainers require it.