Skip to content

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

fix(security): match command executors and args case-insensitively

Steven Enamakelb3e6c4f88b50
diff --git a/crates/openhuman-core/src/security/policy/command_analysis.rs b/crates/openhuman-core/src/security/policy/command_analysis.rs
index d99f0c3de1..904643d45a 100644
--- a/crates/openhuman-core/src/security/policy/command_analysis.rs
+++ b/crates/openhuman-core/src/security/policy/command_analysis.rs
@@ -228,7 +228,8 @@ pub(super) fn classify_host_command(base: &str, args: &[String], source: &str) -
}
pub(super) fn is_command_executor_name(name: &str) -> bool {
- let name = name.strip_suffix(".exe").unwrap_or(name);
+ let name = name.to_ascii_lowercase();
+ let name = name.strip_suffix(".exe").unwrap_or(&name);
let python = ["pythonw", "python"]
.iter()
.any(|prefix| is_versioned_executable(name, prefix));
diff --git a/crates/openhuman-core/src/security/policy/command_checks.rs b/crates/openhuman-core/src/security/policy/command_checks.rs
index 1299915b4e..2a9ff9c531 100644
--- a/crates/openhuman-core/src/security/policy/command_checks.rs
+++ b/crates/openhuman-core/src/security/policy/command_checks.rs
@@ -81,11 +81,12 @@ fn contains_unquoted_single_ampersand(command: &str) -> bool {
#[cfg(test)]
fn has_hidden_execution(command: &str) -> bool {
+ let command = strip_quoted_heredoc_bodies(command);
["$(", "<(", ">("]
.iter()
.any(|needle| command.contains(needle))
- || contains_unquoted_char(command, '`')
- || contains_unquoted_single_ampersand(command)
+ || contains_unquoted_char(&command, '`')
+ || contains_unquoted_single_ampersand(&command)
}
#[cfg(test)]
@@ -312,7 +313,12 @@ impl SecurityPolicy {
continue;
};
let base = normalized_command_name(base_raw);
- let args: Vec<String> = words.map(|w| w.to_ascii_lowercase()).collect();
+ let args: Vec<String> = words
+ .map(|word| {
+ word.trim_matches(|character: char| matches!(character, '\'' | '"'))
+ .to_ascii_lowercase()
+ })
+ .collect();
let joined = cmd_part.to_ascii_lowercase();
let segment_class = classify_segment(&base, &args, &joined);
class = class.max(segment_class);