Skip to content

Improve resilience against memory attacks#2805

Closed
droidmonkey wants to merge 1 commit intorelease/2.4.1from
feature/memory-protection-v2
Closed

Improve resilience against memory attacks#2805
droidmonkey wants to merge 1 commit intorelease/2.4.1from
feature/memory-protection-v2

Conversation

@droidmonkey
Copy link
Copy Markdown
Member

Type of change

  • ✅ New feature (non-breaking change which adds functionality)

Description and Context

To reduce residual fragments of secret data in memory after
deallocation, this patch replaces the global delete operator with a
version that zeros out previously allocated memory. It makes use of
the new C++14 sized deallocation, but provides an unsized fallback
with platform-specific size deductions.

This change is only a minor mitigation and cannot protect against
buffer reallocations by the operating system or non-C++ libraries.
Thus, we still cannot guarantee all memory to be wiped after free.

As a further improvement, this patch uses libgcrypt to write
long-lived master key component hashes into a secure memory area
and wipe it afterwards.

Finally, it ensures that all password form fields are cleared when
they are not in use anymore and fixes a bug where removing a component
from the master key would not mark the database as dirty.

Testing strategy

Incorporating into 2.4.1 to allow beta testers to test on many different machines.

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]
  • ✅ My change requires a change to the documentation, and I have updated it accordingly.
  • ✅ I have added tests to cover my changes.

@droidmonkey droidmonkey added this to the v2.4.1 milestone Mar 20, 2019
@droidmonkey droidmonkey requested a review from phoerious March 20, 2019 00:10
@droidmonkey droidmonkey force-pushed the feature/memory-protection-v2 branch 3 times, most recently from 16d8cec to cff6f0f Compare March 24, 2019 15:01
@droidmonkey droidmonkey modified the milestones: v2.4.1, v2.4.2 Mar 26, 2019
@droidmonkey
Copy link
Copy Markdown
Member Author

punt!

@ghost
Copy link
Copy Markdown

ghost commented Apr 3, 2019

Would it be helpful (until then/after that) to enable memory page sanitation on the linux kernel (CONFIG_PAGE_POISONING)?

@phoerious phoerious force-pushed the feature/memory-protection-v2 branch from cff6f0f to 8fbefdf Compare April 12, 2019 19:41
To reduce residual fragments of secret data in memory after
deallocation, this patch replaces the global delete operator with a
version that zeros out previously allocated memory. It makes use of
the new C++14 sized deallocation, but provides an unsized fallback
with platform-specific size deductions.

This change is only a minor mitigation and cannot protect against
buffer reallocations by the operating system or non-C++ libraries.
Thus, we still cannot guarantee all memory to be wiped after free.

As a further improvement, this patch uses libgcrypt and libsodium
to write long-lived master key component hashes into a secure
memory area and wipe it afterwards.
@phoerious phoerious force-pushed the feature/memory-protection-v2 branch from 8fbefdf to cb00281 Compare April 12, 2019 20:23
@droidmonkey droidmonkey removed this from the v2.4.2 milestone Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants