This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] malloc/malloc.c: Mitigate null-byte overflow attacks
- From: Moritz Eckert <m dot eckert at cs dot ucsb dot edu>
- To: Florian Weimer <fweimer at redhat dot com>, DJ Delorie <dj at redhat dot com>
- Cc: libc-alpha at sourceware dot org, scarybeasts at gmail dot com
- Date: Fri, 3 Nov 2017 14:56:33 -0700
- Subject: Re: [PATCH] malloc/malloc.c: Mitigate null-byte overflow attacks
- Authentication-results: sourceware.org; auth=none
- References: <xn4lqp4laq.fsf@greed.delorie.com> <82d1760e-ef0f-9f0f-57be-3848f2b8d0ad@cs.ucsb.edu> <692369cd-e44d-e8b4-4dd2-95d188113658@redhat.com> <6a8f115d-41bd-114c-0a92-e543ef9ac8de@cs.ucsb.edu> <1103164033.27274244.1509731042658.JavaMail.zimbra@redhat.com> <451a7502-0209-c2c7-da92-f7c747425808@redhat.com>
Alternately, a simple XOR with a magic number means a set-to-zero
would un-XOR to a horribly wrong new "size". Even a fixed magic
number would increase hackability significantly, although a
per-process one would be better (and more expensive to do at runtime,
unfortunately).
See my old heap protector patches. You could probably swap in bswap in
place of the encryption, and it will just work.
Where do I find those patches?
Heck, even ~size would be interesting to ponder. The question is,
which operations will break-in attempts have access to?
Most overflows are more than just a single NUL byte, unfortunately.
This will, of course, further break dumped heaps, like emacs, but
hopefully we're past that by now.
Actually, that's not a problem. I think my heap protector patch simply
rewrites the dumped chunk headers into the appropriate format.
I will likely be busy with ABI-impacting work for many months to come,
so I won't finish the heap protector patches anytime soon.
I would be interested to take a look at those heap protector patches!
This seems to be promising!
But as of now, regarding my proposed patch, it would prevent the
Poison-Null-Byte attack immediately and with no performance impact,
which seems like a good solution until the heap protector is ready.
Thanks,
Moritz