
A variant analysis and visualisation tool that scans codebases for similar vulnerabilities
![]()
C0deVari4nt is a variant analysis and visualisation tool that inspects codebases for similar vulnerabilities. It leverages CodeQL, a semantic code analysis engine, to query code based on user-controlled CodeQL query templates and passes the results to our client interface built with vis.js and React for further exploration and visualisation. This enables quick and comprehensive variant analysis based on previous vulnerability reports. The vis.js visualisation feature provides additional insight for developers into vulnerable code paths and allows them to effectively triage potential variants.

The Log4Shell incident in December 2021 highlighted the difficulties open-source developers face in responding to vulnerability reports. After the initial patch for CVE-2021-44228, which allowed unauthenticated remote attackers to take control of devices running vulnerable versions of Log4j 2, Apache released 3 additional patches to address related vulnerabilities and unmitigated edge cases.
Open-source developers often lack training in comprehensive code review and face problems in identifying variants of a vulnerability, leading to incomplete patches. Although CodeQL query suites exist to facilitate quick analysis of the codebase, the results returned from these suites may result in significant false positive rates. Furthermore, these suites rely on predefined queries which do not support variant analysis and are not customised for individual codebases. As such, open-source projects often respond to vulnerability reports in a piecemeal manner that misses potential variants.
C0deVari4nt provides a platform for developers to easily conduct variant analysis without the significant overhead of writing their own CodeQL queries. This gives developers the flexibility to customise CodeQL templates by providing codebase-specific information such as a particular source and sink of a vulnerability. The results will be visualised in a graph database view powered by vis.js for developers to quickly identify potential variants. As such, developers will be able to effectively address entire classes of bugs from a single vulnerability report.
C0deVari4nt is built using python, CodeQL, vis.js and React to create an interactive GUI application to take user input and showcase relationships between different vulnerable code paths.

C0deVari4nt consists of the following 2 main components:
More details of the client interface can be seen below:

dbextractor.py <codeql db zip file> to unzip the codeql database contentspip install -r requirements.txtuvicorn main:app --reload to start local developmental server on port 8000npm inpm start to start local developmental server
strcat functions without bound checks on the source argumentstrncpy functions without bound checks on the source argumentsnprintf
malloc, calloc or realloc without sufficient memory allocated to contain an instance of the type of the pointerisAdditionalTaintStep method to transfer taints between 2 disconnected functionsisAdditionalTaintStep method to transfer taints between pointers which have the same values at runtimeThe following depicts the CodeQL results for a query with recvfrom as a source, mempool_alloc as an additional taint step and memcpy as a sink:

This result yields a total of 180 nodes in 27 different code paths. The results are portrayed in a simple neo4j interface below:

By putting this query through our tool, we were able to identify duplicate occurrences of each node, source and sink and merge the relationships of the nodes.
This resulted in a significantly cleaner graph with a total of 11 unique nodes while still retaining all 27 unique code paths:

The results can be further categorised into their respective paths through our path labelling feature:

