From 5c42a2b994489c6b381261320673c90b7504f8f8 Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Mon, 23 Nov 2026 17:42:21 +0000 Subject: [PATCH] fix(rendezvous): Validate PUT txn_id against opaque identifier grammar --- src/service/rendezvous/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/service/rendezvous/mod.rs b/src/service/rendezvous/mod.rs index 09cceafbc..0932b5f66 100644 --- a/src/service/rendezvous/mod.rs +++ b/src/service/rendezvous/mod.rs @@ -55,6 +55,14 @@ impl Service { fn create_token() -> String { utils::random_string(Self::TOKEN_LENGTH) } + fn is_valid_opaque_id(id: &str) -> bool { + !id.is_empty() + && id.len() <= 255 + && id + .bytes() + .all(|b| b.is_ascii_alphanumeric() || matches!(b, b'-' | b'.' | b'_' | b'~')) + } + /// Lock and fetch an unexpired rendezvous session. fn lock_session(&self, id: &str) -> Result> { // We don't clear out expired sessions manually, the LRU cache will @@ -103,6 +111,12 @@ impl Service { sequence_token: String, data: String, ) -> Result { + if !Self::is_valid_opaque_id(transaction.as_str()) { + return Err!(Request(InvalidParam( + "Transaction ID does not comply with the opaque identifier grammar" + ))); + } + let mut session = self.lock_session(id)?; // If the provided transaction ID was used already, we have to return