Repository navigation
fix: bound git calls, contain the v2 patch tool, complete Shell.Info - #91
Merged
Merged
Conversation
Three defects from the 2026-11-26 security and SRE reviews, each proven
red before the fix.
SRE: `run_git` used `Command::output()` with no deadline on the same
16-thread blocking pool as every store read, so ~16 `git` invocations
against a huge, network-mounted or hostile repository removed the pool
and stalled every store-backed route. `platform::run_with_deadline`
polls with a 30 s cap, kills on expiry, drains both pipes on threads and
returns `TimedOut`; `git apply` uses the stdin variant with the same
deadline. Failures count in `ocserve_vcs_git_errors_total{op}` instead
of being silently indistinguishable from an empty result.
Security: the v2 `patch` tool wrote with `cwd.join(path)` and no
verification, so `../x`, an absolute path and `*** Move to: ../x`
escaped the project and `.git/hooks/pre-commit` was writable. Containment
moved into `ocserve-store` so the tools crate shares the one
handle-verified primitive with the file routes; `.git` is refused by
name (D-PATCH-NO-GIT-DIR). Rule 75 keeps a new unmarked write a build
failure.
Shell.Info (#75 follow-up): the rename to `exit` still omitted `shell`,
`file`, `metadata` and `time`, and `list()` added `sessionID`, which the
closed schema forbids, so a strict client still rejected every response.
All required keys are emitted; `sessionID` moved to `session_owners()`
for the goal loop. `D-SHELL-NO-FILE` records that output stays in memory.
K-GIT-DEADLINE, K-PATCH-CONTAIN, K-SHELL-INFO-SHAPE.
The snapshot engine's `run_git` used `wait_with_output()` with no cap. It runs on the prompt path (step-start/step-finish snapshots), i.e. on the same 16-thread blocking pool as every store read, so an unbounded `git` against a huge or network-mounted repository would stall turns rather than one route. stdout/stderr now drain on their own threads so a full pipe cannot deadlock the wait loop (issue #80's lesson), and a timeout kills the child, counts in `ocserve_snapshot_git_timeouts_total`, and returns -1 like any other git failure. K-GIT-DEADLINE extended.
The move into `ocserve-store` failed both platform jobs: that crate roots at `#![cfg_attr(not(test), forbid(unsafe_code))]`, so the module's Windows (`GetFinalPathNameByHandleW`) and macOS (`F_GETPATH`) FFI, which carry item-level `#[allow(unsafe_code)]`, is E0453 "overruled by previous forbid". Weakening store's `forbid` would trade a hard invariant for a file move. Instead containment is its own leaf crate with `#![deny(unsafe_code)]` (the policy `ocserve-http` had, which permits documented item-level opt-ins) and no workspace-internal dependencies. `ocserve-http` re-exports it under the old path so every `crate::containment::` call site is unchanged, and `ocserve-tools` depends on it directly for the `patch` tool. The http crate's rustix/libc/windows-sys target deps were containment-only and are removed; store's copies go with the module.
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.
Three defects from the 2026-11-26 security and SRE reviews. Each was proven red before the fix.
SRE — unbounded
giton the shared blocking poolrun_gitusedCommand::output()with no deadline. Those calls run on the same 16-thread blocking pool as every store read, so enough hostilegitinvocations remove the pool and stall every store-backed route. Nowplatform::run_with_deadline(30 s, kills on expiry, drains both pipes on threads);git applyuses the stdin variant with the same deadline; failures count inocserve_vcs_git_errors_total{op}instead of looking like an empty result.Security — the v2
patchtool wrote anywhereapplyusedcwd.join(path)thenfs::writewith no verification:../x,sub/dir/../../x, absolute paths,*** Move to: ../x, and.git/hooks/pre-commitall wrote outside the project. Containment moved intoocserve-storeso the tools crate shares the one handle-verified primitive with the file routes;.gitis refused by name (D-PATCH-NO-GIT-DIR). Rule 75 keeps a new unmarked write a build failure (planted control proven).Shell.Info— #75 renamed one key and still failed validationThe rename to
exitomittedshell,file,metadata,time, andlist()addedsessionID, which the closed schema forbids. All required keys are emitted;sessionIDmoved tosession_owners()for the goal loop.D-SHELL-NO-FILErecords that output stays in memory.Verification
patch_refuses_to_escape_the_project_directory— 5 escape shapes refused, in-tree add succeeds; red when the unverified join is restored.allow:raw-writemarker is removed.run_with_deadlineunit tests (success, timeout kills and names the label, output drained).-D warningsclean, guards 0 fail, matrix OK, docs clean.K-GIT-DEADLINE, K-PATCH-CONTAIN, K-SHELL-INFO-SHAPE.