dashboard: format guard on post_purge_tombstone (path traversal hole — argus 🔴 on #593)

This commit is contained in:
damocles 2026-05-29 18:46:27 +02:00 committed by Mara
commit 977bb16678

View file

@ -1886,6 +1886,17 @@ async fn post_purge_tombstone(
State(state): State<AppState>,
AxumPath(name): AxumPath<String>,
) -> 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");
}