Hardened Malloc

From Whonix


Hardened Malloc is a hardened memory allocator which can be used with many applications to increase security.

According to the author's GitHub description: [1]

This is a security-focused general purpose memory allocator providing the malloc API along with various extensions. It provides substantial hardening against heap corruption vulnerabilities. The security-focused design also leads to much less metadata overhead and memory waste from fragmentation than a more traditional allocator design. It aims to provide decent overall performance with a focus on long-term performance and memory usage rather than allocator micro-benchmarks. It offers scalability via a configurable number of entirely independently arenas, with the internal locking within arenas further divided up per size class.

Readers who wish to discuss the integration of Hardened Malloc with Whonix should refer to this forum thread.


Hardened Malloc is available from the Whonix and Kicksecure APT repository. [2] Users of these Linux distributions can install it easily with the following instructions.

Users of Debian (-based) Linux distributions other than Whonix or Kicksecure need to first add the Whonix APT repository, which is documented on the Whonix Packages for Debian Hosts wiki page. For other distributions, refer to the Hardened Malloc Manual Installation instructions.

Update the package lists.

sudo apt-get update

Upgrade the system.

sudo apt-get dist-upgrade

Install the hardened-malloc package.

sudo apt-get install hardened-malloc

The procedure is complete.

How-to: Launch Applications with Hardened Malloc[edit]

Systemd Services[edit]

To launch individual systemd services with hardened malloc, add a drop-in systemd configuration snippet.


Other Applications[edit]

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.

LD_PRELOAD='/usr/lib/' application-name

All Applications by Default[edit]

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 library must be added to the /etc/ file.

1. Open file /etc/ in an editor with root rights.

(Qubes-Whonix ™: In TemplateVM)

This box uses sudoedit for better security. This is an example. Other tools could archive the same goal too. If this example does not work for you or if you are not using Whonix, please see this link.

sudoedit /etc/

2. Add the library.


3. Save the file.

The procedure is complete.

Incompatible Applications[edit]


Using Hardened Malloc with Tor Browser, Firefox or SecBrowser ™ is difficult, unsupported. [3]

If other browsers can benefit from Hardened Malloc is unknown.


Other applications might not easily benefit from Hardened Malloc for the same reason as some browsers are unsupported as documented above.

If an application can benefit from Hardened Malloc or not depends on technical implementation details of the application in question. Vendors of applications will probably know if their application is compatible Hardened Malloc. Consider asking them. Then please post a link to the question and answer here.

Credits and Source Code[edit]

The original source software is maintained by security researcher, Daniel Micay.

This website is the software fork homepage for Hardened Malloc, with a focus on easy installation, added user documentation, and integration with Whonix, Kicksecure, Debian, and other distributions. The Whonix software fork source code can be found here.


  3. These browsers are all based on Firefox, therefore the following applies equally to each of them.

    LD_PRELOAD='/path/to/' /path/to/program will do nothing or approximately nothing.

    Requires recompilation.

    To successfully replace Firefox memory allocator you should either use LD_PRELOAD _with_ a --disable-jemalloc build OR Firefox's replace_malloc functionality:


No user support in comments. See Support. Comments will be deleted after some time. Specifically after comments have been addressed in form of wiki enhancements. See Wiki Comments Policy.

Anonymous user #1

22 days ago
Score 0 You

Hey, thanks for the great work!

Just a question:

if I wanted to use the Hardened Malloc in conjunction with Firejail and Chromium, would this be the right command ?

LD_PRELOAD='/usr/lib/' firejail chromium


21 days ago
Score 0++

Better ask upstream.



21 days ago
Score 0++
Also... I am not saying Chromium is compatible with Hardened Malloc or not. I don't know. For more details see Hardened_Malloc#Incompatible_Applications which was written just now.


8 days ago
Score 0++

No, Chromium uses it's own memory allocator called PartitionAlloc and can't be changed with just LD_PRELOAD.

It's also better to run

"firejail --env=LD_PRELOAD='/usr/lib/' application-name"

Anonymous user #1

21 days ago
Score 0 You
Ok, Thx !
Add your comment
Whonix welcomes all comments. If you do not want to be anonymous, register or log in. It is free.

Random News:

Interested in becoming an author for the Whonix News Blog or writing about anonymity, privacy and security? Please get in touch!

https | (forcing) onion

Follow: Twitter | Facebook | | Stay Tuned | Whonix News

Share: Twitter | Facebook

This is a wiki. Want to improve this page? Help is welcome and volunteer contributions are happily considered! Read, understand and agree to Conditions for Contributions to Whonix ™, then Edit! Edits are held for moderation.

Copyright (C) 2012 - 2019 ENCRYPTED SUPPORT LP. Whonix ™ is a trademark. Whonix ™ is a licensee of the Open Invention Network. Unless otherwise noted, the content of this page is copyrighted and licensed under the same Freedom Software license as Whonix ™ itself. (Why?)

Whonix ™ is a derivative of and not affiliated with Debian. Debian is a registered trademark owned by Software in the Public Interest, Inc.

Whonix ™ is produced independently from the Tor® anonymity software and carries no guarantee from The Tor Project about quality, suitability or anything else.

By using our website, you acknowledge that you have read, understood and agreed to our Privacy Policy, Cookie Policy, Terms of Service, and E-Sign Consent. Whonix ™ is provided by ENCRYPTED SUPPORT LP. See Imprint.