hsservice: Reject extensions in IntroEstablished cells

Intro points must not send these extensions except in response to a
request that prompts them.
This commit is contained in:
Nick Mathewson 2023-08-15 13:09:14 -04:00
parent bac156bcf5
commit 99be70afd4
1 changed files with 12 additions and 4 deletions

View File

@ -81,6 +81,10 @@ pub(crate) enum IptError {
// Circuit,... // Circuit,...
ReceiveAck, ReceiveAck,
/// We received an invalid INTRO_ESTABLISHED message.
#[error("Got an invalid INTRO_ESTABLISHED message")]
BadEstablished,
/// We encountered a programming error. /// We encountered a programming error.
#[error("Internal error")] #[error("Internal error")]
Bug(#[from] tor_error::Bug), Bug(#[from] tor_error::Bug),
@ -122,7 +126,7 @@ impl IptEstablisher {
/// `hssvc-ipt-algorithms.md`. /// `hssvc-ipt-algorithms.md`.
/// ///
/// TODO HSS Make that file unneeded. /// TODO HSS Make that file unneeded.
#[derive(Clone, Debug)] #[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) enum IptStatusStatus { pub(crate) enum IptStatusStatus {
/// We are (re)establishing our connection to the IPT /// We are (re)establishing our connection to the IPT
/// ///
@ -139,11 +143,11 @@ pub(crate) enum IptStatusStatus {
/// `Err(IptWantsToRetire)` indicates that the IPT Establisher wants to retire this IPT /// `Err(IptWantsToRetire)` indicates that the IPT Establisher wants to retire this IPT
/// ///
/// This happens when the IPT has had (too) many rendezvous requests. /// This happens when the IPT has had (too) many rendezvous requests.
#[derive(Clone, Debug)] #[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct IptWantsToRetire; pub(crate) struct IptWantsToRetire;
/// The current status of an introduction point. /// The current status of an introduction point.
#[derive(Clone, Debug)] #[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct IptStatus { pub(crate) struct IptStatus {
/// The current state of this introduction point as defined by /// The current state of this introduction point as defined by
/// `hssvc-ipt-algorithms.md`. /// `hssvc-ipt-algorithms.md`.
@ -251,7 +255,11 @@ where
let established = established_rx.await.map_err(|_| IptError::ReceiveAck)?; let established = established_rx.await.map_err(|_| IptError::ReceiveAck)?;
// TODO HSS: handle all the extension data in the established field. if established.iter_extensions().next().is_some() {
// We do not support any extensions from the introduction point; if it
// sent us any, that's a protocol violation.
return Err(IptError::BadEstablished);
}
// TODO HSS: Return the introduce_rx stream along with any related types. // TODO HSS: Return the introduce_rx stream along with any related types.
// Or should we have taken introduce_tx as an argument? (@diziet endorses // Or should we have taken introduce_tx as an argument? (@diziet endorses