Skip to content

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

feat(skills): add path validation and ClawHub file API support

Steven Enamakel503c4e8c74f2
diff --git a/crates/openhuman-core/src/skills/ops_discover/resource.rs b/crates/openhuman-core/src/skills/ops_discover/resource.rs
index e4fe81d9df..d0c3c0cb3e 100644
--- a/crates/openhuman-core/src/skills/ops_discover/resource.rs
+++ b/crates/openhuman-core/src/skills/ops_discover/resource.rs
@@ -1,7 +1,7 @@
//! OpenHuman discovery context around `tinyskills` resource reads.
use std::collections::HashSet;
-use std::path::Path;
+use std::path::{Component, Path};
use crate::skills::ops_types::WorkflowScope;
@@ -21,6 +21,22 @@ fn reject_symlink_components(root: &Path, relative_path: &Path) -> Result<(), St
Ok(())
}
+fn validate_relative_path(relative_path: &Path) -> Result<(), String> {
+ if relative_path.as_os_str().is_empty() {
+ return Err("relative_path must not be empty".to_owned());
+ }
+ if relative_path.is_absolute() {
+ return Err("relative_path must not be absolute".to_owned());
+ }
+ if relative_path
+ .components()
+ .any(|component| !matches!(component, Component::Normal(_)))
+ {
+ return Err("relative_path must not contain '..' or escape the skill directory".to_owned());
+ }
+ Ok(())
+}
+
pub fn read_workflow_resource(
workspace_dir: &Path,
skill_id: &str,
@@ -49,6 +65,7 @@ pub fn read_workflow_resource_with_profile(
if skill_id.trim().is_empty() {
return Err("skill_id must not be empty".to_string());
}
+ validate_relative_path(relative_path)?;
let skill = tinyskills::resolve_skill(
load_workflow_metadata_for_profile(workspace_dir, profile_skills_root),
skill_id,
diff --git a/crates/openhuman-core/src/skills/ops_install/url_validation.rs b/crates/openhuman-core/src/skills/ops_install/url_validation.rs
index e156518198..3fe5aaeb06 100644
--- a/crates/openhuman-core/src/skills/ops_install/url_validation.rs
+++ b/crates/openhuman-core/src/skills/ops_install/url_validation.rs
@@ -6,6 +6,24 @@ pub const MAX_INSTALL_URL_LEN: usize = tinyskills::install::MAX_INSTALL_URL_LEN;
const ALLOW_LOCAL_HTTP_ENV: &str = "OPENHUMAN_SKILL_INSTALL_ALLOW_LOCAL_HTTP";
pub(crate) fn normalize_install_url(raw: &str) -> Result<String, String> {
+ // ClawHub's file API identifies the requested Markdown file in its query
+ // rather than in the URL path. Preserve this OpenHuman-compatible form
+ // while keeping the portable validator strict for every other host/path.
+ if let Ok(url) = url::Url::parse(raw) {
+ let is_clawhub_file_api = url.host_str() == Some("clawhub.ai")
+ && url.path().starts_with("/api/v1/skills/")
+ && url.path().ends_with("/file");
+ if is_clawhub_file_api {
+ let markdown_path = url
+ .query_pairs()
+ .find(|(key, _)| key == "path")
+ .map(|(_, value)| value.to_ascii_lowercase().ends_with(".md"))
+ .unwrap_or(false);
+ if markdown_path {
+ return Ok(raw.to_owned());
+ }
+ }
+ }
tinyskills::normalize_install_url(raw)
}