From af120b87c42ca56f69bbe6f8d27c023919742430 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 16:43:53 +0000 Subject: swarm: a new swarm's policy recorded in its genesis change A swarm strict from its start had its policy written by its first user in a later change. A change is judged by the policy at its history, so any member could always add a change whose history is from before the policy: judged by none, needing no signature, taken whenever it comes. Since signed values are read by `seq`, an envelope planted there with the highest `seq` there is can never be followed: a ban, a user, a declaration, for good. `--bootstrap-policy JSON`, with `--genesis`, records the policy in the genesis change, with the first users: then no change of the swarm is from before it. It must be a policy this node knows, and a strict one needs `--bootstrap-keys`, or nobody could sign what decides who may do what. --- src/config/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/config') diff --git a/src/config/mod.rs b/src/config/mod.rs index c0abc09..1686792 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -179,6 +179,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ None, "With bootstrap-users: their SSH keys, as authorized_keys lines (ssh-ed25519 [comment], named by the comment), recorded in their entries: to log in by key and sign values (docs/access.md), so a swarm can be strict from its start.", ), + option( + "bootstrap-policy", + Kind::Text, + "JSON", + None, + "With genesis: the swarm's write protection policy (docs/access.md), recorded in its first change with its first users, so that no change of the swarm is from before it: {\"version\": 1, \"values\": \"signed\"} makes it strict from its start, and needs bootstrap-keys.", + ), option( "refused-writes-per-minute", Kind::Integer, @@ -622,6 +629,7 @@ pub(crate) struct Settings { pub(crate) bootstrap_users: Vec, #[serde(default)] pub(crate) bootstrap_keys: Vec, + pub(crate) bootstrap_policy: Option, pub(crate) genesis_root: Option, #[serde(default)] pub(crate) strict_keys: Vec, @@ -898,6 +906,11 @@ impl Settings { "bootstrap-users names the first users of a new swarm; it needs genesis (drop it once the swarm exists)" ); } + if self.bootstrap_policy.is_some() && !self.genesis { + bail!( + "bootstrap-policy is the policy of a new swarm; it needs genesis (drop it once the swarm exists)" + ); + } if let Some(bad) = self .bootstrap_users .iter() @@ -910,6 +923,11 @@ impl Settings { { bail!("{why}"); } + if let Err(why) = + crate::access::policy::first(self.bootstrap_policy.as_deref(), &self.bootstrap_keys) + { + bail!("{why}"); + } if let Some(root) = &self.genesis_root && crate::swarm::roots::parse(root).is_none() { @@ -1075,6 +1093,7 @@ impl Settings { ("protocol-writers", !self.protocol_writers.is_empty()), ("bootstrap-users", !self.bootstrap_users.is_empty()), ("bootstrap-keys", !self.bootstrap_keys.is_empty()), + ("bootstrap-policy", self.bootstrap_policy.is_some()), ("alias", self.alias.is_some()), ("dashboard-url", self.dashboard_url.is_some()), ("debug-api", self.debug_api), -- cgit v1.3.1