Skip to content

fix(verify): resolve the sandbox config dir from the sandbox root - #112

Merged
kridaydave merged 1 commit into
mainfrom
k5/debt-verify-harness
Oct 13, 2026
Merged

kridaydave merged 1 commit into
mainfrom
k5/debt-verify-harness

Conversation

@kridaydave

Copy link
Copy Markdown
Owner

Harness derives sandbox config dir from sandbox root on Linux to avoid writing into developer config. Guard refuses escape.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c8bfb93-761b-48be-89bf-b2fc4d098502
📥 Commits

Reviewing files that changed from the base of the PR and between 4a9bde6 and a3b023a.

📒 Files selected for processing (1)
  • .opencode/skills/verify-file-organizer/scripts/control-file-organizer.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kridaydave kridaydave left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of PR #112

Scope: one file changed, .opencode/skills/verify-file-organizer/scripts/control-file-organizer.mjs. No server code, schemas, or docs touched.

Blockers

None. The Linux derivation matches getConfigDirectory() in src/core/config/paths.ts: both resolve to <sandbox>/.config/file-organizer-mcp, and sandboxEnv() sets XDG_CONFIG_HOME=<root>/.config on the child, so write and read can no longer drift. The guard is separator-anchored (target !== parent && target.startsWith(parent + path.sep)), so a root prefix cannot false-match a sibling like /tmp/other. The guard also runs before the --fresh fs.rm, so nothing is deleted while the config path is still unknown. This genuinely fixes the reported "Access Denied" failure.

Suggestions

  1. Fix Windows too instead of always failing. sandboxEnv() already sets APPDATA=<root>\AppData\Roaming on Windows, so configRootFor() could derive from root there the same way it does on Linux and macOS. As written, the guard rejects every Windows invocation and makes the harness unusable on that platform.
  2. Correct the macOS note. It says macOS "still trusts the child to honor HOME," but configRootFor() already derives from root there and the guard passes. Only Node honoring HOME could break it, which should be stated plainly.
  3. Canonicalize root before the guard. isInside() is lexical; a symlinked --sandbox root could slip past it. Low risk for tmpdir throwaways, but path.resolve plus fs.realpath would close it.
  4. Add a test that locks this in. Nothing currently exercises the derivation or the guard refusal. A Node smoke that runs doctor with XDG_CONFIG_HOME pointed at a sentinel real config dir and asserts nothing lands there would have caught the original bug.
  5. Remove the stale leading /** Where this platform reads config.json from... */ comment block that now sits above the new JSDoc.

Contract / security

No API or tool-contract changes. Improves safety by turning a previously silent data-loss path (writing sandbox config into the developer config dir) into a hard error. The organizer and path validator are untouched.

@kridaydave
kridaydave force-pushed the k5/debt-verify-harness branch 2 times, most recently from bd53886 to 01603db Compare October 13, 2026 16:53
configRootFor() read XDG_CONFIG_HOME from the harness's own environment,
so the harness wrote the sandbox's config.json into the developer's real
config directory while the child server, spawned with its own
XDG_CONFIG_HOME, read a directory that never received it. The sandbox
data dir was never in the server's allow-list, so every tool call failed
with "Access Denied: Path is outside allowed directories" and doctor's
read-only check went red.

The Linux branch now derives the path from the sandbox root, using one
shared definition with sandboxEnv() so the write and the read cannot
drift apart. A guard proves the resolved config dir is inside the
sandbox root before the first write and refuses otherwise, the same
shape as the --fresh refusal, which turns the failure mode into a hard
error instead of a silent write into the developer's config dir.

Windows keeps reading the harness's APPDATA and macOS still trusts the
child to honor HOME. That is out of scope here and the comment on
configRootFor says so, but the guard now makes both fail loudly rather
than write somewhere wrong.

Commit made by Step 5 Preview Free in OpenCode on behalf of Kriday.
@kridaydave
kridaydave force-pushed the k5/debt-verify-harness branch from 01603db to a3b023a Compare October 13, 2026 17:02
@kridaydave
kridaydave merged commit 6baa5c7 into main Oct 13, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant