Skip to content

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

feat(policy): strip quoted heredoc bodies before hidden-execution check

Steven Enamakel3c92600352c0
diff --git a/crates/openhuman-core/src/security/policy/command_checks.rs b/crates/openhuman-core/src/security/policy/command_checks.rs
index 2538af5783..14a4771697 100644
--- a/crates/openhuman-core/src/security/policy/command_checks.rs
+++ b/crates/openhuman-core/src/security/policy/command_checks.rs
@@ -4,6 +4,7 @@ use super::policy_command::{
classify_segment, command_basename, contains_unquoted_char, contains_unquoted_single_ampersand,
has_dangerous_env_prefix, has_hidden_execution, has_leading_env_assignment,
is_command_executor, normalized_command_name, skip_env_assignments, split_unquoted_segments,
+ strip_quoted_heredoc_bodies,
};
use super::types::{
AutonomyLevel, CommandClass, CommandRiskLevel, GateDecision, SecurityPolicy,
diff --git a/crates/openhuman-core/src/security/policy/policy_command/classification.rs b/crates/openhuman-core/src/security/policy/policy_command/classification.rs
index ab3ed957a9..858c091108 100644
--- a/crates/openhuman-core/src/security/policy/policy_command/classification.rs
+++ b/crates/openhuman-core/src/security/policy/policy_command/classification.rs
@@ -358,6 +358,13 @@ fn verb_class(args: &[String], read_verbs: &[&str]) -> CommandClass {
/// that made Supervised mode unusable: every command the agent wrote carried a
/// `2>&1`, got approved, then silently failed this in-tool guard and never ran.
pub(in crate::security::policy) fn has_hidden_execution(command: &str) -> bool {
+ // A quoted heredoc body (`<< 'EOF' … EOF`) is data, not shell: the shell
+ // performs no expansion inside it, so an `&`, a backtick or a `$(` there
+ // cannot run anything. Scanning it as live text refused ordinary documents
+ // — the life-scenario `meal-plan` write was blocked because four recipe
+ // titles read "Chicken & Spinach". An *unquoted* delimiter is left in place
+ // by the helper, because expansion IS live in that body.
+ let command = &super::quoting::strip_quoted_heredoc_bodies(command);
// The backtick check is deliberately NOT quote-aware: any backtick in the
// command string is blocked, even inside a double-quoted literal. Over-
// blocking is the safe direction here. (By contrast the `&` case below is