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

Potential future vulnerability in polyproto in Chorus #469

Open
bitfl0wer opened this issue Jan 23, 2024 · 2 comments
Open

Potential future vulnerability in polyproto in Chorus #469

bitfl0wer opened this issue Jan 23, 2024 · 2 comments

Comments

@bitfl0wer
Copy link
Member

There might be a future security vulnerability in Chorus, if we implement polyproto into Chorus without the correct considerations.

For example:

Lets say we have a Relationship object. PartialEq on Relationship is defined as such:

pub struct Relationship {
    pub id: Snowflake,
    #[serde(rename = "type")]
    pub relationship_type: RelationshipType,
    pub nickname: Option<String>,
    pub user: Shared<PublicUser>,
    pub since: Option<DateTime<Utc>>,
}

impl PartialEq for Relationship {
    fn eq(&self, other: &Self) -> bool {
        self.id == other.id
            && self.relationship_type == other.relationship_type
            && self.since == other.since
            && self.nickname == other.nickname
    }
}

Note, that the user field is not compared. This is because the User is behind an RwLock, and therefore the lock would have to be acquired to do an equality comparison on the User object. This is fine in our current context, and PartialEq documents that this is a possibility.

However; the id field of Relationship is the ID of the target user, i.e. the User the Relationship is described to.
On Discord, Snowflake IDs are unique. In a federated context, this does not hold true, and an attacker could, if no change is made, craft a user object with the same Snowflake ID as another user, and possibly force a relationship with someone through that.

This needs to be considered when implementing polyproto into Chorus.

@erkinalp
Copy link

erkinalp commented Mar 1, 2024

the User is behind an RwLock

Interesting design choice there.

@bitfl0wer
Copy link
Member Author

Elaborate? Also, this is off-topic for this issue.

the User is behind an RwLock

Interesting design choice there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants