Skip to content

Commit 13f4b66

Browse files
authored
Hide user name on invite status (dani-garcia#5110)
A possible user disclosure when you invite an user into an organization which already has an account on the same instance. This was because we always returned the user's name. To prevent this, this PR only returns the user's name if the status is accepted or higher, else we will return null. This is the same as Bitwarden does. Resolves a reported issue. Also resolved a new `nightly` reported clippy regarding a regex within a loop.
1 parent c967d0d commit 13f4b66

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/db/models/organization.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ impl UserOrganization {
232232
false
233233
}
234234

235+
/// Return the status of the user in an unrevoked state
236+
pub fn get_unrevoked_status(&self) -> i32 {
237+
if self.status <= UserOrgStatus::Revoked as i32 {
238+
return self.status + ACTIVATE_REVOKE_DIFF;
239+
}
240+
self.status
241+
}
242+
235243
pub fn set_external_id(&mut self, external_id: Option<String>) -> bool {
236244
//Check if external id is empty. We don't want to have
237245
//empty strings in the database
@@ -524,7 +532,7 @@ impl UserOrganization {
524532
json!({
525533
"id": self.uuid,
526534
"userId": self.user_uuid,
527-
"name": user.name,
535+
"name": if self.get_unrevoked_status() >= UserOrgStatus::Accepted as i32 { Some(user.name) } else { None },
528536
"email": user.email,
529537
"externalId": self.external_id,
530538
"avatarColor": user.avatar_color,

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,10 @@ async fn container_data_folder_is_persistent(data_folder: &str) -> bool {
516516
format!(" /{data_folder} ")
517517
};
518518
let mut lines = BufReader::new(mountinfo).lines();
519+
let re = regex::Regex::new(r"/volumes/[a-z0-9]{64}/_data /").unwrap();
519520
while let Some(line) = lines.next_line().await.unwrap_or_default() {
520521
// Only execute a regex check if we find the base match
521522
if line.contains(&data_folder_match) {
522-
let re = regex::Regex::new(r"/volumes/[a-z0-9]{64}/_data /").unwrap();
523523
if re.is_match(&line) {
524524
return false;
525525
}

0 commit comments

Comments
 (0)