Watch
0
0
Fork
You've already forked hyperhive
0

hive-priv refuses bind-mount edits on the swarm's forge and matrix containers

The forge and matrix containers belong to the services host, not to a
hive. hive-priv's container-name validator still accepted hive-forge and
hive-matrix for WriteNspawnFlags, WriteResourceLimits and
RemoveServiceDropin; hive-c0re only ever sends h-<agent> names there.

- hive-priv-sock/src/lib.rs: drop SIBLING_CONTAINERS, its only user was
  the validator, and its test.
- hive-priv/src/main.rs: the validator accepts only h-<name> and returns
  the logical name, so write_resource_limits loses its non-h- fallback;
  test that all three requests refuse both names.
- hive-priv/README.md, docs/trust-boundary/security.md: the allowlist
  no longer lists the forge and matrix.

Fixes #5508
This commit is contained in:
atlas 2026-10-17 23:40:53 +02:00 • committed by mara
commit 4f75e2a71a
4 changed files with 57 additions and 58 deletions

View file

@ -28,21 +28,6 @@ pub const PAUSED_MARKER_FILE: &str = "paused";
/// Sub-agent container prefix. System container name = `h-<agent_name>`.
pub const AGENT_PREFIX: &str = "h-";
/// Sibling service containers managed by hive-c0re. This doubles as the
/// authoritative allowlist for the requests that name a container as a
/// string (bind-mount edits): only these — or a valid agent
/// name — are accepted. `hive-c0re` is deliberately absent; so is the
/// gateway, whose nginx is a plain host unit rather than a container.
/// hive-priv re-validates against this list root-side, so it's authoritative
/// regardless of what the caller sends.
///
/// ⚠️ This is the *container-name* allowlist, not the lifecycle one:
/// [`InfraContainer`] is what gates
/// [`PrivRequest::ControlInfraContainer`], and no name in this list has a
/// variant there: the forge and matrix are swarm services, started and
/// stopped by systemd on the host that runs them, never from a hive.
pub const SIBLING_CONTAINERS: &[&str] = &["hive-forge", "hive-matrix"];
/// Lifecycle verb for [`PrivRequest::ControlInfraContainer`]. Maps directly
/// to `systemctl <verb> <unit>`, where the unit comes from
/// [`InfraContainer::service_unit`].
@ -659,17 +644,7 @@ pub enum PrivEvent {
#[cfg(test)]
mod tests {
use super::{InfraContainer, SIBLING_CONTAINERS};
#[test]
fn sibling_container_allowlist_excludes_c0re() {
// SIBLING_CONTAINERS is the authoritative allowlist for the
// requests that name a container as a string. hive-c0re must NEVER
// be in it — stopping the daemon would sever the socket the request
// arrived on.
assert!(!SIBLING_CONTAINERS.contains(&"hive-c0re"));
assert!(SIBLING_CONTAINERS.contains(&"hive-matrix"));
}
use super::InfraContainer;
#[test]
fn infra_control_names_no_c0re_or_swarm_service() {