security: use openFileWithinRoot for A2UI file serving#10525
Merged
steipete merged 3 commits intoopenclaw:mainfrom Feb 13, 2026
Merged
security: use openFileWithinRoot for A2UI file serving#10525steipete merged 3 commits intoopenclaw:mainfrom
steipete merged 3 commits intoopenclaw:mainfrom
Conversation
Contributor
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/canvas-host/a2ui.ts
Line: 179:223
Comment:
**HEAD requests return body**
`handleA2uiHttpRequest` explicitly allows `HEAD`, but it always reads the file and calls `res.end(...)` with a body (both for HTML and non-HTML). For `HEAD`, Node will typically drop the body bytes, but you still do the file I/O and may send an unexpected response. Consider short-circuiting on `req.method === "HEAD"` after setting headers (and still closing `result.handle`) so `HEAD` is actually header-only.
How can I resolve this? If you propose a fix, please make it concise. |
Contributor
Author
|
Addressed the HEAD request feedback — pushed a fix that returns headers only (Content-Type, Cache-Control) without reading the file body for HEAD requests. Ready for review. |
d94eddc to
ab7e254
Compare
Replace the custom path resolution in the A2UI handler with the existing openFileWithinRoot primitive from fs-safe.ts. The previous implementation had a TOCTOU (time-of-check-time-of-use) gap between lstat/realpath checks and the actual file read, and did not use O_NOFOLLOW or inode verification. The canvas-host server.ts already uses openFileWithinRoot correctly for its file serving. This change brings the A2UI handler in line with the same security guarantees: atomic root-boundary enforcement, symlink blocking via O_NOFOLLOW, and inode verification.
Return only headers (Content-Type, Cache-Control) without reading the file body for HEAD requests, avoiding unnecessary disk I/O.
ab7e254 to
64547d6
Compare
Contributor
GwonHyeok
pushed a commit
to learners-superpumped/openclaw
that referenced
this pull request
Feb 15, 2026
jiulingyun
added a commit
to jiulingyun/openclaw-cn
that referenced
this pull request
Feb 15, 2026
This was referenced Feb 19, 2026
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 1, 2026
Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 64547d6 Co-authored-by: abdelsfane <32418586+abdelsfane@users.noreply.github.com> Co-authored-by: steipete <58493+steipete@users.noreply.github.com> Reviewed-by: @steipete (cherry picked from commit 7467fcc) # Conflicts: # CHANGELOG.md
This was referenced Mar 1, 2026
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 3, 2026
Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 64547d6 Co-authored-by: abdelsfane <32418586+abdelsfane@users.noreply.github.com> Co-authored-by: steipete <58493+steipete@users.noreply.github.com> Reviewed-by: @steipete (cherry picked from commit 7467fcc) # Conflicts: # CHANGELOG.md # src/canvas-host/a2ui.ts
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.
Summary
openFileWithinRootprimitive fromfs-safe.tslstat+realpathchecks were performed separately from the subsequentfs.readFileserver.tsfor canvas host file servingTest plan
../../../etc/passwd) are rejected