Browse Source

Return NotFound for admin attachments and ungate assigned ciphers

pull/7938/head
tom27052006 3 days ago
parent
commit
12c1143122
  1. 5
      src/api/core/ciphers.rs
  2. 4
      src/api/core/organizations.rs

5
src/api/core/ciphers.rs

@ -1491,15 +1491,16 @@ async fn get_attachment_data(
};
if scope == CipherAccessScope::OrganizationAdmin {
// NotFound as in Bitwarden, the web vault then falls back to the attachment's own URL
let Some(org_id) = cipher.organization_uuid.as_ref() else {
err!("Cipher is not owned by an organization")
err_code!("Cipher is not owned by an organization", Status::NotFound.code)
};
if !Membership::find_confirmed_by_user_and_org(&headers.user.uuid, org_id, &conn)
.await
.is_some_and(|member| member.can_edit_any_collection())
|| !cipher.is_write_accessible_to_user(&headers.user.uuid, scope, &conn).await
{
err!("Cipher is not accessible")
err_code!("Cipher is not accessible", Status::NotFound.code)
}
} else if !cipher.is_accessible_to_user(&headers.user.uuid, scope, &conn).await {
err!("Cipher is not accessible")

4
src/api/core/organizations.rs

@ -879,10 +879,6 @@ async fn get_org_details_impl(
// cipher, like a Custom member with Delete any collection only. As in Bitwarden, any confirmed member may list them.
#[get("/ciphers/organization-details/assigned?<data..>")]
async fn get_assigned_org_details(data: OrgIdData, headers: Headers, conn: DbConn) -> JsonResult {
// Only the Custom role needs this, every other role that opens the Admin Console may edit every cipher
if !custom_roles_enabled() {
err_code!("Resource not found.", "Custom roles are disabled", Status::NotFound.code);
}
let Some(member) =
Membership::find_confirmed_by_user_and_org(&headers.user.uuid, &data.organization_id, &conn).await
else {

Loading…
Cancel
Save