Harden local API and filesystem security boundaries#203
Open
imxyanua wants to merge 1 commit into
Open
Conversation
* fix(api): reject cross-origin browser requests * fix(security): enforce canonical workspace boundaries * fix(ui): bound chat image attachments * test(files): use portable temporary paths --------- Co-authored-by: EvoX <evox@evomap.ai>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
Pi Web exposes local agent, filesystem, Git, model, plugin, skill, credential, and session operations through browser-accessible API routes. The existing implementation trusted lexical paths and did not reject cross-site browser requests, which allowed browser-origin attacks and symlink or junction escapes from approved workspaces. Large uploads and chat image attachments were also unbounded.
This PR adds a shared browser-origin gate, canonical filesystem authorization, consistent workspace checks across dependent routes, bounded upload and image handling, and regression coverage.
Root Cause
cwdor file paths without applying the same canonical workspace boundary./tmppaths and failed on Windows despite correct production behavior.Changes
Security
Origin.Resource Limits
Tests
Verification
npx tsc --noEmit: passing in repeated runs, including post-commit verification.npm run lint: passing in repeated runs, including post-commit verification.npm run build: passed three independent times with isolated build-timeHOMEandUSERPROFILE, plus a final branch build..nextbuild output; 454 entries, 5,333,998 compressed bytes, 29,142,590 unpacked bytes.origin/main, no generated artifacts or secret-like files included.Relevant tests were executed multiple times to verify deterministic behavior.
Breaking Changes
None.
Remaining Risks
0.0.0.0when no hostname is supplied. The API origin gate mitigates cross-site browser access but does not provide authentication for direct LAN clients. Default localhost binding or explicit authentication remains recommended follow-up work.npm audit --omit=devreports two high and two moderate production advisories in transitivesharp,postcss, andprotobufjsdependencies. No compatible clean upgrade was available during this audit.