Skip to content

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

fix(boot_guard): reject off-switches for approval gate and sandbox

Steven Enamakel8fa4ba7728cf
diff --git a/crates/openhuman-core/src/core/runtime/boot_guard.rs b/crates/openhuman-core/src/core/runtime/boot_guard.rs
index 66a9b0baea..5aff64def1 100644
--- a/crates/openhuman-core/src/core/runtime/boot_guard.rs
+++ b/crates/openhuman-core/src/core/runtime/boot_guard.rs
@@ -36,6 +36,10 @@ pub const FORBIDDEN_ENV: &[(&str, &str)] = &[
"OPENHUMAN_CORE_TOKEN",
"the gateway bearer must come from the service token file",
),
+];
+
+/// Switches that are fine on but must not turn a protection off.
+pub const FORBIDDEN_OFF_SWITCHES: &[(&str, &str)] = &[
(
"OPENHUMAN_APPROVAL_GATE",
"the approval gate cannot be switched off",
@@ -43,6 +47,13 @@ pub const FORBIDDEN_ENV: &[(&str, &str)] = &[
("OPENHUMAN_SANDBOX", "sandboxing cannot be switched off"),
];
+fn is_off(value: &str) -> bool {
+ matches!(
+ value.trim().to_ascii_lowercase().as_str(),
+ "0" | "false" | "off" | "no" | "disabled"
+ )
+}
+
/// A process-wide backend key; allowed only when the operator opts into
/// [`SaasConfig::shared_backend_api_key`].
pub const SHARED_API_KEY_ENV: &str = "OPENHUMAN_BACKEND_API_KEY";
@@ -192,6 +203,14 @@ pub fn check(inputs: &BootInputs<'_>) -> Result<(), BootGuardError> {
var: var.clone(),
why,
});
+ } else if let Some((_, why)) = FORBIDDEN_OFF_SWITCHES
+ .iter()
+ .find(|(name, _)| name == var && is_off(value))
+ {
+ violations.push(Violation::Env {
+ var: var.clone(),
+ why,
+ });
} else if var == SHARED_API_KEY_ENV && !inputs.config.shared_backend_api_key {
violations.push(Violation::Env {
var: var.clone(),