fix(server): reject foreign directory hints before instance lookup - #34256
fix(server): reject foreign directory hints before instance lookup#34256romanilyin wants to merge 4 commits into
Conversation
|
Merge blocker found during review: the PR validates top-level directory query/header hints before InstanceStore.load, but the v2 ServerApi path still has an equivalent directory-hint bypass. packages/server/src/location.ts reads location[directory] and x-opencode-directory, decodes the header, and calls LocationServiceMap.get(...) without ServerDirectory.parse/native-path rejection. Those routes include location-scoped /api/* endpoints such as packages/protocol/src/groups/fs.ts, so a POSIX server can still accept /api/fs/find?location[directory]=C%3A%5CWork%5CRepo without the intended 400. Please apply the same server-native parsing/rejection to LocationMiddleware or a shared parser and add focused tests for location[directory] plus encoded x-opencode-directory on /api/* routes. Local evidence from a clean worktree: bun install --frozen-lockfile passed, focused server tests passed 49/49, and packages/opencode typecheck passed. Note: this account could not submit a formal request-changes review because GitHub reports it lacks explicit repository access. |
|
Addressed in 255e714. Changes:
Verification:
|
|
Follow-up safe-merge review on current head Validation in an isolated worktree merged into current
Current state: the PR is open/non-draft, checks pass, local merge into latest Residual review notes before a maintainer merges: the original v2 |
|
Thanks for the focused fix. I locally validated the PR's merge result against current I don't think this is merge-ready yet:
Other observed state: PR is open, non-draft, mergeable without content conflicts, but stale by 3 commits from current |
255e714 to
86b4435
Compare
|
Addressed the latest review note in Changes:
Verification:
Current GitHub state after push: the PR is mergeable and |
|
Blocking merge on one remaining cross-platform parser issue found by independent review and reproduced locally. I cannot submit this as a formal request-changes review because GitHub says this account lacks explicit repository access. On the current PR head Local reproduction on the PR merge tree: Required before merge:
Validation already run on the local merge result:
GitHub state is still |
86b4435 to
ee7abd5
Compare
|
Addressed the Windows-profile parser blocker in Changes:
Verification:
Current GitHub state after push: PR is mergeable, branch is current with |
|
Current safe-merge review on 2026-07-05 for head Not merging this head. Current GitHub/API state is still Local validation in an isolated worktree after merging the PR head into current
Validation caveat: adding Adversarial review did not find a new foreign-path bypass in the updated parser/location changes. Residual maintainer decisions before merge: the PR intentionally preserves relative directory hints, the HTTP Windows/WSL behavior is only unit-tested via injected parser profiles in this Linux review environment, and the change adds the new runtime dependency Required before merge: rebase/update the PR onto current |
ee7abd5 to
85b275a
Compare
|
Updated the branch onto current Validation after the rebase:
GitHub state after push: |
|
Hi @StarpTech, gentle follow-up on this PR. The underlying server-side issue still appears to be present on the current The branch is now behind I’m also happy to replace the The required fork workflows are still awaiting maintainer approval to run. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
This PR was closed by the automated cleanup, but the underlying issue is still active and has since been reproduced again in #36902, which explicitly references this PR. The current I am still actively maintaining this contribution and can rebase it onto the latest I’m also willing to replace Could a maintainer please confirm whether this direction is acceptable and reopen the PR for an updated revision? |
Issue for this PR
Closes #34255
Part of #33107
Related: #30895, #19473
Type of change
What does this PR do?
Validates request directory hints before
InstanceStore.load.Query values are consumed once, encoded SDK headers are decoded once, and Windows drive/UNC paths sent to a POSIX/WSL server return a structured 400 instead of being resolved under the server cwd.
The path logic stays behind one small wrapper. This PR does not migrate SQLite/App state, change session matching, resolve symlink identity, or translate Windows paths to WSL paths.
How did you verify your code works?
/mnt/c/...succeeds on WSL whileC:\...and UNC directory hints return 400.Screenshots / recordings
N/A — server/API change.
Checklist