Skip to content

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

fix(config): make the autonomy allowlist widening visible, and stop promising otherwise

M3gA-Mindbc643a56bff6
diff --git a/src/openhuman/config/migrations/expand_autonomy_defaults.rs b/src/openhuman/config/migrations/expand_autonomy_defaults.rs
index c24145fb93..3b9d4a957b 100644
--- a/src/openhuman/config/migrations/expand_autonomy_defaults.rs
+++ b/src/openhuman/config/migrations/expand_autonomy_defaults.rs
@@ -10,8 +10,24 @@
//! ## What this migration does
//!
//! 1. **Merges new commands** into `config.autonomy.allowed_commands`. Only
-//! commands not already present are added, so any user customisation
-//! (e.g. additional entries, deliberate removals) is fully preserved.
+//! commands not already present are added, so additional entries a user has
+//! made are preserved.
+//!
+//! ⚠️ **A deliberate removal is NOT preserved, and cannot be.** The merge is
+//! additive and has no record of what the v3 default contained, so it cannot
+//! tell "absent because the user removed it" from "absent because it
+//! post-dates this config". A narrowed `allowed_commands` is therefore
+//! widened back. This doc previously claimed removals were "fully
+//! preserved"; that was false in the one direction that matters for a
+//! command allowlist.
+//!
+//! This bites hardest on a **hand-written** `config.toml`: `schema_version`
+//! is `#[serde(default)]`, so a file without the field loads as version `0`
+//! and runs the whole 0→10 chain including this migration — even though it
+//! was never a v3 config. A config this code writes is stamped with
+//! `CURRENT_SCHEMA_VERSION` on creation (`schema/load/impl_load.rs`), so the
+//! fresh-install path is unaffected. Set `schema_version` explicitly to opt
+//! out.
//! 2. **Merges new auto-approve tools** into `config.autonomy.auto_approve`
//! with the same additive-only merge logic.
//! 3. **Bumps `max_actions_per_hour`** from 20 (the old hard-coded default)
@@ -78,6 +94,8 @@ pub fn run(config: &mut Config) -> anyhow::Result<MigrationStats> {
);
// Merge new commands (additive only — never remove user entries).
+ let commands_before = config.autonomy.allowed_commands.clone();
+ let mut added_commands: Vec<&str> = Vec::new();
for &cmd in NEW_COMMANDS {
if !config.autonomy.allowed_commands.iter().any(|c| c == cmd) {
log::debug!(
@@ -85,10 +103,29 @@ pub fn run(config: &mut Config) -> anyhow::Result<MigrationStats> {
cmd
);
config.autonomy.allowed_commands.push(cmd.to_string());
+ added_commands.push(cmd);
stats.commands_added += 1;
}
}
+ // Widening a command allowlist is a security-relevant change, and until now
+ // it happened at DEBUG — invisible on a default log level, and invisible in
+ // the file on disk, which still shows the narrow list the user wrote. Say it
+ // at WARN, and name what was added, whenever the list being widened was not
+ // empty: an empty list is a config that never expressed an opinion, but a
+ // non-empty one is a list somebody chose.
+ if !added_commands.is_empty() && !commands_before.is_empty() {
+ log::warn!(
+ "[migrations][expand-autonomy-defaults] widened a non-empty allowed_commands \
+ from {} to {} entries; added: {}. If this list was curated deliberately, the \
+ removals are NOT preserved — set `schema_version` in config.toml to opt out \
+ of this migration.",
+ commands_before.len(),
+ config.autonomy.allowed_commands.len(),
+ added_commands.join(", ")
+ );
+ }
+
// Merge new auto-approve tools (additive only).
for &tool in NEW_AUTO_APPROVE_TOOLS {
if !config.autonomy.auto_approve.iter().any(|t| t == tool) {
diff --git a/src/openhuman/config/migrations/mod_tests.rs b/src/openhuman/config/migrations/mod_tests.rs
index 0862c38954..591fa2fb20 100644
--- a/src/openhuman/config/migrations/mod_tests.rs
+++ b/src/openhuman/config/migrations/mod_tests.rs
@@ -492,3 +492,77 @@ async fn run_pending_v3_to_v4_preserves_custom_max_actions() {
"user-customised max_actions_per_hour must not be overwritten"
);
}
+
+/// The coverage gap that let the allowlist-widening ship unnoticed.
+///
+/// Existing tests start at v3 (a real migration) or at a fresh install (already
+/// stamped `CURRENT_SCHEMA_VERSION`). Neither covers the case a user actually
+/// hits: a **hand-written** `config.toml` with a deliberately narrow
+/// `allowed_commands` and no `schema_version` field, which `#[serde(default)]`
+/// loads as version `0`.
+///
+/// This test documents what happens today rather than what should. It is not an
+/// endorsement: an additive merge structurally cannot tell "absent because the
+/// user removed it" from "absent because it post-dates this config", so
+/// deciding whether a v0 config with an explicit allowlist should be migrated at
+/// all is a product ruling, not a refactor. Pinning current behaviour means that
+/// ruling, when it comes, has to walk past this assertion.
+#[tokio::test]
+async fn run_pending_widens_a_hand_written_v0_allowlist_and_that_is_visible() {
+ let tmp = TempDir::new().unwrap();
+ fs::create_dir_all(tmp.path().join("workspace")).unwrap();
+
+ let mut config = config_in(&tmp);
+ // A hand-written file: no `schema_version` key at all -> serde default 0.
+ config.schema_version = 0;
+ config.autonomy.allowed_commands = vec!["ls".to_string(), "cat".to_string()];
+
+ run_pending(&mut config).await;
+
+ assert_eq!(
+ config.schema_version, CURRENT_SCHEMA_VERSION,
+ "the whole 0 -> current chain runs against a config that was never at v3"
+ );
+
+ // The user's own entries survive — the merge is additive.
+ for kept in &["ls", "cat"] {
+ assert!(
+ config.autonomy.allowed_commands.iter().any(|c| c == kept),
+ "{kept} was configured explicitly and must survive"
+ );
+ }
+
+ // …and so do 28 commands the user never asked for, five of which mutate the
+ // filesystem. This is the security-relevant half.
+ for added in &["mkdir", "touch", "cp", "mv", "ln"] {
+ assert!(
+ config.autonomy.allowed_commands.iter().any(|c| c == added),
+ "current behaviour: the v3->v4 migration adds {added} to a hand-written \
+ allowlist that never contained it"
+ );
+ }
+ assert!(
+ config.autonomy.allowed_commands.len() > 2,
+ "the configured list of 2 is widened, not preserved: {:?}",
+ config.autonomy.allowed_commands
+ );
+}
+
+/// Setting `schema_version` explicitly is the documented opt-out, and it works.
+#[tokio::test]
+async fn an_explicit_schema_version_stops_the_allowlist_being_widened() {
+ let tmp = TempDir::new().unwrap();
+ fs::create_dir_all(tmp.path().join("workspace")).unwrap();
+
+ let mut config = config_in(&tmp);
+ config.schema_version = CURRENT_SCHEMA_VERSION;
+ config.autonomy.allowed_commands = vec!["ls".to_string(), "cat".to_string()];
+
+ run_pending(&mut config).await;
+
+ assert_eq!(
+ config.autonomy.allowed_commands,
+ vec!["ls".to_string(), "cat".to_string()],
+ "with the gate satisfied no migration runs, so the curated list is untouched"
+ );
+}