fix: restrict shell execution in docs-only repository runs - #546
Open
Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Open
fix: restrict shell execution in docs-only repository runs#546Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 729bfc0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
Fixes #536.
Repository init/update runs now enforce their docs-only boundary across the shell
executetool as well as the structured filesystem tools.This PR:
Problem
OpenWikiLocalShellBackendalready constrainedwrite(),edit(), anduploadFiles()toopenwiki/whendocsOnly: truein repository mode.However,
execute()applied a shell allowlist only when.openwikiignorewas active. With the normal inactive ruleset, commands were delegated directly toLocalShellBackend.execute(). An agent could therefore bypass the structured path guard with a command such as:The same primitive could mutate source files or paths outside the repository. This matters because repository and connector content are untrusted model inputs.
Implementation
Independent docs-only shell policy
OpenWikiLocalShellBackend.execute()now evaluates two independent restrictions:.openwikiignoreallowlist, when ignore rules are active;docsOnlyis true andoutputModeisrepository.A command must satisfy every active restriction.
The docs-only allowlist intentionally contains only:
pwdgit rev-parse HEADgit --no-pager rev-parse HEADPatterns are fully anchored after trimming. Appending redirection or another command therefore fails closed:
pwd && echo bad > AGENTS.md— blockedgit rev-parse HEAD > AGENTS.md— blockedThis is deliberately an allowlist rather than a mutation denylist. Shell grammar, substitutions, aliases, redirection, and command composition make it unsafe to prove arbitrary input read-only.
The existing
.openwikiignoremaintenance allowlist remains separate because it has a different read-confidentiality purpose and historically permits deterministic plan cleanup. Repository docs-only execution does not permit shell cleanup; the host-side cleanup path already removes_plan.md.Prompt alignment
Repository init/update prompts now:
ls,glob,grep,read_file,write_file, andedit_file;rg, shell git history, or "narrow shell execute" for documentation writes;This avoids tool-error churn after the backend is hardened.
Behavior matrix
.openwikiignoreTests
Added backend regressions that verify:
AGENTS.mdis refused;pwdremains available;Added prompt regressions that verify:
Validation
corepack pnpm test— 67 files, 795 tests passedcorepack pnpm run typecheckcorepack pnpm run lint:checkcorepack pnpm run format:checkcorepack pnpm exec vitest run test/docs-only-backend.test.ts test/openwiki-ignore.test.ts test/prompt.test.ts— 39 tests passedcorepack pnpm exec changeset statusgit diff --check