diff --git a/hive-c0re/src/dashboard.rs b/hive-c0re/src/dashboard.rs index 86fd64d2..17662b48 100644 --- a/hive-c0re/src/dashboard.rs +++ b/hive-c0re/src/dashboard.rs @@ -1886,6 +1886,17 @@ async fn post_purge_tombstone( State(state): State, AxumPath(name): AxumPath, ) -> Response { + // Format guard FIRST so a name like `..` can't traverse into the + // parent of `/var/lib/hyperhive/agents/{name}` and have + // `remove_dir_all` wipe `/var/lib/hyperhive/` itself. Existing + // manager + live-container checks below don't catch `..` — only + // the whitelist does. (argus #593 🔴.) Existence check via + // `containers_snapshot()` is deliberately NOT used here: + // tombstoned agents are gone from the snapshot by design; that's + // the whole point of this endpoint. + if let Some(reason) = validate_agent_name(&name) { + return (StatusCode::BAD_REQUEST, format!("bad agent name: {reason}")).into_response(); + } if name == lifecycle::MANAGER_NAME { return error_response("refusing to purge the manager's state"); }