dashboard: format guard on post_purge_tombstone (path traversal hole — argus 🔴 on #593)
This commit is contained in:
parent
0006c0635e
commit
977bb16678
1 changed files with 11 additions and 0 deletions
|
|
@ -1886,6 +1886,17 @@ async fn post_purge_tombstone(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
AxumPath(name): AxumPath<String>,
|
AxumPath(name): AxumPath<String>,
|
||||||
) -> Response {
|
) -> 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 {
|
if name == lifecycle::MANAGER_NAME {
|
||||||
return error_response("refusing to purge the manager's state");
|
return error_response("refusing to purge the manager's state");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue