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

Check against the inbox id derived against the checksum as well #1268

Closed
wants to merge 5 commits into from

Conversation

codabrink
Copy link
Contributor

@codabrink codabrink commented Nov 14, 2024

Fixes xmtp/xmtp-react-native#512

It appears that our SDKs at some point allowed or still allow checksum addresses to create inboxIds. Now we have inboxIds on the network that throw a mismatch id error because we handle most addresses as lowercase.
This is supposed to prevent any checksum inboxIds from being created ever again and help unblock users with inboxIds that were created from checksum addresses.

@codabrink codabrink marked this pull request as ready for review November 14, 2024 22:00
@codabrink codabrink requested a review from a team as a code owner November 14, 2024 22:00
@codabrink codabrink changed the title Coda/checksum inbox Check against the inbox id derived against the checksum as well Nov 14, 2024
Copy link
Contributor

@nplasterer nplasterer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes the most sense to continue to support legacy addresses created from a checksum address. Would be good to know where these checksum inbox Ids are still being created. I'll do another pass on lowercasing in the sdk when I push this fix out through the sdks. And @rygine maybe you can as well whenever you push this out through node and web?

@rygine
Copy link
Collaborator

rygine commented Nov 14, 2024

@nplasterer i reviewed the WASM/node bindings, and we're already lowercasing where necessary. 🎉

@@ -381,6 +381,7 @@ impl IdentityAction for IdentityUpdate {
}

let new_state = state.ok_or(AssociationError::NotCreated)?;
// Do we need to handle this case for checksum inboxIds?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@insipx I could hack some code here to check for mismatched inboxIds from checksums here but it's a lot less straight forward thoughts on this case?

use sha2::{Digest, Sha256};

use super::AssociationError;

/// Helper function to generate a SHA256 hash as a hex string.
fn sha256_string(input: String) -> String {
let normalized_input = input.to_lowercase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to do this here we should rename the function. Will be a footgun to change the string before hashing, since callers won't expect that.

@@ -104,7 +103,8 @@ impl IdentityStrategy {
legacy_signed_private_key,
) => {
if let Some(stored_identity) = stored_identity {
if inbox_id != stored_identity.inbox_id {
let checksum_inbox_id = generate_inbox_id_from_checksum(&address, &nonce)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the inbox ID was created with the checksum address, and not the lowercased one, it shouldn't be able to create a valid Create Inbox identity action

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check that the inbox ID matches the signer as part of verifying that Identity Action, so it should blow up there.

So even if your client "works", everyone else would reject you

@neekolas
Copy link
Contributor

How many people do we think this issue is affecting?

I'd much rather force them into creating a new identity and shed tech debt rather than having to support this bug forever.

@nplasterer
Copy link
Contributor

The only real person in particular that we know this is effecting is @rygine. But I think a lot of bot accounts and other fresh accounts @humanagent was testing with were also failing but those I think are less important.

@nplasterer nplasterer closed this Nov 15, 2024
@nplasterer nplasterer deleted the coda/checksum-inbox-id branch November 15, 2024 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Unable to Import Keys for Clients Generated for the First Time in MessageKit
4 participants