Giter Club home page Giter Club logo

slimguard's Introduction

SlimGuard: A Secure and Memory-Efficient Heap Allocator

SlimGuard is a secure dynamic memory allocator whose design is driven by memory efficiency. We redesign the security features of state-of-the-art allocators with memory efficiency in mind. SlimGuard protects against widespread heap-related attacks such as overflows, over-reads, double/invalid free, and use-after-free. Among other features, SlimGuard uses an efficient fine-grain size classes indexing mechanism and implements a novel dynamic canary scheme optimized for memory overhead reduction.

Build SlimGuard

SlimGuard can be built on most modern Linux distributions and has been tested on Ubuntu 18.04 and Debian 10.

To build SlimGuard, run make in /path/to/libSlimGuard

To use SlimGuard, you can

  1. link libSlimGuard to your executable

  2. setting LD_PRELOAD as an enviromment variable using

export LD_PRELOAD=/path/to/libSlimGuard.so
  1. simply run as
LD_PRELOAD=/path/to/libSlimGuard.so /your/app

Tests

For this use cmake:

mkdir build
cd build
cmake ..
make
make test

slimguard's People

Contributors

bcliu430 avatar jvoisin avatar olivierpierre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

slimguard's Issues

Mimalloc fails to run

Mimalloc's test-stress is a multi-threaded microbenchmark for memory allocators. Its default configuration fails to run with SlimGuard. To reproduce the issue, see the make run target here:

make run
gcc -g test-stress.c -o test-stress -lpthread
LD_PRELOAD=/home/pierre/Desktop/SlimGuard/test/mimalloc/../../libSlimGuard.so ./test-stress
Using 32 threads with a 10% load-per-thread and 50 iterations
- iterations left:  40
- iterations left:  30
- iterations left:  20
Segmentation fault
make: *** [Makefile:13: run] Error 139

Update for glibc 2.34+ : __malloc_hook / ... deprecated and no longer usable

I use glibc 2.35 on my system, and i can't compile libSlimGuard, because of the symbols used in src/gnuwrapper.cpp.
These symbols (__malloc_hook, etc) are not found by my compiler, because they have been removed from glibc.

From glibc 2.34 log :

  • The deprecated memory allocation hooks __malloc_hook, __realloc_hook,
    __memalign_hook and __free_hook are now removed from the API. Compatibility
    symbols are present to support legacy programs but new applications can no
    longer link to these symbols. These hooks no longer have any effect on glibc
    functionality. The malloc debugging DSO libc_malloc_debug.so currently
    supports hooks and can be preloaded to get this functionality back for older
    programs. However this is a transitional measure and may be removed in a
    future release of the GNU C Library. Users may port away from these hooks by
    writing and preloading their own malloc interposition library.

Just wanted to let you know

Cannot allocate class N data area

On a CentOS Linux release 7.8.2003 (Core), I'm experiencing the following error with any binary when trying to use SlimGuard:
ls: mmap(8589934592): Cannot allocate memory
ls: Cannot allocate class 3 data area

As a matter of fact, this is experienced using the simplest mode:
LD_PRELOAD=/path/to/libSlimGuard.so /your/app

The class number depends on the binary used:
cat: mmap(8589934592): Cannot allocate memory
cat: Cannot allocate class 1 data area

a.out: mmap(8589934592): Cannot allocate memory
a.out: Cannot allocate class 162 data area

Insufficient check for invalid free

We (I and @ironore15) According to our evaluation, SlimGuard's invalid check is insufficient.
Is it bug? or just design issue?

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <malloc.h>

void* p[256];
uintptr_t buf[256];

int main() {
  buf[119] = 48;
  fprintf(stderr, "%p\n", buf[121]);
  free(&buf[120]);
  fprintf(stderr, "%p\n", buf[121]);
}
LD_PRELOAD=$(pwd)/libSlimGuard.so ./poc
(nil)
0x7fda100008d0

Best,
Insu Yun.

Missing error handling for a large allocation

Hi.

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <malloc.h>

void* p[256];
uintptr_t buf[256];

int main() {
  p[0] = malloc(-8);
  fprintf(stderr, "%p\n", p[0]);
}

This program will crash if we run it with SlimGuard.
The reason is that SlimGuard checks mark_used without validating the return value from previous call, which could be zero( https://github.com/ssrg-vt/SlimGuard/blob/master/src/slimguard.c#L409)

Best,
Insu Yun.

The values in the free list seem to be predictable

I am trying to understand the behaviour of Slimguard during the memory allocations and freeing, but something seems strange. When I requested addresses with a malloc call, for instance 10 of them, and freed them juste after (whatever value I put inside, and having some values used before so that the memory page is not release with madvise), the 10 next addresses given by malloc seemed to be exactly the same.

In the sources, at this line, if I am not mistaken the if is true if there are at least 2 values in the free list (head and next of the head not null). Therefore when calling for memory, if the list is composed of 10 previously freed addresses (by this line) then 10 of them are returned in the inverted order of their freeing. I read your research-article of this library and it doesn't exactly suggests the same implementation of the free list, with in the implementation a bucket where we take random values from and a free list where the newly freed values are without randomization. Did I misunderstand the implementation/objective or is there really a problem of use-after-free possibilities ?

Malloc-test fails to run with large sizes

See the make run target here:

make run
gcc -g malloc-test.c -o malloc-test -lpthread
LD_PRELOAD=/home/pierre/Desktop/SlimGuard/test/malloc-test/../../libSlimGuard.so ./malloc-test 100000 1048576
Segmentation fault
make: *** [Makefile:13: run] Error 139

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.