@@ -10,12 +10,15 @@ where possible, as required by the protocol specification.
1010
1111To clear secrets on locking, Bitwarden clients use two techniques, zeroizing and process reload. For
1212any memory that lives in Rust, memory is overwritten with zeroes, as soon as it becomes unused or
13- gets dropped. This hardens the SDK, and the Rust desktop module (desktop native) against memory
14- being left behind. Process reload wipes the entire process - on the web app by reloading the page,
15- on browser extensions by reloading the extension, and on desktop by force-crashing the renderer
16- process. The assumption here is that since the process dies, the memory gets wiped too. JavaScript
17- does not provide mechanisms for reliably zeroizing memory. Secrets or partial secrets frequently
18- remain in memory even after garbage collection cycles complete.
13+ gets dropped
14+ [ 1] ( https://github.com/bitwarden/sdk-internal/blob/4591981820f12a24e64609fb0a9fd4fdaabbb216/crates/bitwarden-crypto/src/lib.rs#L13 ) .
15+ This hardens the SDK, and the Rust desktop module (desktop native) against memory being left behind.
16+ Process reload wipes the entire process - on the web app by reloading the page, on browser
17+ extensions by reloading the extension, and on desktop by force-crashing the renderer process
18+ [ 2] ( https://github.com/bitwarden/clients/blob/16e67566436ae7becbea85f900656c437204824b/libs/common/src/key-management/services/default-process-reload.service.ts#L22 ) .
19+ The assumption here is that since the process dies, the memory gets wiped too. JavaScript does not
20+ provide mechanisms for reliably zeroizing memory. Secrets or partial secrets frequently remain in
21+ memory even after garbage collection cycles complete.
1922
2023## Process isolation and key protection on desktop apps
2124
@@ -24,18 +27,33 @@ There are two mechanisms used here: Process isolation and key protection. Proces
2427OS-level features to isolate the process from debugger access. Windows and desktop Linux by default
2528allow user-space processes to debug other user-space processes and read memory. MacOS does not allow
2629this by default and requires user consent to allow a process to debug another process. On Linux,
27- some distributions such as Ubuntu use yama.ptrace_scope to limit ptrace access.
30+ some distributions such as Ubuntu use
31+ [ yama.ptrace_scope] ( https://www.kernel.org/doc/Documentation/security/Yama.txt ) to limit ptrace
32+ access.
2833
2934To harden against user-space memory attacks, Bitwarden desktop isolates the main process. On
30- Windows, ` DACL ` is used to restrict access to the process, on Linux ` PR_SET_DUMPABLE ` is used to
35+ Windows, [ ` DACL ` ] ( https://learn.microsoft.com/en-us/windows/win32/secauthz/dacls-and-aces ) is used
36+ to restrict access to the process, on Linux
37+ [ ` PR_SET_DUMPABLE ` ] ( https://man7.org/linux/man-pages/man2/pr_set_dumpable.2const.html ) is used to
3138disable ptrace access and on MacOS the process is hardened using the Hardened Runtime entitlements,
3239and also by using ` PT_DENY_ATTACH ` to prevent debugger attachment. On Linux, a dynamic library that
33- sets ` PR_SET_DUMPABLE ` is also injected into the renderer processes, so that these are isolated too.
34- These mechanisms apply to all apps except for the Snap desktop app. Snap does not support
35- ` PR_SET_DUMPABLE ` currently and breaks file picker support, due to a bug in the desktop portal.
40+ sets [ ` PR_SET_DUMPABLE ` ] ( https://man7.org/linux/man-pages/man2/pr_set_dumpable.2const.html ) is also
41+ injected into the renderer processes by injecting a shared object into the renderer processes
42+ [ 3] ( https://github.com/bitwarden/clients/blob/16e67566436ae7becbea85f900656c437204824b/apps/desktop/desktop_native/process_isolation/src/lib.rs ) ,
43+ so that these are isolated too. These mechanisms apply to all apps except for the Snap desktop app.
44+ Snap does not support
45+ [ ` PR_SET_DUMPABLE ` ] ( https://man7.org/linux/man-pages/man2/pr_set_dumpable.2const.html ) currently and
46+ breaks file picker support, due to a [ bug] ( https://github.com/flatpak/xdg-desktop-portal/issues/785 )
47+ in the desktop portal.
3648
3749Next to hardening the entire process, operating systems offer mechanisms to protect cryptographic
38- keys in memory. On Windows, ` DPAPI ` can be used to encrypt a key in memory, with a key bound to the
39- process. On Linux, ` memfd_secret ` and ` keyctl ` are available, each of which can be used to store
40- keys in memory while preventing other processes from reading them. This is used to hold the
41- biometric unlock key in memory while the desktop app is locked.
50+ keys in memory. On Windows,
51+ [ ` DPAPI ` ] ( https://learn.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptprotectmemory ) can
52+ be used to encrypt a key in memory, with a key bound to the process. On Linux,
53+ [ ` memfd_secret ` ] ( https://man7.org/linux/man-pages/man2/memfd_secret.2.html ) and
54+ [ ` keyctl ` ] ( https://man7.org/linux/man-pages/man1/keyctl.1.html ) are available, each of which can be
55+ used to store keys in memory while preventing other processes from reading them. This is used to
56+ hold the biometric unlock key in memory while the desktop app is locked. Access to this protected
57+ memory is available via the
58+ [ ` EncryptedMemoryStore ` ] ( https://github.com/bitwarden/clients/blob/16e67566436ae7becbea85f900656c437204824b/apps/desktop/desktop_native/core/src/secure_memory/encrypted_memory_store.rs#L16 )
59+ abstraction that automatically uses the correct memory protection.
0 commit comments