Look into Hardened Malloc first.
Install Hardened Malloc
Users of Linux distributions that are not based on Debian must compile Hardened Malloc from source.  To do this, it is necessary to install g++ for compilation.
1. Update the package lists.
git to clone the repository.
3. The following block explains how to download and signature verify hardened malloc.
While git is cryptographically secure, it is not foolproof. See Web of Trust and How safe are signed git tags? Only as safe as SHA-1 or somehow safer? for further information.
Run the following commands in a terminal to download and verify the signing key and source code.
Retrieve the signing key. 
Verify the key fingerprint.
gpg: WARNING: no command supplied. Trying to guess what you mean ...
pub rsa4096/F9E712E59AF5F22A 2012-12-06 [SC]
Key fingerprint = 65EE FE02 2108 E2B7 08CB FCF7 F9E7 12E5 9AF5 F22A
uid Daniel Micay <firstname.lastname@example.org>
uid Daniel Micay <email@example.com>
uid Daniel Micay <firstname.lastname@example.org>
uid Daniel Micay <email@example.com>
uid Daniel Micay <firstname.lastname@example.org>
sub rsa4096/7363D2F61FDC8A7F 2012-12-06 [E]
Import the key.
Get the source code.
Navigate to the
Always verify software signatures! Check the hardened malloc signature.
type commit tag 8 tagger Daniel Micay <email@example.com> 1562939118 -0400
8 gpg: Signature made Fri 12 Jul 2019 09:45:21 AM EDT gpg: using RSA key 65EEFE022108E2B708CBFCF7F9E712E59AF5F22A gpg: issuer "firstname.lastname@example.org" gpg: Good signature from "Daniel Micay <email@example.com>" [unknown] gpg: aka "Daniel Micay <firstname.lastname@example.org>" [unknown] gpg: aka "Daniel Micay <email@example.com>" [unknown] gpg: aka "Daniel Micay <firstname.lastname@example.org>" [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 65EE FE02 2108 E2B7 08CB FCF7 F9E7 12E5 9AF5 F22A
4. Checkout the tag.
5. Build the program.
This will only take a few seconds, depending on your system's resources.
6. Move the hardened_malloc library to the system library folder
Move the library.
How-to: Launch Applications with Hardened Malloc
To launch individual systemd services with hardened malloc, add drop a systemd configuration snippet.
To launch other applications with Hardened Malloc, the
LD_PRELOAD environment variable must be edited before starting the application. For example, to launch
application-name in this way, run.
All Applications by Default
Note: This action may break numerous applications such as man, apt or Xorg.
It is possible to make all applications use Hardened Malloc as the default memory allocator. To configure this option, the path to the
hardened_malloc.so library must be added to the
/etc/ld.so.preload in an editor with root rights.
(Kicksecure ™ inside Qubes: In Template)
This box uses
sudoedit for better security. This is an example and other tools could also achieve the same goal. If this example does not work for you or if you are not using Kicksecure ™, please refer to this link.
2. Add the
3. Save the file.
The procedure is complete.
- Hardened Malloc is available form the Kicksecure ™ APT repository for Debian-based distributions.
- https://grapheneos.org/install https://github.com/GrapheneOS/hardened_malloc/issues/82