Skip to content

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

test(storage): cover path traversal rejection in remove_within

Steven Enamakel05533bbe0e4c
diff --git a/crates/openhuman-core/src/storage/layout/run_tests.rs b/crates/openhuman-core/src/storage/layout/run_tests.rs
index 7894713703..bf8c185612 100644
--- a/crates/openhuman-core/src/storage/layout/run_tests.rs
+++ b/crates/openhuman-core/src/storage/layout/run_tests.rs
@@ -486,3 +486,19 @@ async fn auto_migrate_is_off_by_default_and_runs_when_asked() {
assert_migrated(&fx);
assert!(!auto_migrate(&on).await, "already v2");
}
+
+#[test]
+fn deleting_refuses_a_path_that_climbs_out_of_its_base() {
+ let dir = tempfile::tempdir().unwrap();
+ let base = dir.path().join("files");
+ std::fs::create_dir_all(&base).unwrap();
+ let outside = dir.path().join("keep.txt");
+ std::fs::write(&outside, b"keep").unwrap();
+
+ let climbing = plan::join(&base, "../keep.txt");
+ assert!(matches!(
+ remove_within(&base, &climbing),
+ Err(LayoutError::Verify(_))
+ ));
+ assert!(outside.is_file(), "a `..` entry must not delete outside the base");
+}