From 2fce5b4e93cb6d0f4cb6b3210b4161472304fb94 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Mon, 2 Nov 2026 21:03:07 +0100 Subject: [PATCH] radicle/identity: Compare OID of proposed document Reject revisions whose embedded identity document differs from the what is being signed over. --- crates/radicle/src/cob/identity.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/radicle/src/cob/identity.rs b/crates/radicle/src/cob/identity.rs index 9afe0b7ab..ae2874ff1 100644 --- a/crates/radicle/src/cob/identity.rs +++ b/crates/radicle/src/cob/identity.rs @@ -115,6 +115,10 @@ pub enum ApplyError { /// Invalid signature over document blob. #[error("invalid signature from {0} for blob {1}")] InvalidSignature(PublicKey, Oid), + /// The identity document embedded in an operation that carries a [`Revision`] + /// action differs from the blob signed by the delegates. + #[error("identity document blob {embedded} does not match signed blob {signed}")] + DocMismatch { signed: Oid, embedded: Oid }, /// Unauthorized action. #[error("not authorized to perform this action")] NotAuthorized, @@ -645,7 +649,14 @@ impl Identity { } => { debug_assert_eq!(self.revisions.get(&id), None, "revision visited twice"); - let doc = Doc::from_blob(&repo.blob(blob)?)?; + let embedded = Doc::blob_at(id, repo)?; + if Oid::from(embedded.id()) != blob { + return Err(ApplyError::DocMismatch { + signed: blob, + embedded: embedded.id().into(), + }); + } + let doc = Doc::from_blob(&embedded)?; // All revisions but the first one must have a parent. let parent_id = parent_id.ok_or(ApplyError::MissingParent)?;