Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed src/openhuman/agent/git_attribution/hook.rs,src/openhuman/tools/impl/filesystem

Steven Enamakel64c63be43975
diff --git a/src/openhuman/agent/git_attribution/hook.rs b/src/openhuman/agent/git_attribution/hook.rs
index 1b129964f0..0b53e49d30 100644
--- a/src/openhuman/agent/git_attribution/hook.rs
+++ b/src/openhuman/agent/git_attribution/hook.rs
@@ -89,6 +89,7 @@ fn build_hook_env(
}
}
parameters.push(b'\'');
+ push_neutralised_config(&mut parameters);
HashMap::from([
(OsString::from("OPENHUMAN_GIT_ATTRIBUTION"), TRAILER.into()),
@@ -107,6 +108,38 @@ pub fn hook_env() -> HashMap<std::ffi::OsString, std::ffi::OsString> {
HashMap::new()
}
+/// Append the shell-safe git config overrides to a `GIT_CONFIG_PARAMETERS`
+/// buffer.
+///
+/// `GIT_CONFIG_PARAMETERS` is how git itself propagates `-c` to child
+/// processes, so these land at `-c` precedence: above the repository's own
+/// config, which in an agent-writable workspace is the thing an attacker gets
+/// to author. Several git config keys name a command git then runs —
+/// `core.fsmonitor` on `git status`, `core.pager` and `core.editor` on the
+/// commands that use them — and until `git_operations` moved behind a tool
+/// pack, `shell git` was the one path that got none of that hardening.
+///
+/// The list, and the reasoning about what is deliberately left out of it,
+/// lives with the rest of the policy in `tools::impl::filesystem`.
+///
+/// Later entries win, so this is appended after the hooks path rather than
+/// before: nothing here sets `core.hooksPath`, but the ordering is the
+/// contract and worth keeping explicit.
+#[cfg(unix)]
+fn push_neutralised_config(parameters: &mut Vec<u8>) {
+ for entry in crate::openhuman::tools::implementations::filesystem::SHELL_NEUTRALISED_CONFIG {
+ let Some((key, value)) = entry.split_once('=') else {
+ continue;
+ };
+ parameters.push(b' ');
+ parameters.push(b'\'');
+ parameters.extend_from_slice(key.as_bytes());
+ parameters.extend_from_slice(b"'='");
+ parameters.extend_from_slice(value.as_bytes());
+ parameters.push(b'\'');
+ }
+}
+
#[cfg(unix)]
fn build_hook_dir() -> std::io::Result<PathBuf> {
use std::io::Write;
diff --git a/src/openhuman/tools/impl/filesystem/mod.rs b/src/openhuman/tools/impl/filesystem/mod.rs
index 5015d91960..bb1c51a1ad 100644
--- a/src/openhuman/tools/impl/filesystem/mod.rs
+++ b/src/openhuman/tools/impl/filesystem/mod.rs
@@ -23,6 +23,13 @@ use tinytools::ToolRunContext;
#[path = "mod_tests.rs"]
mod tests;
+/// The git config overrides a shell-spawned `git` is forced to run under.
+///
+/// Re-exported from the module that owns the whole policy so the `shell` tool
+/// and `git_operations` cannot drift into two different answers about which
+/// config keys are dangerous.
+pub(crate) use git_operations_config::SHELL_NEUTRALISED_CONFIG;
+
pub use apply_patch::ApplyPatchTool;
pub use csv_export::CsvExportTool;
pub use edit_file::EditFileTool;