[PM-40523] feat: Add endpoint to return organization private key to admins#8006
Conversation
…dmins
Adds GET /organizations/{orgId}/private-key so admin-level users
(owners, admins, providers, and the "Manage Users" custom permission)
can fetch an organization's encrypted private key.
Supports KM's fix for the account-recovery-enrollment vulnerability
(PM-40307): admins generating an invite link need to derive the org's
public-key fingerprint from a source that can't be silently swapped by
a malicious server. Fetching the encrypted, tamper-evident private key
and deriving the public key/fingerprint from it client-side achieves
that, instead of trusting a bare public key fetched from the server.
Gated by ManageUsersRequirement per the ticket's authorization spec
(deliberately widens "Manage Users" access to the org private key,
pending AppSec sign-off) and by the GenerateInviteLink feature flag,
matching the rest of this epic's admin-side invite-link endpoints.
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the new Code Review DetailsNo blocking findings. The change mirrors the existing sibling |
Removes the leftover FIXME/#nullable disable that was copy-pasted from an older sibling model. This file is new on this branch, so it should be nullable-clean from the start rather than carrying forward debt.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8006 +/- ##
=======================================
Coverage 62.46% 62.47%
=======================================
Files 2297 2298 +1
Lines 99981 99996 +15
Branches 9020 9022 +2
=======================================
+ Hits 62456 62468 +12
- Misses 35346 35348 +2
- Partials 2179 2180 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-40523
📔 Objective
Adds
GET /organizations/{orgId}/private-key, letting admin-level users (owners, admins, providers, and the "Manage Users" custom permission) fetch an organization's encrypted private key.This supports KM's fix for the account-recovery-enrollment vulnerability (PM-40307): when an admin generates an invite link, the client needs to derive the org's public-key fingerprint from a source that can't be silently swapped by a malicious server. Fetching the encrypted (tamper-evident) private key and deriving the public key/fingerprint from it client-side achieves that, instead of trusting a bare public key fetched directly from the server.
Access is gated by
[Authorize<ManageUsersRequirement>], matching the ticket's explicit authorization spec. This deliberately widens access for the "Manage Users" custom permission (previously only "Manage account recovery" could read the org private key) — a known, intentional expansion discussed in PM-40523. Also gated behind theGenerateInviteLinkfeature flag, matching the rest of this epic's admin-side invite-link endpoints.