Code Monkey home page Code Monkey logo

sslab-gatech / apisan Goto Github PK

View Code? Open in Web Editor NEW
60.0 17.0 27.0 34.83 MB

APISan: Sanitizing API Usages through Semantic Cross-Checking

License: MIT License

Python 0.65% AngelScript 0.03% Shell 0.09% CMake 0.26% Makefile 0.28% M4 0.06% Go 0.08% C++ 51.75% OCaml 0.25% CSS 0.02% Batchfile 0.02% Roff 0.02% C 19.67% NASL 0.01% Assembly 4.72% Objective-C++ 0.88% Objective-C 2.72% HTML 0.69% LLVM 17.79% Cuda 0.02%
api-misuse cross-checkig static-analysis symbolic-execution

apisan's Introduction

APISan: Sanitizing API Usages through Semantic Cross-Checking

APISAN is a tool that automatically infers correct API usages from source code without manual effort. The key idea in APISAN is to extract likely correct usage patterns in four different aspects (e.g., causal relation, and semantic relation on arguments) by considering semantic constraints. APISAN is tailored to check various properties with security implications. We applied APISAN to 92 million lines of code, including Linux Kernel, and OpenSSL, found 76 previously unknown bugs, and provided patches for all the bugs.

This repository has analysis tool and LLVM. LLVM related files follow their own license(LICENSE.LLVM), and analysis tool is provided under the terms of the MIT license.

How to use

  • Tested in Ubuntu 14.04
  • Setup
  $ ./setup.sh
  • How to build symbolic database
  $ apisan build [cmds]
  • Run './configure'
  $ apisan build ./configure
  $ apisan build make
  • How to run a checker
  $ apisan check --db=[db] --checker=[checker]
  • Example
  $ cd test/return-value
  $ ../../apisan build make
  $ ../../apisan check --checker=rvchk

Checkers (under analyzer/apisan/check)

  • Return value checker: retval.py
  • Argument checker: argument.py
  • Causality checker: causality.py
  • Condition checker: condition.py
  • Integer overflow checker: intovfl.py
  • Format string bug checker: fsb.py

Authors

Publications

@inproceedings{yun:apisan,
  title        = {{APISan: Sanitizing API Usages through Semantic Cross-checking}},
  author       = {Insu Yun and Changwoo Min and Xujie Si and Yeongjin Jang and Taesoo Kim and Mayur Naik},
  booktitle    = {Proceedings of the 25th USENIX Security Symposium (Security)},
  month        = aug,
  year         = 2016,
  address      = {Austin, TX},
}

apisan's People

Contributors

insuyun avatar seungjunn 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apisan's Issues

High memory usage

Hi,
I tried to apply apisan on qemu, but when I built the qemu using apisan build make, it used all of my 64GB memory and 200GB of the 256GB swap and stopped running. Is it common? What should I do?
Thanks

Traces generated by symbolic execution

Hi,

After reading the paper, I like your job actually. However, during the process of reading source code, I have met several confusions.

  • First: where are the traces after symbolic execution? If convenient, would you mind saying its address in source code?

  • Second: Where are the functions mentioned in the paper, such as returnValueContexts, argRelationContexts? I couldn't find them in source code. If convenient, would you mind saying its address?

  • Third: Apisan is implement on the basis of clang and llvm. If convenient, would you mind saying the changes you've made on the framework?

Sincerely,
Liz

Unrolling a loop

Hi Jakkdu!
your paper refers that APISAN unrolls each loop only once.
Now, I want to know where you changed it so that it only loops once.
Can you help me? Thank you!

False positive in alias analyze of cpair

Hi jakkdu. It seems like apisan doesn't support alias analyze of cpair checker. Consider the following code:

#include <stdio.h>
void good1(){
  int* a=(int*)malloc(sizeof(int));
  // do something...
  free(a);
}
// other similar malloc-free pattern omitted...
void goodx(){
  int* a=(int*)malloc(sizeof(int));
  int* b=a;
  // do something...
  free(b);
}

Apisan makes complaints that malloc-free pattern in goodx is a potential bug.

Condition checker

I can't understand the algorithm of your condition checker. Can you please explain what you have done to find the bugs?

Return value checker can't detect flaw

Apisan rvchk can't detect the unchecked return value flaw in following code piece:
Note: the following code piece is modified from Juliet Test Suite

#include <stdio.h>

void bad()
{
    if(1)
    {
        /* FLAW: Do not check the return value */
        fprintf(stdout, "%s\n", "string");
    }
}

static void good1()
{
    if(0)
    {
        /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
        printf("Benign, fixed string");
    }
    else
    {
        /* FIX: check the return value */
        if (fprintf(stdout, "%s\n", "string") < 0)
        {
            printf("test string");
        }
    }
}

static void good2()
{
    if(1)
    {
        /* FIX: check the return value */
        if (fprintf(stdout, "%s\n", "string") < 0)
        {
            printf("test string");
        }
    }
}

void good()
{
    good1();
    good2();
    good1();
    good2();
    good1();
    good2();
    good1();
    good2();
    good1();
    good2();
}

int main(int argc, char * argv[])
{
    printf("Calling good()...");
    good();
    printf("Finished good()");
    printf("Calling bad()...");
    bad();
    printf("Finished bad()");
    return 0;
}

In theory the rvchk can detect the missing check of `fprintf` in `bad()`, but nothing was reported. Can you tell me am I missing something?
Appreciate your attention.

JW, ZG
IMChecker Group, THU

Semantic believes

Hi,
I checked the apisan code, but I couldn't find where you extract the semantic believes (as explained in your paper). Do you extract the semantic belief in your code or just check for the minor uses?
Thanks.

how to use instruction

Hi Jakkdu!
how to use apisan - -- checker= cpair - -- db =app1, app2
Should I put both apps in the same directory? Or just install them on my computer?

problem in build apisan

hello,
I could not understand what and where is SYM_EXEC_EXTRACTOR = "alpha.unix.SymExecExtract" in your code?
can you say some detail about it?

thank you

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.