Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block resumption psks #817

Merged
merged 7 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ futures = "0.3.30"
futures-core = "0.3.30"
hex = "0.4.3"
log = "0.4"
openmls = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls_basic_credential = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls_rust_crypto = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls_traits = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls = { git = "https://github.com/xmtp/openmls", rev = "99b2d5e7d0e034ac57644395e2194c5a102afb9a" }
openmls_basic_credential = { git = "https://github.com/xmtp/openmls", rev = "99b2d5e7d0e034ac57644395e2194c5a102afb9a" }
openmls_rust_crypto = { git = "https://github.com/xmtp/openmls", rev = "99b2d5e7d0e034ac57644395e2194c5a102afb9a" }
openmls_traits = { git = "https://github.com/xmtp/openmls", rev = "99b2d5e7d0e034ac57644395e2194c5a102afb9a" }
prost = "^0.12"
prost-types = "^0.12"
rand = "0.8.5"
Expand Down
12 changes: 6 additions & 6 deletions bindings_ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use openmls::{
Extension, ExtensionType, Extensions, Metadata, RequiredCapabilitiesExtension,
UnknownExtension,
},
group::{CreateGroupContextExtProposalError, MlsGroupCreateConfig, MlsGroupJoinConfig},
group::{
CreateGroupContextExtProposalError, MlsGroupCreateConfig, MlsGroupJoinConfig,
ProcessedWelcome,
},
messages::proposals::ProposalType,
prelude::{
BasicCredentialError, Capabilities, CredentialWithKey, Error as TlsCodecError, GroupId,
Expand Down Expand Up @@ -165,6 +168,8 @@ pub enum GroupError {
MessageHistory(#[from] MessageHistoryError),
#[error("Installation diff error: {0}")]
InstallationDiff(#[from] InstallationDiffError),
#[error("PSKs are not support")]
NoPSKSupport,
}

impl RetryableError for GroupError {
Expand Down Expand Up @@ -326,8 +331,14 @@ impl MlsGroup {
let welcome = deserialize_welcome(&welcome_bytes)?;

let join_config = build_group_join_config();
let staged_welcome =
StagedWelcome::new_from_welcome(provider, &join_config, welcome.clone(), None)?;

let processed_welcome =
ProcessedWelcome::new_from_welcome(provider, &join_config, welcome.clone())?;
let psks = processed_welcome.psks();
if !psks.is_empty() {
return Err(GroupError::NoPSKSupport);
}
let staged_welcome = processed_welcome.into_staged_welcome(provider, None)?;

let added_by_node = staged_welcome.welcome_sender()?;

Expand Down
8 changes: 8 additions & 0 deletions xmtp_mls/src/groups/validated_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ pub enum CommitValidationError {
InstallationDiff(#[from] InstallationDiffError),
#[error("Failed to parse group mutable permissions: {0}")]
GroupMutablePermissions(#[from] GroupMutablePermissionsError),
#[error("PSKs are not support")]
NoPSKSupport,
}

#[derive(Debug, Clone, PartialEq, Hash)]
Expand Down Expand Up @@ -186,6 +188,7 @@ impl MetadataFieldChange {
* present in the [`AssociationState`] for the `inbox_id` presented in the credential at the `to_sequence_id` found in the
* new [`GroupMembership`].
* 5. All proposals in a commit must come from the same installation
* 6. No PSK proposals will be allowed
*/
#[derive(Debug, Clone)]
pub struct ValidatedCommit {
Expand Down Expand Up @@ -226,6 +229,11 @@ impl ValidatedCommit {
&mutable_metadata,
)?;

// Block any psk proposals
if staged_commit.psk_proposals().any(|_| true) {
nplasterer marked this conversation as resolved.
Show resolved Hide resolved
return Err(CommitValidationError::NoPSKSupport);
}

// Get the installations actually added and removed in the commit
let ProposalChanges {
added_installations,
Expand Down
Loading