Coder Social home page Coder Social logo

wsp-lab / hiddencpg Goto Github PK

View Code? Open in Web Editor NEW
32.0 3.0 3.0 4.82 MB

HiddenCPG: Large-Scale Vulnerable Clone Detection Using Subgraph Isomorphism of Code Property Graphs

Python 69.72% Shell 0.09% Makefile 0.10% Batchfile 0.09% Groovy 0.89% HTML 1.63% CSS 0.05% JavaScript 0.07% ANTLR 0.22% Java 25.93% C 0.12% PHP 1.09% C++ 0.01%
clone-detection subgrpah-isomorphism

hiddencpg's Introduction

HiddenCPG

HiddenCPG is a vulnerable clone detection system using code property graph (CPG) for uncovering various web vulnerabilities. HiddenCPG is capable of detecting unknown web vulnerabilities that stem from the absence of input sanitization and incorrect sanitization. The details of the testing strategy is in our paper, "HiddenCPG: Large-Scale Vulnerable Clone Detection Using Subgraph Isomorphism of Code Property Graphs", which appeared in WWW 2022. To see how to configure and execute HiddenCPG, see the followings.

Setup

Install

  1. Install dependencies
$ pip install pickle
$ pip install json
$ pip install networkx
$ pip install operator
$ pip install copy
$ pip install signal
$ pip install github
  1. Clone HiddenCPG
$ git clone https://github.com/WSP-LAB/HiddenCPG.git
  1. Install joern and phpjoern
  • Build joern and make sure that php2ast is working correctly.
  • Build phpjoern and make sure that phpast2cpg is working correctly.

Usage

System CPG

  • To convert the target applications to CPG, use the following command:
$ python2 mkcpg.py [Root directory of target PHP code] [Output directory]

CPG query

  • First, convert the vulnerable application into a CPG.
$ pytho2 mkcpg.py [Root directory of vulnerable PHP code] [Output directory]
  • Then, extract the CPG query by specifying the location of the sink and source in the command (Here, the sink and source locations refer to the node number of the top level statement visited by the control flow edge among the AST nodes).
$ python2 Extractor.py [CPG directory] [Source node] [Sink node] [Path number] [Output directory]

Note that an extracted query is stored using python pickle.

HiddenCPG

  • You need two directories: the directory where the system CPGs are collected and the directory where the CPG queries are collected.
SystemCPG
│
└───application1
│   │   cpg_edges.csv
│   │   nodes.csv
│   │   rels.csv
│
└───application2
    │   cpg_edges.csv
    │   nodes.csv
    │   rels.csv

CPGQuery
│
└───query1
│
└───query2
  • Execute HiddenCPG
$ cd hiddencpg
$ python2 hiddencpg.py [SystemCPG] [CPGQuery] [Log name]

Logs are written to each systemCPG directory. When HiddenCPG finds a bug, it records which node is mapped to which node in the log.

Dataset

  • Crwaler
$ cd dataset
$ python2 crawler.py [Github token]
  • Cloning dataset
$ python2 clone [Output directory]

Authors

This research project has been conducted by WSP Lab at KAIST.

Citing HiddenCPG

To cite our paper:

@INPROCEEDINGS{wi:www:2022,
    author = {Wi, Seongil and Woo, Sijae and Whang, Joyce Jiyoung and Son, Sooel},
    title = {{HiddenCPG}: Large-Scale Vulnerable Clone Detection Using Subgraph Isomorphism of Code Property Graphs},
    booktitle = {Proceedings of the {ACM} Web Conference},
    year = 2022,
    pages = {755--766}
}

hiddencpg's People

Contributors

seongil-wi 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

Watchers

 avatar  avatar  avatar

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.