fix(resolve-file-uri): remove project boundary check for prompt file:// URIs#3752
Open
nerored wants to merge 1 commit intocode-yeongyu:devfrom
Open
fix(resolve-file-uri): remove project boundary check for prompt file:// URIs#3752nerored wants to merge 1 commit intocode-yeongyu:devfrom
nerored wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Removing a security boundary check (isWithinProject) previously added to prevent arbitrary file access is a security regression, even if it aligns with documentation.
…// URIs Remove the `isWithinProject` boundary restriction from `resolvePromptAppend()` so that `file://` prompt URIs behave as documented — supporting absolute, home-relative (`~/`), and project-relative paths — instead of being silently rejected with a warning placeholder. Since commit 9865978 ("fix(security): confine file resolution to project roots"), `resolvePromptAppend()` called `isWithinProject(filePath, configDir ?? process.cwd())` and rejected any path outside the current working directory or config directory. This contradicts the configuration reference which explicitly lists absolute, relative, and home-relative forms as supported. Users following the documented examples receive a silent `[WARNING: Path rejected: ...]` placeholder instead of their intended prompt content. The boundary check was originally added for security, but `prompt` and `prompt_append` are user-configured fields — the user is deliberately pointing to a file they want loaded into the agent prompt. The check prevents legitimate cross-project prompt sharing, a use case the documentation describes as a primary motivation for `file://` support. Fixes the root cause behind code-yeongyu#3554. Changes: - resolve-file-uri.ts: remove `isWithinProject` import, `log` import, and the boundary check block (projectRoot declaration + if-statement + log + return). - resolve-file-uri.test.ts: remove 3 rejection tests that enforced the boundary; add a test verifying absolute paths load regardless of configDir; update the home-directory test to expect success; remove the now-unused symlink fixture. Test: resolve-file-uri 8 pass / 0 fail, sisyphus-junior 47 pass / 0 fail. Typecheck: clean.
8a50740 to
0152818
Compare
nerored
pushed a commit
to nerored/oh-my-openagent
that referenced
this pull request
May 1, 2026
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
Remove the
isWithinProjectboundary restriction fromresolvePromptAppend()so thatfile://prompt URIs behave as documented — supporting absolute, home-relative (~/), and project-relative paths — instead of being silently rejected with a[WARNING: Path rejected: ...]placeholder.Root Cause
Since commit
9865978("fix(security): confine file resolution to project roots"),resolvePromptAppend()has calledisWithinProject(filePath, configDir ?? process.cwd())and rejected any path that resolves outside the current working directory or config directory.This contradicts the configuration reference which explicitly documents support for all three forms:
The same documentation also describes cross-project prompt sharing as a primary motivation for
file://support. The boundary check makes this impossible when the prompt file lives in a shared global directory (e.g.~/.config/opencode/prompts/).The check was added for security, but
promptandprompt_appendare user-configured fields — the user is deliberately pointing to a file they want loaded into the agent prompt. Other parts of the codebase (skill loader, config discovery) already have their ownisWithinProjectguards where project isolation is genuinely needed.Changes
src/agents/builtin-agents/resolve-file-uri.tsisWithinProjectimport,logimport, and the boundary check block.src/agents/builtin-agents/resolve-file-uri.test.tsVerification
Related
file://support for absolute /~// relative pathsNeed help on this PR? Tag
@codesmithwith what you need.Summary by cubic
Remove the project boundary check from
resolvePromptAppend()sofile://prompt URIs can load absolute, home (~/), and project‑relative files as documented. This removes false “[WARNING: Path rejected]” and enables cross‑project prompt sharing.resolvePromptAppend()so absolute paths load regardless ofconfigDir.Written for commit 0152818. Summary will update on new commits.