text
stringlengths 64
2.99M
|
---|
as they have the potential to introduce vulnerabilities. E. Post-processing with LLM Assistance Following the identification of sensitive functions, we pro- ceed with argument backtracking analysis. The arguments Beyond the false positives that can be resolved through within these sensitive functions undergo further scrutiny to the dispatching rules of the framework, some false alarms ascertain whether they potentially harbor externally inputted persistthatcannotbebypassedsimplybyestablishingspecific dangerousvariables.Iftheoriginofthedatastreamisconstant rules. Considering the recent popularity of large language or independent of user input, it does not pose a vulnerability. models (LLMS) for code analysis [49], [50], we envision However, if the data stream is contingent on user input, a using LLMs to assist our analysis in the post-processing of taint propagation analysis is initiated to track the transmission generated alarms. Fortunately, there have been studies that of variables. The propagation analysis leverages Reaching have demonstrated the feasibility of this idea through small- Definitions Analysis, as discussed in §III-C. scale experiments [47]. We choose to use ChatGPT 4 because Sources. For LuCI framework, we also need to determine of its advanced language understanding capabilities and the the tainted source of the user’s input. Although the LuCI breadth of its knowledge coverage [48]. We summarize the framework encapsulates the HTTP protocol, we still need causes of false alarms and then use the latest GPT-4 model to identify the interfaces used by HTTP requests to deter- to analyze the alarms by elaborately constructing problems mine the source of the tainted vulnerability. Functions like for pruning false alarms. Figure 5 shows the workflow of luci.http.formvalue, for example, are potential entry post-processing with LLM assistance. We show an example points for untrusted data. of conversation for function evaluation using ChatGPT on the webpage2 to further understand the process. Sanitizers. Accurately defining the sanitizer function can reduce false alarms in the detection process. Typ- ical sanitizer functions in the LuCI framework are IV. IMPLEMENTATION luci.util.shellquote, which can safely quote values LuaTaint has been implemented with approximately 12,000 for use in shell commands. linesofPythoncode.Thesyntaxparsingmoduleisconstructed Framework-Adapted Module. To mitigate false positives using luaparser [28], a python-based Lua parser and abstract in static taint analysis, we integrate the LuCI framework’s syntax tree builder. The control flow analyzer systematically dispatching rules into the vulnerability validation process. In traverses all nodes based on their categories to establish a theModel-View-Controller(MVC)architecture,thecontroller comprehensive control flow graph. The reaching definitions module acts as the central hub for processing web applica- analyzer relies on reaching definitions worklist analysis and tion requests, receiving input data from web requests, and fixed-pointalgorithm,addressingdataflowconstraintsthrough transmitting this data to the model or view modules. Given iterative processes. The framework-adapted module is de- that LuCI adheres to the MVC framework, external input is signed to encapsulate the dispatching rules of various web predominantlysourcedfromthecontrollermodule.Therefore, intaintdetection,wedevelopamorestringentinputvalidation 2https://chat.openai.com/share/4689d438-6867-490d-ae8c-9d963323f17eIEEEINTERNETOFTHINGSJOURNAL,VOL.14,NO.8,AUGUST2021 8 frameworks, it plays a pivotal role in vulnerability verifica- TABLEI tion to mitigate false positives. The taint analyzer uses the EXISTINGCVELISTFORVERIFICATION. constraintrelationshipbetweennodestoconductbacktracking CVE-ID Vendor Series/Version Type Alarm? analysis based on the arguments of the sink functions, and during this process, it combines the dispatching rules of CVE-2017-16957 TP-Link WVR/WAR/ER/R CI True CVE-2017-16958 TP-Link WVR/WAR/ER/R CI True different web frameworks. CVE-2017-16959 TP-Link WVR/WAR/ER/R CI True Environment: All of the experiments are run on a separate CVE-2017-17757 TP-Link WVR/WAR/ER/R CI True CVE-2018-11481 TP-Link IPC RCE False virtual machine that hosts an Ubuntu 16.04 with AMD Ryzen CVE-2019-12272 OpenWrt LuCI0.10 CI True 75800HwithRadeonGraphics3.2GHzCPUwith16GRAM. CVE-2019-19117 Phicomm K2 CI True CVE-2021-28961 OpenWrt OpenWrt19.07 CI True CVE-2021-43162 Ruijie RG-EW RCE Encypto V. EVALUATION CVE-2022-28373 Verizon ODU RCE True CVE-2022-28374 Verizon ODU RCE True We’ve developed a series of research questions to guide our assessment of LuaTaint’s performance and efficiency in identifying vulnerabilities: Table I shows that most of the existing vulnerabilities RQ1: Is LuaTaint capable of detecting both manufactured related to the LuCI framework belong to CI and RCE vulner- vulnerabilities as well as those present in real-world IoT abilities. Notably, Ruijie’s firmware is encrypted, hindering devices? the ability to unpack and inspect the source code. The TP- RQ2: How effective is the framework-adapted module Link IPC series, designed for visual security through smart within LuaTaint, and how accurately can it prune false alarms cameras,includesavulnerability(CVE-2018-11481)allowing using Large Language Models (LLMs)? remote code execution. This particular vulnerability involves RQ3:WhatistheefficiencyofLuaTaint,andtowhatextent insufficiently strict restrictions in the string matching process can the approximation operation reduce overhead? ”p%”, which LuaTaint does not recognize as an alarm due to the absence of an executable function and a consequential |
RQ4:IncomparisontoexistingstaticanalysistoolsforLua, deficiency in the identification of a dangerous data flow. In how does LuaTaint fare in terms of performance on current addition to this, LuaTaint accurately identifies the remain- tasks? ing vulnerabilities associated with the provided CVE IDs as alarms. A. Vulnerabilities Detection After that, we collected 92 firmwares from 8 vendors for To explore RQ1, we initiated experimental validation using testing, including 8devices, Avalon, GL.iNet, Linksys, Net- manufactured and real-world vulnerabilities. Gear, TP-Link, Xiaomi and OpenWrt. They all contain web WeinitiallyassessedtheeffectivenessofLuaTaintbyexam- interfaces, as shown in Table II. For public firmware images, iningitsperformanceonmanufacturedvulnerabilities.Forthis we used popular tools to extract them, such as Binwalk [22]. purpose, we composed 10 distinct examples for each category From the extracted images, LuaTaint identifies web interface of known vulnerabilities, such as command injection, remote programs based on file directories and file types and performs code execution, SQL injection, and path traversal. These security analysis on them. examples were meticulously designed to encompass a variety In Table II, we classified a problem with the same func- of scenarios, incorporating diverse file handling functions and tion and same argument on different devices as one bug. modes of parameter propagation, to thoroughly demonstrate LuaTaintdetected112truealarms,andthereare78bugsafter the wide range of potential security vulnerabilities. Experi- deduplication without considering the vendors, 68 of which ments demonstrate that LuaTaint excels in detecting manufac- were previously unknown. Due to serious security concerns, turedvulnerabilities,achievingaccuracyratesashighas100%. we have reported defects to the developers of these device However, manufactured vulnerabilities are often simplified vendors. Eight of these bugs have been confirmed by the and separate from the system, while real-world vulnerabilities vendors as existing in older stable firmware versions, and are generally introduced unintentionally and integrated into the others are still being confirmed. These results show that complex systems, presenting more unpredictable challenges. LuaTaint can effectively find common vulnerabilities in the Consequently, we evaluated LuaTaint’s performance on web interface of embedded systems. real-world vulnerabilities, focusing on those related to the LuCI interface in recent years. Table I summarizes these It’s noteworthy that identical vulnerability codes are recur- vulnerabilities, detailing their CVE-ID, the affected vendor, rent across different firmware series from the same vendors. the device series or version, and the type of vulnerability. Additionally, some instances of the same vulnerability code These issues were found in the firmware of specific vendors’ are present in the firmware of diverse vendors. This phe- devices and earlier versions of the OpenWrt distribution, with nomenoncanbeattributedtothepracticewhereinsmartdevice CI (Command Injection) and RCE (Remote Code Execution) vendors, when utilizing OpenWrt, may neglect to conduct beingtheprimaryvulnerabilitytypes.ByleveragingLuaTaint, comprehensive security checks on the corresponding version. wewereabletoautomatethedetectionofthesevulnerabilities Consequently,vulnerabilitiesinherentintheoriginalOpenWrt and carry out an in-depth analysis of our findings. system persist in the smart devices of major vendors. InIEEEINTERNETOFTHINGSJOURNAL,VOL.14,NO.8,AUGUST2021 9 TABLEII TABLEIII DATASETANDRESULTSOFFIRMWARESUNDERTESTING. COMPARISONOFALARMANDFALSERATERESULTSONSOME FIRMWARES. Vendor Type # Bugs LeakyFW Vendor Device AlarmsB FPB FRB AlarmsA FPA FRA 8devices wirelessmodules 9 3 8 8devices Carambola2 4 1 25.00% 11 8 72.73% Avalon bitcoinminer 9 6 9 8devices Cherry 2 0 0% 9 7 77.78% GL.iNet router 18 7 4 Avalon Avalon2 15 10 66.67% 28 23 82.14% Avalon Avalon761 16 10 62.50% 36 30 83.33% Linksys router 2 22 2 GL.iNet MT300A 18 11 61.11% 42 35 83.33% NetGear router 3 22 2 Linksys EA8500-full 26 4 15.38% 35 13 37.14% TP-Link router 10 44 8 NetGear WNDR3700-V4 24 3 12.50% 33 12 36.36% TP-Link ArcherC2600 24 19 79.16% 39 34 87.18% Xiaomi router 21 1 1 TP-Link TL-WDR7300 4 1 25.00% 9 6 66.67% OpenWrt firmware 20 7 15 Xiaomi R1350 8 7 87.50% 22 21 95.45% Total / 92 112 51 OpenWrt lede-17.01.6 15 10 66.67% 28 23 82.14% Total / 156 76 48.72% 292 212 72.60% 1 ---TL-WAR450Lv1.bin /usr/lib/lua/luci/controller/admin/bridge.lua B. Evaluation of Accuracy Enhancements. 2 local function get_device_byif(iface) 3 local mycmd = ". /lib/zone/zone_api.sh; zone_get_device_byif" iface Wedesignedtwosetsofexperimentstoverifytheimpactof 4 local ff = io.popen(cmd, "r") current designs on the effectiveness of vulnerability detection 5 end 6 local function tophy(ifname) to answer RQ2. 7 local phy = {} 8 for k,v in ipairs(ifname) do Efficacy of Framework-Adapted Module. To assess the 9 phy[#phy + 1] = get_device_byif(v) efficacy of the framework-adapted module, we conducted 10 end 11 return phy comparative experiments by examining the results of taint 12 end propagation analysis with and without the framework-adapted 13 local function check_section_available(data, op) 14 local new = { } module. Table III presents statistical data on the number of |
15 new.t_name = data.t_name firmwarealarmsandthenumberoffalsealarmsunderthetwo 16 -- change the index of IF to name (total of 5 IFs) 17 new.ifname = tophy(new.t_bindif) experimental conditions. We use false rate (FR) to represent 18 end the ratio of the number of false alarms to the total number of 19 function add_br(http_form) 20 local data = json.decode(http_form.data) alarms. The three columns with B as the subscript represent 21 local jdata = data.params the results before using the framework adaptation module, 22 local input = jdata.new 23 if not input or type(input) ˜= "table" then and with A as the subscript represent the results after using 24 return false, err.ERR_COM_TABLE_ITEM_UCI_ADD the framework adaptation module. Given that there are often 25 end 26 new = check_section_available(input, "add") shared vulnerabilities among the same vendors of firmware, 27 end we selected firmware samples from various vendors to ensure Listing 2. Functions Related to CVE-2017-16958 in the WVR/WAR/ER/R a diverse representation. SeriesofTP-LinkFirmware. As shown in Table III, the framework-adapted module effectively filters most of the false alarms in the process of addition, some vulnerabilities have been repaired with the vulnerability verification, reducing the overall false alarm rate update of the OpenWrt system. from 72.60% to 48.72%, saving a lot of time and manpower for later vulnerability verification. For specific operations, we Case Study. In order to better understand the process of use the framework-adapted module to filter out tainted data LuaTaint, we use a specific case to show the vulnerabilities flows that meet the following requirements: Although these we have detected. In the firmware of the TP-Link data flows exist sources, sinks, and paths between them, (a) TL-WVR, after unpacking, we can find the function some functions of these alarms are called by other functions, get_device_byif() as shown in List 2 under the path the parameter value of the tainted source is constant, and (b) "/squashfs-root/usr/lib/lua/luci/controller/some function parameters are variables but cannot be injected admin/bridge.lua", where the API io.popen through the interface, so the attacker cannot define the value is injected. The popen parameter cmd is a string ". of these parameter variables. Therefore, it is not possible to /lib/zone/zone_api.sh; perform actual remote attacks from these data flows, so we zone_get_device_byif" and the variable iface use the framework-adapted module to filter these data flows spliced, so we need to further analyze the function that before the alarm through the features of the framework. In calls get_device_byif() until we backtrack to the addition, new rules of adaptor are available to extend when HTTP parameter requesting an external variable. The whole using LuaTaint to detect injection-type vulnerabilities in other call flow after injecting API parameters backtracking in frameworks. List 2 is get_device_byif() ←− tophy(ifname) Accuracy of LLMs Pruning.WealsotestedLLMsperfor- ←− check_section_available(data, op) ←− manceonaselectionoffirmwarefromvariousvendors.Table add_br(http_form). There is no external parameter IV shows the statistics of vulnerabilities found by LuaTaint in string filter here, so get_device someoftheabovefirmware.InTableIV,theAlarmsindicates _byif()isrecognizedasacommandexecutionvulnerability the number of alarms analyzed by LuaTaint, and T/F is the (CVE-2017-16958). number of true and false alarms after manual confirmation.IEEEINTERNETOFTHINGSJOURNAL,VOL.14,NO.8,AUGUST2021 10 TABLEIV TABLEV THERESULTSBEFOREANDAFTERLLMSPRUNING. THEOVERHEADSTATISTICSFORSOMEFIRMWARESWITHLUATAINT. Vendor DeviceSeries Alarms T/F TP/FN FP/TN PreB PreA Kinkan 3 0/3 0/0 1/2 0% 0% Vendor Device #Fun #Line TimeB MemB TimeA MemA Carambola2 4 3/1 3/0 0/1 75.00% 100% 8devices Carambola2 287 5875 13.47s 66.42MB 12.40s 54.64MB 8devices Cherry 2 2/0 2/0 0/0 100% 100% 8devices Cherry 266 5836 3.78s 45.13MB 3.31s 46.09MB Carambola3 4 3/1 3/0 0/1 75.00% 100% Avalon Avalon2 989 20801 236.15s 283.70MB 35.71s 104.98MB Avalon2 15 5/10 5/0 2/8 33.33% 71.43% Avalon Avalon761 1046 20069 319.75s 323.91MB 22.95s 99.15MB Avalon4 15 5/10 5/0 1/9 33.33% 83.33% GL.iNet MT300A 1109 21335 421.39s 370.47MB 25.90s 100.82MB Avalon Avalon741 15 5/10 5/0 1/9 33.33% 83.33% Linksys EA8500-full 1294 22653 209.43s 190.15MB 37.14s 109.79MB Avalon761 16 6/10 6/0 2/8 37.50 75.00%% NetGear WNDR3700-V4 1244 21305 152.99s 174.18MB 31.92s 110.00MB mt300a-2.265 18 7/11 7/0 1/10 38.89% 87.50% TP-Link ArcherC2600 1883 39427 - - 502.84s 416.41MB GL.iNet mt300n-2.265 18 7/11 7/0 1/10 38.89% 87.50% TP-Link TL-WDR7300 967 10369 467.54s 316.52MB 296.75s 162.05MB EA8500-full 26 22/4 22/0 0/4 84.62% 100% Xiaomi R1350 1457 30056 158.90s 272.49MB 55.44s 153.84MB Linksys EA8500 25 22/3 22/0 0/3 88.00% 100% OpenWrt lede-17.01.6 992 19533 388.64s 380.37MB 21.10s 97.05MB WNDR3700-V4-full 26 22/4 22/0 0/4 84.62% 91.67% NetGear WNDR3700-V4 24 21/3 21/0 0/3 87.50% 100% ArcherC2600 22 6/16 6/0 5/11 27.27% 54.55% TP-Link TL-WDR7300 4 3/1 3/0 0/1 75.00% 100% D. Comparison R1350 8 1/7 1/0 1/6 12.50% 50.00% Xiaomi |
R1cm 2 0/2 0/0 0/2 0% - lede-17.01.6 15 5/10 5/0 1/9 33.33% 83.33% For RQ4, we compared LuaTaint with some static analysis OpenWrt openwrt-19.07.9 2 2/0 2/0 0/0 100% 100% openwrt-21.02.1 0 0/0 0/0 0/0 - - tools for Lua. We found that the existing static code analysis Total / 264 147/117 147/0 16/101 54.89% 90.18% tools for Lua, such as LuaCheck [52]. LuaCheck is mainly used to detect common problems in Lua code such as syntax TP (true positive), TN (true negative), FP (false positive), and errors,codestyleproblems,unusedvariables,etc.Whilethese FN (false negative) indicate the result of comparing the label checks contribute to enhancing code quality and reducing obtained after the post-processing of these alarms with the errors, they lack a specific focus on the detection of security ground-truth. Due to the uncertainties generated by GPT-4, vulnerabilities. Hence, direct comparisons are inadvisable. all of these labels are tested five times, and the result is the Additionally, there are static security analysis tools that one with the higher confidence. Pre B and Pre A represent offer support for Lua, with TscanCode [53] being an example the precision of the alarms before and after post-processing, developedbyTencent.TscanCodeisastaticcodeanalysistool respectively. that covers multiple programming languages, including Lua. Inthisgroupofexperiments,wenotonlytestedfalsealarms While TscanCode is capable of identifying various types of but also tested true alarms. The experimental results show codeissues,includingsecurityvulnerabilities,ourexperiments that GPT-4’s performance of true alarms is relatively stable, revealedthatstaticanalysistoolsoftenrelyonspecificpatterns whichcanreach100%recall(totalTN=0).Theperformanceof or rules for vulnerability detection. The security concerns false alarms improves the precision from 54.89% to 90.18%, reported by TscanCode mainly address syntax or logic prob- effectively cutting a lot of false alarms. lemsduringcodeimplementationandcannoteffectivelydetect injection vulnerabilities embedded in firmware code. In our experiments, none of the vulnerabilities we found can be C. Overhead detected by TscanCode. We assessed the operational cost of a segment of the firmware,consideringboththeruntimeandmemoryconsump- VI. DISCUSSIONS tionoftheprocess,tovalidatetheeffectivenessofoptimization ofapproximateoperationforRQ3.Toavoidaccidentalerrors, While LuaTaint is effective in discovering vulnerabilities eachdataisexecutedtentimes,andtheaveragesarecomputed. in the web interface of IoT devices, there are still several ThestatisticaloutcomesarepresentedinTableV.#Fun,#Line shortcomings that highlight them as key opportunities for represent the number of functions and lines of code in LuCI; future work. Time and Mem represent the time and memory consumed by Scope of Vulnerability Types. Currently, the primary vul- the current firmware to complete an analysis; subscript B and nerabilities we have identified in firmware web interfaces are A represent before and after approximation operation. command injection and remote code execution. These vulner- We can see from the firmware results of the two devices of abilities are more prevalent, guiding our focus on defining 8devices that when the LuCI program is small in scale, our their specific trigger words. However, our existing analysis approximateoperationdoesnotplayanobviousrole.However, algorithm is also capable of addressing other vulnerabilities, when the LuCI program is large in scale and contains more such as cross-site scripting, SQL injection, and certain types functions,ourapproximateoperationcanreducetheexecution of sensitive information disclosure. To expand our scope to cost in the process of vulnerability detection, including the these types, we plan to define more key trigger words and reduction of running time and memory occupied by the correlative rules. process.Especially,whenthefirmwareoftheTP-LinkArcher LimitationsofAnalyticalMethods.Inthispaper,LuaTaint C2600deviceisdetectedbythemethodbeforeperformingthe primarily concentrates on the back-end of page handlers to approximation operation, it is stopped because the operation identify vulnerabilities in web interfaces, with limited anal- exceeded the set maximum recursion depth and the related ysis of front-end web information. The intricacies of data vulnerability could not be detected. After performing the interaction between the front-end and back-end often exhibit approximationoperation,theprogramcouldberunatalimited idiosyncratic and complex patterns, making it challenging to depth and generate the final related vulnerability report. distill specific patterns in the static analysis of a large volumeIEEEINTERNETOFTHINGSJOURNAL,VOL.14,NO.8,AUGUST2021 11 of objects. Despite this, for the issues LuaTaint detects, there todrivethewebinterfacetoautomaticallygenerateinitialseed is still potential to leverage user inputs from the front-end messages. It also proposes the weighted message parse tree to pageforfurtherconfirmation.Otherwise,wedidnotprioritize guide mutations and uses fuzzy testing technology to detect efficiency as a concern in this project. However, the data flow vulnerabilities. While the system has difficulty efficiently analysis of a large project will incur significant computational recognizinginteractivefeaturesonthevariedandcomplexweb overhead. More efficient data flow algorithms, such as sparse interfaces of IoT devices. dataflowanalysis[44],andincrementaldataflowanalysis[45] can be used to try to improve data flow analysis in follow-up work. VIII. CONCLUSION Integration of Post-processing. OpenAI has released an We present an automated system designed to detect vul- |
API for GPT-4 that allows developers and enterprises to nerabilities in the web interface frameworks of IoT devices. integrateitsadvancedlarge-scalelanguagemodelintoavariety The system starts by parsing web interface code using Lua of applications and services. After applying through the GPT- AST and creating control flow graphs. Then, it analyzes data 4 API, we can then integrate the post-processing process into flow using reaching definitions and fixed-point algorithms the vulnerability detection system through the GPT-4 API to to identify constraints. The system also incorporates a taint achieve full process automation. analysis module tailored to the framework, pinpointing vul- nerabilities and reporting them. The experiment results show that incorporating framework dispatching rules into the taint VII. RELATEDWORKS analysis effectively reduces false alarms, and LLMs can also We summarize the static and dynamic analysis tech- be used for efficient pruning. LuaTaint successfully identified niquesforIoTfirmwarevulnerabilitydetectioninrecentyears, 68 vulnerabilities among 92 firmware samples, demonstrating as well as security analysis methods for web interfaces. its effectiveness for widespread and accurate bug detection in Firmware Security Analysis. There has been extensive firmware web interfaces. study into firmware vulnerability detection through static and dynamics analysis [29], [30]. Firmalice is a notable binary REFERENCES analysis framework that uses symbolic execution and pro- gram slicing to identify authentication bypass vulnerabilities [1] F. A. Alaba, M. Othman, I. A. T. Hashem, and F. Alotaibi, “Internet in binary firmware [34]. Dtaint represents a static binary of things security: A survey,” Journal of Network and Computer taint analysis system [7], while Genius employs static code Applications, vol. 88, pp. 10–28, Oct. 2017. [Online]. Available: https://www.sciencedirect.com/science/article/pii/S1084804517301455 similarity-based analysis, transforming control flow graphs [2] A. Costin, J. Zaddach, A. Francillon, and D. Balzarotti, “A into numeric feature vectors for identifying vulnerabilities Large-Scale analysis of the security of embedded firmwares,” [37]. Other notable systems include KARONTE, a multi- in 23rd USENIX Security Symposium (USENIX Security 14). San Diego, CA: USENIX Association, Aug. 2014, binary static vulnerability detection system [36], and SATC, pp. 95–110. [Online]. Available: https://www.usenix.org/conference/ which uses shared keywords for taint analysis [8]. SRFuzzer usenixsecurity14/technical-sessions/presentation/costin [9] and IoTFuzzer [38] are notable frameworks for fuzzy [3] A. Whitmore, A. Agarwal, and L. Xu, “The internet of things– a survey of topics and trends,” Information Systems Frontiers, testing in router web servers and IoT devices, respectively. vol. 17, no. 2, p. 261–274, apr 2015. [Online]. Available: https: Tools like IoTHunter [39], Firm-AFL [40], and RPFuzzer //doi.org/10.1007/s10796-014-9489-2 [41] further augment this approach. Representative tools of [4] P. A. Networks, “2020 unit 42 iot threat report,” [Online], 2020. [Online]. Available: https://iotbusinessnews.com/download/ dynamic taint analysis include TaintCheck [43], Flayer, and white-papers/UNIT42-IoT-Threat-Report.pdf BitBlaze. These dynamic techniques are instrumental in iden- [5] P. Joshi, “Common attacks on embedded sys- tifying vulnerabilities that may not be apparent through static tems and how to prevent them,” [Online], 2022. [Online]. Available: https://rsk-cyber-security.com/blog/ analysis alone. common-attacks-on-embedded-systems-and-how-to-prevent-them/ Web Interface Security Analysis. For web applications [6] E.Montalbano,“Millionsofrouters,iotdevicesatriskfrombotenago malware,” [Online], 2021. [Online]. Available: https://iotbusinessnews. beyond firmware interfaces, the TAJ [42] tool employs hybrid com/download/white-papers/UNIT42-IoT-Threat-Report.pdf slicing combined with object-sensitive alias analysis for taint [7] K. Cheng, Q. Li, L. Wang, Q. Chen, Y. Zheng, L. Sun, and Z. Liang, analysis in Java web applications. Existing efforts in firmware “Dtaint: Detecting the taint-style vulnerability in embedded device firmware,”in201848thAnnualIEEE/IFIPInternationalConferenceon webinterfacesecurityanalysispredominantlyrelyondynamic DependableSystemsandNetworks(DSN). IEEE,2018,pp.430–441. analysisorfuzzytesting.Costinetal.[12]proposedascalable [8] L.Chen,Y.Wang,Q.Cai,Y.Zhan,H.Hu,J.Linghu,Q.Hou,C.Zhang, and fully automated dynamic analysis framework to discover H. Duan, and Z. Xue, “Sharing more and checking less: Leveraging common input keywords to detect bugs in embedded systems,” in web interface-related vulnerabilities in firmware. Various is- 30th USENIX Security Symposium (USENIX Security 21). USENIX sues need to be fixed when using these tools, as they are Association, Aug. 2021, pp. 303–319. [Online]. Available: https: not specialized for vulnerabilities in IoT web interfaces or //www.usenix.org/conference/usenixsecurity21/presentation/chen-libo [9] Y. Zhang, W. Huo, K. Jian, J. Shi, H. Lu, L. Liu, C. Wang, D. Sun, integrated into automated frameworks. FIRMADYNE [13], C. Zhang, and B. Liu, “Srfuzzer: An automatic fuzzing framework |
allows web penetration testing on accessible web interfaces forphysicalsohorouterdevicestodiscovermulti-typevulnerabilities,” over a local network. However, it has a low simulation of in Proceedings of the 35th Annual Computer Security Applications Conference, ser. ACSAC ’19. New York, NY, USA: Association networkreachabilityandwebserviceavailability.WMIFuzzer for Computing Machinery, 2019, p. 544–556. [Online]. Available: [14] focuses on the web interface by enforcing UI automation https://doi.org/10.1145/3359789.3359826IEEEINTERNETOFTHINGSJOURNAL,VOL.14,NO.8,AUGUST2021 12 [10] Y. Gao, X. Zhou, W. Xie, B. Wang, E. Wang, and Z. Wang, ofthe2013InternationalConferenceonSoftwareEngineering,ser.ICSE “Optimizingiotwebfuzzingbyfirmwareinfomationmining,”Applied ’13. IEEEPress,2013,p.652–661. Sciences, vol. 12, no. 13, p. 6429, 2022. [Online]. Available: [33] M. K. Gupta, M. Govil, and G. Singh, “Static analysis approaches https://www.mdpi.com/2076-3417/12/13/6429 to detect sql injection and cross site scripting vulnerabilities in web [11] A.Qasem,P.Shirani,M.Debbabi,L.Wang,B.Lebel,andB.L.Agba, applications:Asurvey,”inInternationalConferenceonRecentAdvances “Automatic vulnerability detection in embedded devices and firmware: andInnovationsinEngineering(ICRAIE-2014),2014,pp.1–5. Survey and layered taxonomies,” ACM Comput. Surv., vol. 54, no. 2, [34] Y. Shoshitaishvili, R. Wang, C. Hauser, C. Kru¨gel, and G. Vigna, mar2021.[Online].Available:https://doi.org/10.1145/3432893 “Firmalice-automaticdetectionofauthenticationbypassvulnerabilities [12] A.Costin,A.Zarras,andA.Francillon,“Automateddynamicfirmware in binary firmware,” in Network and Distributed System Security analysis at scale: A case study on embedded web interfaces,” in Symposium, vol. 1, 2015, pp. 1–1. [Online]. Available: https: Proceedings of the 11th ACM on Asia Conference on Computer and //api.semanticscholar.org/CorpusID:17298209 CommunicationsSecurity,ser.ASIACCS’16. NewYork,NY,USA: [35] N.Redini,A.Machiry,D.Das,Y.Fratantonio,A.Bianchi,E.Gustafson, Association for Computing Machinery, 2016, p. 437–448. [Online]. Y. Shoshitaishvili, C. Kruegel, and G. Vigna, “Bootstomp: On the Available:https://doi.org/10.1145/2897845.2897900 security of bootloaders in mobile devices,” in Proceedings of the 26th [13] D.D.Chen,M.Woo,D.Brumley,andM.Egele,“Towardsautomated USENIX Conference on Security Symposium, ser. SEC’17. USA: dynamicanalysisforlinux-basedembeddedfirmware.”inNDSS,vol.1, USENIXAssociation,2017,p.781–798. 2016,pp.1–1. [36] N. Redini, A. Machiry, R. Wang, C. Spensky, A. Continella, [14] D. Wang, X. Zhang, T. Chen, J. Li, and P. Gope, “Discovering Y. Shoshitaishvili, C. Kruegel, and G. Vigna, “Karonte: Detecting vulnerabilities in cots iot devices through blackbox fuzzing web insecure multi-binary interactions in embedded firmware,” in management interface,” Security and Communication Networks, vol. Proceedings 2020 IEEE Symposium on Security and Privacy, SP 2019, pp. 1–19, jan 2019. [Online]. Available: https://doi.org/10.1155/ 2020. United States: IEEE, may 2020, pp. 1544–1561. [Online]. 2019/5076324 Available:http://www.ieee-security.org/TC/SP2020/ [15] P. Srivastava, H. Peng, J. Li, H. Okhravi, H. Shrobe, and M. Payer, [37] Q. Feng, R. Zhou, C. Xu, Y. Cheng, B. Testa, and H. Yin, “Scalable “Firmfuzz: Automated iot firmware introspection and analysis,” in graph-based bug search for firmware images,” in Proceedings of the Proceedings of the 2nd International ACM Workshop on Security and 2016 ACM SIGSAC Conference on Computer and Communications Privacy for the Internet-of-Things, ser. IoT S&P’19. New York, NY, Security, ser. CCS ’16. New York, NY, USA: Association for USA:AssociationforComputingMachinery,2019,p.15–21.[Online]. Computing Machinery, 2016, p. 480–491. [Online]. Available: https: Available:https://doi.org/10.1145/3338507.3358616 //doi.org/10.1145/2976749.2978370 [16] Q. Yin, X. Zhou, and H. Zhang, “Firmhunter: State-aware and [38] J. Chen, W. Diao, Q. Zhao, C. Zuo, Z. Lin, X. Wang, W. Lau, introspection-driven grey-box fuzzing towards iot firmware,” Applied M. Sun, R. Yang, and K. Zhang, “Iotfuzzer: Discovering memory Sciences, vol. 11, no. 19, p. 9094, 2021. [Online]. Available: corruptions in iot through app-based fuzzing,” in Network and https://www.mdpi.com/2076-3417/11/19/9094 Distributed Systems Security (NDSS) Symposium 2018, feb 2018, [17] A.Holt,C.-Y.Huang,A.Holt,andC.-Y.Huang,“Openwrt,”Embedded network and Distributed Systems Security (NDSS) Symposium 2018; OperatingSystems:APracticalApproach,pp.195–217,2018. Conferencedate:18-02-2018Through21-02-2018.[Online].Available: https://www.ndss-symposium.org/ndss2018/ [18] “Luci web interface - openwrt,” [Online], 2021, online; accessed [39] P. Khandait, N. Hubballi, and B. Mazumdar, “Iothunter: Iot 2021-08-02. [Online]. Available: https://openwrt.org/docs/guide-user/ |
network traffic classification using device specific keywords,” IET luci/startt Networks, vol. 10, no. 2, p. 59–75, jan 2021. [Online]. Available: [19] “Table of hardware - openwrt,” [Online], 2023, online; accessed https://doi.org/10.1049/ntw2.12007 2023-12-06.[Online].Available:https://openwrt.org/toh/start [40] Y. Zheng, A. Davanian, H. Yin, C. Song, H. Zhu, and L. Sun, “Firm- [20] S. Khandelwal, “Thousands of mikrotik routers hacked to eavesdrop afl: High-throughput greybox fuzzing of iot firmware via augmented on network traffic,” [Online], 2018. [Online]. Available: https: processemulation,”inProceedingsofthe28thUSENIXConferenceon //thehackernews.com/2018/09/mikrotik-router-hacking.html SecuritySymposium,ser.SEC’19. USA:USENIXAssociation,2019, [21] “Owasp top ten - web application security risks,” [Online], p.1099–1114. 2021, online; accessed 2021. [Online]. Available: https: [41] Z.Wang,Y.Zhang,andQ.Liu,“Rpfuzzer:Aframeworkfordiscovering //owasp.org/www-project-top-ten/ router protocols vulnerabilities based on fuzzing,” KSII Transactions [22] C. Heffner, “Binwalk - firmware analysis tool,” [Online], 2014. on Internet and Information Systems, vol. 7, pp. 1989–2009, 08 2013. [Online].Available:https://github.com/ReFirmLabs/binwalk [Online]. Available: http://dblp.uni-trier.de/db/journals/itiis/itiis7.html# [23] [Online],2023.[Online].Available:https://github.com/qemu/qemu WangZL13 [24] A.LeffandJ.T.Rayfield,“Web-applicationdevelopmentusingthemod- [42] O. Tripp, M. Pistoia, S. J. Fink, M. Sridharan, and O. Weisman, el/view/controllerdesignpattern,”inProceedingsfifthieeeinternational “Taj: Effective taint analysis of web applications,” SIGPLAN Not., enterprise distributed object computing conference. IEEE, 2001, pp. vol. 44, no. 6, p. 87–97, jun 2009. [Online]. Available: https: 118–127. //doi.org/10.1145/1543135.1542486 [25] L.L.LeiWang,FengLiandX.Feng,“Principleandpracticeoftaint [43] J. Newsome and D. Song, “Dynamic taint analysis for automatic analysis,”JournalofSoftware,vol.28,no.4,pp.860–882,2017. detection,analysis,andsignaturegenerationofexploitsoncommodity [26] “The programming language lua,” [Online], 2023, online; accessed software,”vol.5,2005,pp.3–4. 2023.[Online].Available:https://www.lua.org/ [44] Q. Shi, X. Xiao, R. Wu, J. Zhou, G. Fan, and C. Zhang, “Pinpoint: [27] [Online], 2021. [Online]. Available: http://openwrt.github.io/luci/api/ Fast and precise sparse value flow analysis for million lines of index.html code,” in Proceedings of the 39th ACM SIGPLAN Conference [28] B. Eliott, “py-lua-parser: A lua parser and ast builder written in on Programming Language Design and Implementation, ser. PLDI python,” 2023, online; accessed 2023-09-11. [Online]. Available: 2018, vol. 53, no. 4. New York, NY, USA: Association for https://github.com/boolangery/py-lua-parser Computing Machinery, jun 2018, p. 693–706. [Online]. Available: [29] M. Pistoia, S. Chandra, S. J. Fink, and E. Yahav, “A survey of static https://doi.org/10.1145/3192366.3192418 analysis methods for identifying security vulnerabilities in software [45] D. Shao, D. Gopinath, S. Khurshid, and D. E. Perry, “Optimizing systems,”IBMSyst.J.,vol.46,no.2,p.265–288,apr2007.[Online]. incremental scope-bounded checking with data-flow analysis,” in 2010 Available:https://doi.org/10.1147/sj.462.0265 IEEE21stInternationalSymposiumonSoftwareReliabilityEngineering. [30] P.LiandB.Cui,“Acomparativestudyonsoftwarevulnerabilitystatic IEEE,122010,pp.408–417. analysistechniquesandtools,”in2010IEEEInternationalConference [46] S. Micheelsen and B. Thalmann, “A static analysis tool for detecting onInformationTheoryandInformationSecurity,2010,pp.521–524. securityvulnerabilitiesinpythonwebapplications,”may2016.[Online]. [31] G. Agosta, A. Barenghi, A. Parata, and G. Pelosi, “Automated Available:https://projekter.aau.dk/projekter/files/239563289/final.pdf security analysis of dynamic web applications through symbolic code [47] H.Li,Y.Hao,Y.Zhai,andZ.Qian,“Assistingstaticanalysiswithlarge execution,”inProceedingsofthe2012NinthInternationalConference language models: A chatgpt experiment,” in Proceedings of the 31st onInformationTechnology-NewGenerations,ser.ITNG’12. USA: ACMJointEuropeanSoftwareEngineeringConferenceandSymposium IEEE Computer Society, 2012, p. 189–194. [Online]. Available: on the Foundations of Software Engineering, ser. ESEC/FSE 2023. https://doi.org/10.1109/ITNG.2012.167 NewYork,NY,USA:ACM,2023,p.2107–2111.[Online].Available: [32] Y.ZhengandX.Zhang,“Pathsensitivestaticanalysisofwebapplica- https://doi.org/10.1145/3611643.3613078 tionsforremotecodeexecutionvulnerabilitydetection,”inProceedings [48] OpenAI,“Gpt-4technicalreport,”2023.IEEEINTERNETOFTHINGSJOURNAL,VOL.14,NO.8,AUGUST2021 13 [49] C.Lemieux,J.P.Inala,S.K.Lahiri,andS.Sen,“Codamosa:Escaping |
coverage plateaus in test generation with pre-trained large language models,” in Proceedings of the 45th International Conference on Software Engineering, ser. ICSE ’23. IEEE Press, 2023, p. 919–931. [Online].Available:https://doi.org/10.1109/ICSE48619.2023.00085 [50] Z.Zhang,C.Chen,B.Liu,C.Liao,Z.Gong,H.Yu,J.Li,andR.Wang, “Unifying the perspectives of nlp and software engineering: A survey onlanguagemodelsforcode,”2023. [51] M.I.Schwartzbach,“Lecturenotesonstaticanalysis,”BasicResearch inComputerScience,UniversityofAarhus,Denmark,2008. [52] P. Melnichenko, “luacheck: A tool for linting and static analysis of lua code,” 2018, online; accessed 2018-10-12. [Online]. Available: https://github.com/mpeterv/luacheck [53] Tencent, “Tscancode: A static code analyzer for c++, c#, lua,” 2022, online; accessed 2022-09-05. [Online]. Available: https://github.com/ Tencent/TscanCode |
2402.18189 VulMCI : Code Splicing-based Pixel-row Oversampling for More Continuous Vulnerability Image Generation Tao Peng Ling Gui School of Computer Science and Artificial Intelligence, School of Computer Science and Artificial Intelligence, Wuhan Textile University, Wuhan 430063, China Wuhan Textile University, Wuhan 430063, China Email: pt@wtu.edu.cn Email: 2315363137@mail.wtu.edu.cn Yi Sun Lijun Cai School of Computer Science and Artificial Intelligence, College of Computer Science and Electronic Engineering, Wuhan Textile University, Wuhan 430063, China Hunan University, Changsha 410082, China Email: id.yisun@gmail.com Email: ljcai@hnu.edu.cn Rui Li Qiang Zhu College of Software Engineering and Cyber Security, School of Computer Science and Artificial Intelligence, Dongguan University of Technology, Dongguan 523000, China Wuhan Textile University, Wuhan 430063, China Email: ruili@dgut.edu.cn Email: qzhu@wtu.edu.cn Li Li School of Computer Science and Artificial Intelligence, Wuhan Textile University, Wuhan 430063, China Email: lli@wtu.edu.cn Abstract—In recent years, the rapid development of deep I. INTRODUCTION learning technology has brought new prospects to the field of vulnerability detection. Many vulnerability detection methods With the widespread use of computer networks and the transformsourcecodeintoimagesfordetection,buttheyneglect ubiquity of the Internet, vulnerability detection has become the issue of image quality generation. Since vulnerability images increasingly crucial as malicious hackers and cybercriminals donotpossessclearandcontinuouscontourslikeobjectdetection images, Convolutional Neural Networks (CNNs) tend to lose continuously seek novel methods to infiltrate systems and pil- semanticinformationduringtheconvolutionandpoolingprocess. fer sensitive information. Furthermore, as software scales and Therefore,thispaperproposesapixelrowoversamplingmethod complexities continue to grow, vulnerabilities within source based on code line concatenation to generate more continuous code have become more insidious and pervasive, posing a code features, addressing the problem of discontinuous colors in severe threat to information security. According to the latest code images. The feasibility of the proposed method is theoreti- cally analyzed and verified. Based on these efforts, we introduce data from the National Vulnerability Database (NVD) [1], we the vulnerability detection system VulMCI, which is tested on can observe that in 2021, the number of disclosed vulnera- twodatasets,SARDandNVD.Experimentalresultsdemonstrate bilities surpassed the twenty-thousand mark, and even though that VulMCI outperforms eight state-of-the-art vulnerability thefiguredecreasedtoslightlyoverthirteenthousandin2022, detectors (i.e., Checkmarx, FlawFinder, RATS, VulDeePecker, it remains a substantial quantity. Consequently, the need for SySeVR, Devign, VulCNN, and AMPLE) in accuracy on the SARDdataset.Comparedtootherimage-basedmethods,VulMCI efficientandautomatedsourcecodevulnerabilitydetectionhas shows improvements in all metrics, including a 19.82% increase emergedasanurgentrequirementtoensuretherobustnessand in True Positive Rate (TPR), a 4.95% increase in True Negative reliability of software systems. Rate (TNR), and an 8.89% increase in accuracy (ACC). On the Traditional vulnerability detection methods typically em- NVD real-world dataset, VulMCI achieves an average accuracy of 90.41%. ploytechniquesbasedoncodesimilarity[2]–[6]orrule-based IndexTerms—VulnerabilityDetection,Scurity,DeepLearning, approaches [7]–[9] to analyze source code in order to identify Program Analysis, Program Representation potentialvulnerabilities.However,theseconventionalmethods exhibit several notable limitations. Firstly, they often require a significant amount of manual work and rule formulation, Correspondingauthors:YiSunandLijunCai. https://github.com/guilingxz/VulMCI which becomes impractical when dealing with large-scale 4202 rpA 61 ]RC.sc[ 2v98181.2042:viXracoderepositories.Secondly,theyfrequentlystruggletoaddress ousrowsofpixels,effectivelyenhancingtheidentification complex vulnerability types, especially those with conceal- of vulnerability features. mentandvariants.Finally,thesemethodstendtoproducefalse • Weproposeapixelrowoversamplingalgorithmbasedon positives and false negatives when handling extensive code codeconcatenation.Toaddresstheissueofdiscontinuous repositories, thus compromising the accuracy and efficiency numerical values in directly generated code images, we of the detection process. utilizetherelationshipsbetweennodesinthecontrolflow Nevertheless, in recent years, the rapid advancement of graph to insert new code lines between adjacent rows. deep learning technology has brought new prospects to the Thisbalanceslocalvariationsintheimageandhighlights field of vulnerability detection. Deep learning methods have important features, thereby improving the CNN’s ability the ability to automatically learn patterns and features from to extract key features and enhancing classification per- extensive source code without the need for manual inter- formance. s vention, rendering them highly scalable. Furthermore, deep • We present a novel finding that when code is converted learning technology is effective in handling complex vulner- into image representation, there exist discontinuous and ability types, thereby enhancing the accuracy of vulnerability abrupt numerical changes. This discontinuity may nega- detection. These advantages have positioned deep learning- tively impact the training of Convolutional Neural Net- based vulnerability detection methods as a current focal point work(CNN)models,especiallyaftertheimagesundergo of research and attention. pooling operations, leading to the loss of significant row |
Existing deep learning-based vulnerability detection sys- information. tems utilize various methods, including processing code into Paper organization. The remaining sections of this paper textualrepresentationsusingnaturallanguageprocessing[10], are organized as follows. Section 2 presents the motivation [11], analyzing code structure graphs using graph neural of our paper. Section 3 introduces our method. Section 4 networks [12], [13], and generating images from code for de- presents the experimental results. Section 5 discusses future tection[14].Whileeachofthesemethodshasitsmerits,there work.Section6providesanoverviewofrelatedwork.Finally, isstillroomforimprovement.Insomepriorstudies[10],[15], Section 7 summarizes the key findings of this paper. customCommonWeaknessEnumeration(CWE)vulnerability sets were used to match and locate vulnerabilities. However, II. MOTIVATION this approach may lead to incomplete vulnerability coverage and instances where vulnerability labels do not match in real- Figure 1 depicts a vulnerability code image generated world datasets. Additionally, many methods [15], [16] rely on using our VulCNN [14] method. We observed the presence theconceptofcodeslicingtoeliminateredundantinformation, of numerous redundant zero vectors and discontinuous color dependingnotonlyonhighlyaccuratevulnerabilitylinelocal- points, which are detrimental to the subsequent training of izationbutalsoriskingthelossofcompleteprogramsemantic CNN models. This is attributed to the significant differences information during slicing. in feature representation between vulnerability detection tasks Furthermore, methods that transform source code into im- andobjectdetectiontaskswhenusingimagesforclassification. ages, such as VulCNN [14], although preserving the complete Objectdetectiontaskstypicallyrequiremodelstocapturecon- semantics and structural information of functions, have been tinuous edge features of target objects, which are retained to found through experiments to generate RGB images with someextentaftermultipleconvolutionandpoolingoperations, significant instances of black and discontinuous scattered as illustrated in Figure 2. However, in vulnerability detection color points in the channels. This characteristic is considered tasks, the features of key statements often occupy a relatively detrimental to the classification task of Convolutional Neural small proportion of the data, and their distribution may be Network (CNN) models. more dispersed. This leads to significant fluctuations in pixel In this paper, we adopt the baseline method of converting values and the generation of discontinuous color points when sourcecodeintoimagesandproposeimprovementstoaddress directly converting vulnerability code into images. This sce- the issue of discontinuity between rows of pixels in the nario presents two main challenges for classical convolutional images. We apply a pixel row oversampling algorithm to the neural networks (CNNs) when processing vulnerability code sourcecodelineswithdependenciestoenhancethecontinuity images: betweencodelines.Themainadvantageofthisapproachisto 1) Information Loss: Vulnerability code images are likely reduce data noise and minimize differences between adjacent tolosecrucialsemanticinformationafterconvolutionand data points, thereby making the model more robust to small pooling operations, especially concerning the features of variations in the input data. This contributes to improving key vulnerability statements. This poses difficulties in model stability and generalization capability. training and inference for vulnerability detection models. In summary, this paper makes the following contributions: 2) Interference Noise: In addition to key statements, vul- • We present a novel framework for vulnerability image nerability code images typically contain a large number detection called VulMCI, which incorporates a method of irrelevant statements, which may introduce additional of pixel row oversampling using code control flow. This interferencenoiseandreducethemodel’saccurateunder- methodgeneratescodefeatureimageswithmorecontinu- standing of vulnerability features.A. Pixel-row oversampling We utilize Joern [18] to generate Code Property Graphs (CPGs) from the extracted function samples, and then splice them based on the node relationships of Control Flow Graphs (CFGs). The control flow graph describes the control flow of the program, representing the transitions of control flow during program execution. Thus, splicing based on CFG node relationships enhances contextual connections. The splicing process follows these steps: we first traverse the line numbers of the code, and if a node corresponding to the line number has edges of CFG type, we concatenate the code of that Fig.1. AvulnerabilityimagegeneratedusingVulCNNmethod node with the code of the target node completely, inserting it as a new code sample line after the node line. If the node corresponding to the code line does not belong to CFG, no splicing is performed, but the code line content is retained. As shown in the red-boxed portion of the function samples in Figure 3, lines 4 and 5 correspond to nodes with existing edges in the CFG. Therefore, the codes of lines 4 and 5 are concatenated and inserted between the two lines. Finally, the Fig.2. ComparisonofMultiplePoolingResults function samples after pixel row oversampling are vectorized using sent2vec [17], where each line of code is embedded as In response to these challenges, we propose a pixel-row a row vector. These vector rows are then arranged together to oversamplingmethodbasedoncontrolflowgraph-guidedcode generateagrayscaleimage.Figure3andAlgorithm1describe splicing. By integrating the structured features of the code, how VulMCI converts function code into a grayscale image. we selectively splice correlated code lines to generate new |
sample rows. This approach aims to bridge code segments Algorithm 1Convertingthesourcecodeofafunctionintoan with flow relationships, enhancing contextual continuity and grayscale image thereby improving the extraction of vulnerability features. Input: F: Source code of a function Output: I: An grayscale image III. OURMETHOD 1: nF ←CODENORMALIZATION(F) 2: CFG←GRAPHEXTRACTION(nF) Existingmethodsforgeneratingimagesfromcodeoverlook 3: cfg nodes←EXTRACTCFGNODES(CFG) the continuity of pixel rows, resulting in low-quality images. 4: CFG adj matrix←GENERATEADJACENCYMATRIX(CFG) Therefore, we propose the system approach of VulMCI to 5: channel←[] 6: for i in range(len(code list)) do generate high-quality images with more continuous rows. As 7: if i+1 not in cfg nodes then illustrated in Figure 3, VulMCI consists of four main stages: 8: line vec=EMBEDSENTENCE(code list[i]) constructing function samples, pixel row oversampling, code 9: channel.insert(i,line vec) encoding and embedding, and generating grayscale images. 10: end if 11: for j in range(len(CFG adj matrix[i])) do • Building function samples: Our system supports the 12: if CFG adj matrix[i][j]=1 then extraction of function-level slice samples from initial 13: left code=code list[i] programfiles,whichundergonormalization.Thisprocess 14: right code=code list[j] involvesthreemainsteps:removingcomments,standard- 15: concatenated code=left code+right code izing function names, and standardizing variable names. 16: line vec=EMBEDSENTENCE(concatenated code) 17: channel.append(line vec) • Pixel-row oversampling: We generate Code Property 18: end if Graphs (CPGs) from the extracted function samples, 19: end for and utilize the edge-node relationships of Control Flow 20: end for Graphs(CFGs)tosynthesizenewcodelinesinsertedinto 21: I =Channel 22: return I the source code, where each node represents a line of code. • Codeencodingandembedding:Weutilizethesent2vec B. Theoretical Analysis [17]modelandparametersprovidedbyVulCNN[14]for code encoding and embedding. Definition 1. For any two adjacent pixel rows represented by • Generating three-channel images: We arrange the gen- vectorsvector1=[s 1,s 2,...,s n]andvector2=[f 1,f 2,...,f n], erated code line vectors together to form a grayscale animageisconsideredpixel-rowcontinuouswhentheabsolute image of vulnerabilities, which is used for subsequent difference between corresponding elements, denoted as |s − i training and classification by CNNs. f |≤gap, where gap is a small value. iFig.3. SystemoverviewofVulMCI Theorem 1. Our method has a good probability of producing Step 2:We establish that the UV parameters in the training more continuous images. objective of the sent2vec model satisfy the requirements of the above inequality. The complete training objective of the Proof. Step 1: We demonstrate the continuity between ad- Sent2Vec [17] model, an unsupervised learning method for jacent pixel rows and concatenated pixel rows under specific learning and inferring sentence embeddings, is as follows: conditions.Theobjectiveofthesent2vec[17]modelistolearn word and sentence embedding by minimizing a loss function. min(cid:88) (cid:88)(cid:16) q (w )ℓ(cid:0) uT v (cid:1) The simplified representation of the objective is as follows: U,V p t wt Swt S∈Cwt∈S min(cid:88) f (UV ) (1) +|N | (cid:88) q (w′)ℓ(cid:0) −uT v (cid:1)(cid:17) (5) U,V s Ls wt n w′ Swt S∈C w′∈V where U represents the word embedding matrix, V represents whereU andV representtheembeddingmatricesforwords the sentence embedding matrix, C is the corpus, and L and sentences respectively, C is the corpus containing the set s representsthewordindexlistcorrespondingtothesentenceS ofsentencestobelearned.Additionally,Srepresentsaspecific inthecorpus.Theparameterizedrepresentationofthesentence sentenceinthecorpus,andw tisthetargetwordinsentenceS. vectorisasfollows.WeaimtoobtainasetofUV parameters u wt represents the embedding vector for the target word, and to demonstrate the effectiveness of our concatenated rows. v Swt istheembeddingvectorforthesentenceS withthetarget vector1= u u . . .1 2 =UVL u = (cid:80) (cid:80)m i m i= =1 1 . .u ui i1 2w wi i1 2 ×L u (2) b pw ex i ro n etrr daad r ic y ct tr e ile vodm ego if psov t er ie rcd ft o. rh e reN mgrtw aea nst r s cg i er e oe t np or nw le oos pse r s odn sft ius tw n ivt t ch e. tie o aT n ns h , de et m nfo e eu af gn s ac un tt ire i viog n ena gt si tℓv ah( me ex p)s m la eom i ss d .p et Bl lhe ’ ye ss . (cid:80)m u w minimizing this loss function, the model learns embeddings u i=1 in in that effectively capture semantic relationships between words n and sentences in an unsupervised manner. c 1 (cid:80)m u w The first part of the loss function focuses on positive concatenated vector= c . . .2 =UVL c = (cid:80)(cid:80) mi m i= =1 1 u. . .ui i1 2w wi i1 2 ×L c ps e tia m lo em n sb ,p e ℓl d pe (cid:0)ds uui, sn T w hge t |
in nvc s gSpo wau dtcr (cid:1) ia e s.g sii t T mn h hg r io e laus rg sim eh sci eol t na h n tr e d ens l p ce o en ag srt ie tsn ft a uic c d re tds hr re eet g rso r se aeb s pse s ai n roc tenl go ia ns l toe is vr ths e ein f su a ent m mh ce - -- c i=1 in in n bedding space through the logistic regression loss function (3) ℓ(cid:0) −uT v (cid:1) . The overall objective is to minimize the loss w′ Swt function by learning U and V, resulting in embeddings with d 1 (cid:80)m u w enhancedsemanticrelationshipsbetweensentencesandwords. vector2= d . . .2 =UVL d = (cid:80)i m i= =1 1 . .ui i1 2wi i1 2 ×L d (4) B bay ses dpl oic nin thg ea cn od ni tn ros ler flti on wg ga rd aj pac he ,n wt eco ind te ron do ud ce es min ot ro et ch oe nm tei xd td ul ae l . information, making contextually relevant code lines closer (cid:80)m u w in the embedding space. This characteristic is reflected in d i=1 in in n the code encoding and embedding stage shown in Figure3. If for any pair of elements, |u −c |≤gap and |c −d |≤ Therefore, the training objective of sent2vec [17] can obtain a i i i i gap holds, then the two vectors and the concatenated vector set of UV parameters, theoretically leading to a smaller gap, are considered continuous. proving the continuity between adjacent vector rows.Fig.5. CNNclassificationofVulMCI Fig.4. Functioncodelengthdistribution simultaneously. In VulMCI, we select 10 filters of different C. Classification sizes (from 1 to 10), each containing 32 feature maps to In the realm of vulnerability detection, the adoption of capture features from different parts of the image. Following advanced techniques becomes imperative to handle the com- the max-pooling operation, the length of our fully connected plexity and nuances of source code. Convolutional Neural layer is 320. Table I provides a detailed description of the Networks (CNN) have emerged as a powerful tool in various parametersusedinVulMCI.TheentiremodeladoptsRectified image-basedtasks,showcasingtheirabilitytodiscernintricate LinearUnit(ReLU)[19]asthenon-linearactivationfunction. featuresandpatterns.Inthissection,weleveragethecapabili- Additionally,weutilizecross-entropylossasthelossfunction ties of CNN to address the challenges inherent in source code in CNN for penalizing incorrect classifications. We employ vulnerability detection. Adam [20] as the optimizer with a learning rate set to 0.001. After completing the image generation phase, we trans- Oncethetrainingiscompleted,weusethetrainedCNNmodel formed the source code of functions into images. For a given to classify new functions, determining whether they possess image, we initiated training of a CNN model, subsequently vulnerabilities. applying this model for vulnerability detection. Since CNN models require input images of uniform size, and the number TABLEI PARAMETERSETTINGSINVULMCI of code lines in different functions may vary, it becomes essential to select a suitable threshold length for extension parameters settings or cropping. lossfunction CrossEntropyLoss activationfunction ReLU The code length distribution of function samples in the optimizer Adam experimental dataset (SARD) is illustrated in Figure 4. It is batchsize 32 observed that the majority of function lengths are less than learningrate 0.001 epochnum 100 100 lines. Therefore, we have chosen a code length threshold of 100 lines to generate our input images. And previous experimentshaveshownthatchoosing100linesasathreshold IV. EXPERIMENTS can balance overhead and detection performance well. For In this section, our aim is to address the following research functions with code lengths less than 100, we pad the vectors questions: with zeros at the end. In the case of functions exceeding 100 • RQ1: What are the advantages of VulMCI’s pixel row lines,wetruncatethetrailingportionofthevectors.Theinput oversampling method compared to other oversampling image size is set to 100×128, 100 is the code line threshold, methods? and 128 representsthe dimensionality of thesentence vectors. • RQ2: How does the detection performance of VulMCI compare to other state-of-the-art vulnerability detection After generating images of fixed size, we build a Convo- systems? lutional Neural Network (CNN) model through training on • RQ3:CanVulMCIbeappliedtoreal-worldvulnerability these images. As depicted in Figure 5, we employ convolu- scanning? tional filters of varying shapes, with dimensions m * 128, to A. Experiment Settings ensure each filter can extract features across the entire space of the embedded sentences. The size of the filters roughly The dataset used in this paper is sourced from the vulnera- determines the length of the sentence sequences considered bilitydatasetprovidedbySySeVR[15].Thisdatasetoriginatesfrom SARD [21] and NVD [1], encompassing a total of 126 B. Experimental Results vulnerability types, each uniquely identified by a Common 1) Experiments for Answering RQ1: To validate the effec- Weakness Enumeration (CWE) ID [22]. The SARD dataset tiveness of the CFG-based pixel row oversampling method comprises production, synthetic, and academic programs (re- in VulMCI, we additionally designed several oversampling ferred to as test cases) categorized as ”good” (i.e., without methods for comparison. The specific methods are as follows: vulnerabilities), ”bad” (i.e., containing vulnerabilities), and ”mixed” (i.e., vulnerabilities with available patch versions). 1) To determine the influence of oversampling iterations on |
TheNVDdatasetincludesvulnerabilitiesin19popularC/C++ theresults,wedesignedamethodbasedontheK-nearest open-source products (software systems), along with possible neighbor (KNN) adjacent line code splicing according diff files describing the differences between susceptible code to the semantic properties predicted by sent2vec. This and its patched versions. The SARD dataset contains a total method adopts segmented combination splicing to gener- of 21,233 program files, while the NVD dataset includes ate new lines of code. Given two adjacent lines of code, 2,011realvulnerabilitiesandtheircorrespondingfixedversion LineiandLinei+1(whereirepresentsthelinenumber), files. Our system processed the dataset by extracting function adaptive splicing is performed between the two adjacent samples from program files and removing function samples lines of code. The splicing process is executed according with less than ten lines of code. This exclusion was based to the following steps: on the observation that the majority of functions with fewer • From right to left in Line i, we take the number than ten lines only involve external function calls and cannot obtainedfromEquation1asthelengthofthesubstring, beeasilyclassifiedasusablefunctionsamples.Ultimately,we and then obtain the substring left tokens. obtained12,116vulnerabilityfunctionsamplesand4,660non- vulnerability function samples from the SARD dataset, and (cid:22) (cid:23) left length·(k−i) 1,049vulnerabilityfunctionsamplesand952non-vulnerability num left tokens[i]= k function samples from the NVD dataset. In this study, we first conducted comparative and ablation • From left to right in Line i+1, we take the number experiments using the SARD dataset, and then employed the obtainedfromEquation2asthelengthofthesubstring, NVD dataset in RQ3 to evaluate the effectiveness of vulner- and then obtain the substring right tokens. ability detection on real vulnerabilities. We adopted a k-fold (cid:22) (cid:23) right length·i cross-validation (k=5) approach to partition the entire dataset num right tokens[i]= into 5 mutually exclusive subsets, with 4 subsets used for k modeltrainingand1subsetformodeltesting.Thispartitioning • The new concatenated line is obtained as approach ensures the utilization of distinct data subsets for concatenated code = left tokens+right tokens, both training and testing phases, facilitating the assessment and we complete the words at the character level. of the model’s generalization performance. The devices and • Where i ∈ [1,k), k-1 new concatenated lines will be experimental parameters employed in this study are presented gradually inserted between adjacent lines, where k=1 in Tables I and II, respectively. To comprehensively evaluate indicates no splicing, k=2 indicates splicing once, k=3 theperformanceofourproposedmethod,weutilizedmultiple indicates splicing twice, and so on. evaluation metrics, including False Positive Rate (FPR), False The experimental results, as depicted in TableIII, encom- Negative Rate (FNR), Precision (Pr), Recall (Re), F1 Score passed a total of 7 scenarios. From these experiments, (F1), and Accuracy (ACC). Each metric provides detailed it was observed that the best performance was achieved insights into the algorithm’s performance across different whenk =2,indicatingthatinsertingasinglelineyielded aspects, offering a nuanced understanding of its strengths and theoptimaloutcome.Thisapproachresultedina0.533% limitations. increase in accuracy compared to not splicing lines. However, the accuracy was still 7.8% lower compared to VulMCI’s CFG-based method. This discrepancy can be TABLEII DETAILSOFTHEEXPERIMENTALDEVICES attributed to the indiscriminate oversampling of all lines usingtheK-nearestneighborsplicingmethod.Whilethis Device Type Version approach enhanced the continuity of the images, it also GPU Tesla V100 CPU IntelXeonSilver 6130 fused redundant code segments, including those weakly Operatingsystem Centoslinuxrelease 7.9.2009 associated with vulnerabilities. As vulnerability-related Python 3.8 code segments are in the minority, their significance was Torch 1.12.1 Matplotlib 3.8.2 not significantly bolstered by the splicing process. Package Numpy 1.25.2 2) To assess the impact of different oversampling methods Networkx 3.1 on the results, we devised three additional control meth- Joern 2.0.121 ods, including the complete concatenation of adjacent codeandanoversamplingapproachwherecodelinesareTABLEIII PARAMETERANALYSISOFK-VALUEDADJACENTCODECONCATENATIONMETHOD k Remark FPR FNR Pr Re F1 ACC 1 Baselinewithoutsplicing 17.976 8.932 92.225 93.412 91.068 88.687 2 Splicingandinserting1line 16.429 8.762 92.577 93.955 91.238 89.22 3 Splicingandinserting2lines 18.69 8.252 92.476 93.215 91.748 89 4 Splicingandinserting3lines 19.762 8.124 92.367 92.863 91.876 88.812 5 Splicingandinserting4lines 17.738 8.72 92.381 93.508 91.28 88.906 6 Splicingandinserting5lines 21.19 7.359 92.543 92.445 92.641 89 7 Splicingandinserting6lines 20.476 7.954 92.341 92.637 92.046 88.75 VulMCI CFG k=2 SplicingonlyCFGnodes,usingk=2splicingstrategy 1.931 3.383 97.91 99.237 96.617 97.02 first vectorized and then inserted by adding their respec- structural relationships, the concatenated code is more tivevectors.Thecompleteconcatenationofadjacentcode directional and strongly correlated with the vulnerability involves inserting a single line between adjacent lines, execution process, resulting in cases of concatenation |
where concatenated code = left code + right code. The across lines. Therefore, concatenating complete adjacent oversampling method of inserting vectors involves the lines based on code structural information is more suit- insertion vector being equal to the sum of the left and able. Among the three edge types, concatenating based rightvectors.Topreventexcessivelylargevaluesresulting on CFG yields the best results, with an F1 score of fromvectoraddition,wealsoexperimentedwithdividing 98.035% and an accuracy of 97.199%. This is because the sum of the vector rows by two before insertion, CFG can better capture code structure and control flow. denotedasInsertion vector=(left vector+right vector) Specifically, code execution follows temporal logic, and / 2. concatenatingbasedonthedependenciesofdataflowand The experimental results, as shown in TableIV, indicate code control flow does not disrupt the temporal relation- that the methods directly processing vector rows (vec ship of the code. It also narrows the distance between and vec2) perform poorly, with vec2 even performing key statements, facilitating vulnerability feature extrac- slightly worse than no splicing, suggesting that directly tion. Concatenating based on DDG yields the second- oversamplingvectorrowsmayleadtoinformationlossor best results because DDG only focuses on vulnerabilities confusion. The methods of complete code concatenation caused by data, such as buffer overflow, and does not and adaptive concatenation of 1 line (k=2) yield similar well reflect the formation relationships of logical vulner- results, hence we compared them with the CFG-based abilities. Concatenating based on CDG yields the worst method of adjacent lines with complete concatenation results, although slightly better than no concatenation. (VulMCI CFG all), which shows slightly better perfor- This is because CDG generally only contains conditional mancethanVulMCI CFG k=2.Thisdifferenceinresults branches,suchasif andwhile.Finally,whenconcatenat- may be related to the distribution of the concatenated ing all three edge types of DDG, CFG, and CDG, the data. accuracy is only 0.376% higher than no concatenation. It 3) As the Code Property Graph (CPG) contains various is evident that simultaneously concatenating three types typesofrelationshipsubgraphs,toinvestigatewhichtype of edges leads to many repeated concatenations between of edge concatenation performs best in experiments, we nodes, resulting in a loss of distinction between key comparedthreetypesofconcatenation:DataDependency vulnerability statements, thus having a counterproductive Graph (DDG), Control Dependency Graph (CDG), and effect. Control Flow Graph (CFG). Since in the above ex- 2) Experiments for Answering RQ2: In this section, we periments, the concatenation methods ’k=2’ and ’all’ compare VulMCI with several vulnerability detection tools, performed the best and yielded similar results, we also includingacommercialstaticvulnerabilitydetectiontool(i.e., applied two different concatenation methods to the three Checkmarx [9]), two open-source static analysis tools (i.e., types of edges. FlawFinde [7] and RATS [8]), and five deep learning-based The experimental results, as shown in Table 5, indicate vulnerability detection methods (i.e., VulDeePecker [10], Sy- that when concatenating based on edge relationships, SeVR [15], Devign [13], VulCNN [14] and AMPLE [23]). concatenatingcompleteadjacentlinesyieldsbetterresults Figure 6 presents a bar chart that intuitively illustrates the than using split-combine concatenation. This is related metrics of True Positive Rate (TPR), True Negative Rate to the data distribution. When all lines of code are con- (TNR), and Accuracy (ACC) for each of these methods. catenatedindiscriminately,thedistancesbetweenlinesare closer,makingsplit-combineconcatenationmoresuitable For the three static analysis tools, RATS, Checkmarx, and forthisdatadistribution.Thesent2vecmodelcanpredict FlawFinder, their detection effectiveness is not satisfactory, the concatenated lines well by connecting contextual with accuracy rates all below 60%. One plausible explanation semantics. However, when concatenating based on code is that they rely on human experts to define vulnerability rules for detection. However, as vulnerability types becomeTABLEIV COMPARISONOFOTHERSPLICINGMETHODS Method Description FPR FNR F1 Pr Re ACC Nosplicing Baseline 17.976 8.932 92.225 93.412 91.068 88.687 All Completecodeconcatenationofadjacentlines 17.5 8.464 92.559 93.606 91.536 89.157 Vec Vectorizefirst,thenaddadjacentvectorrows 19.524 8.379 92.268 92.925 91.621 88.687 Vec2 Dividethesumofadjacentvectorrowsbytwobeforeinsertion 22.857 7.529 92.177 91.885 92.471 88.436 VulMCI CFG All OnlyspliceCFGnodesandadoptthesplicingstrategy”All” 1.609 3.259 98.035 99.364 96.741 97.199 TABLEV COMPARISONOFOTHERSPLICINGMETHODS Method Description FPR FNR F1 Pr Re ACC NoConcatenation Baseline 17.976 8.932 92.225 93.412 91.068 88.687 ConcatenateAll ConcatenateDDG,CFG,andCDG,completecode 17.619 8.55 92.493 93.56 91.45 89.063 DDG k=2 ConcatenateonlyDDGnodes,split-combineapproach 3.004 3.053 97.876 98.823 96.947 96.961 CDG k=2 ConcatenateonlyCDGnodes,split-combineapproach 15.88 11.056 91.201 93.576 88.944 87.604 CFG k=2 ConcatenateonlyCFGnodes,split-combineapproach 1.931 3.383 97.91 99.237 96.617 97.02 |
DDG all ConcatenateonlyDDGnodes,Completespliceapproach 2.575 3.012 97.979 98.989 96.988 97.11 CDG all ConcatenateonlyCDGnodes,Completespliceapproach 12.768 10.52 92.063 94.799 89.48 88.856 CFG all ConcatenateonlyCFGnodes,Completespliceapproach 1.609 3.259 98.035 99.364 96.741 97.199 traction, leading to incomplete code semantics. On the other hand, VulMCI enhances the semantic information of critical codewhileretainingcompletefunctioncode.Additionally,the limited coverage of vulnerability label sets in slicing methods means that a function sample may have multiple vulnerability candidates, making precise vulnerability localization and slic- ing challenging. VulMCI achieves a 10.70% higher accuracy than SySeVR. Devign employs a graph neural network approach, effec- tivelyleveragingnoderelationshipswithinthegraphstructure. However, its use of compound graphs with intricate network node information introduces redundant information weakly correlated with vulnerability nodes, increasing model com- plexity and performance overhead. Moreover, as the number of nodes increases, the model struggles to learn edge node information, leading to information loss. In contrast, VulMCI utilizes an image-based approach for detection, enhancing Fig.6. TruePositiveRate(TPR),TrueNegativeRate(TNR),andAccuracy ofRATS,Checkmarx,FlawFinder,VulDeePecker,SySeVR,Devign,VulCNN vulnerability features through oversampling based on code andAMPLEondetectingvulnerability structurewhileretainingcompletecodesemantics,thusavoid- ing the aforementioned issues. increasingly complex, human experts cannot comprehensively AMPLE addresses Devign’s shortcomings by simplifying define patterns for all vulnerabilities, leading to higher rates nodes according to type and variable, representing different of false positives and false negatives. types of edges with weighted vectors, and enhancing node Regarding VulDeePecker and SySeVR, both methods em- representation using a multi-head attention mechanism. This ploy program slicing to process datasets, vectorizing slices results in a 6.41% increase in accuracy compared to Devign. for training bidirectional recurrent neural networks (BRNN) However, due to the addition of modules, AMPLE still in- for vulnerability detection. The performance disparity be- curs considerable performance overhead. In contrast, VulMCI tween these two systems arises from VulDeePecker only achieves a higher simplification rate by mapping the complex considering vulnerabilities caused by API function calls and node network to a network between line numbers in the solely focusing on data dependency information. In contrast, preprocessing phase. Experimental results demonstrate that SySeVR considers semantic information resulting from both VulMCI outperforms AMPLE by 3.60% in accuracy. data and control dependencies and supports a wider range VulCNN utilizes centrality analysis to transform time- of vulnerability syntax labels for matching vulnerabilities. consuming graph analysis into efficient image scanning, ef- Consequently,SySeVRachievesa9.47%higheraccuracythan fective for large-scale scanning. However, it overlooks the VulDeePecker. discontinuity of pixel information in images, leading to insuf- SySeVR utilizes code slicing for vulnerability feature ex- ficient vulnerability feature extraction. VulMCI addresses thisAdditionally,thereissomeredundancyinthelabelinformation of analyzed nodes. We are currently contemplating the recon- struction of a new, lightweight code analysis tool to enhance operational efficiency. While utilizing the pixel row oversampling method to gen- erate more continuous code line features, we have focused solely on oversampling between code lines. In other words, we have considered only the continuity of pixel rows above and below the code lines, neglecting the continuity within pixel rows. However, we are committed to ongoing research to substantiate the effectiveness of this concept. In subsequent phases, we plan to extend our method to other graph-based detection systems to further validate its scalability. This extension aims to assess the adaptability and effectiveness of our approach beyond the current system. VI. RELATEDWORK In recent years, researchers have proposed various methods Fig.7. TimeOverheadScalePlotforModels for vulnerability detection, categorizing static detection tech- niques into code similarity-based and pattern-based methods. issue through pixel row oversampling, resulting in a 19.82% Code similarity-based approaches, such as [3], [4], [6], [24], increase in true positive rate (TPR), a 4.95% increase in aregenerallysuitableforidentifyingcodeclonesorrepetitions true negative rate (TNR), and an 8.89% increase in accuracy but exhibit poor performance in detecting unknown vulnera- (ACC). bilities. 3) ExperimentsforAnsweringRQ3: ToevaluateVulMCI’s Pattern-based methods encompass several directions. Rule- real-world vulnerability detection capabilities, we trained and based methods rely on human experts to manually construct tested the model using 2011 real vulnerabilities and their vulnerability features. Tools like Checkmarx [9], FlawFinder corresponding fixed version files from the NVD. The data [7], and RATS [8] using this approach often struggle to partitioningmethodremainedconsistentwithpreviousexperi- ensurecoverageinpracticaldetection,requiringahighlevelof ments.Duetothescarcityofreal-worldvulnerabilitydataand expertiseandthusyieldingsuboptimalresults.Earlymachine- |
topreventinaccuraciescausedbyindividualsamplevariations, learning-based vulnerability detection methods, such as those we conducted five repeated experiments, saving the results of based on metric program representations, typically employed the final generation. Each fold of the test set was evaluated in feature engineering to manually extract vulnerability-related each experiment, and the average result of each fold’s testing features. Classic methods include code churn [25]–[31], code was computed. The average F1 score over the five repeated complexity [26], [27], [29]–[33], coverage [26], [27], de- experiments reached 89.07%, with an average accuracy of pendency [26], [27], organizational [26], [27], and developer 90.41%. activity[25],[28],[29],[34],[35].Inrecentyears,researchers Real-worldvulnerabilitydetectionofteninvolveslarge-scale have started using deep learning methods to automatically code scanning, necessitating consideration of performance extract vulnerability features. overhead. The time overhead of each system is depicted Due to different program representations at various com- in Figure 8, with VulCNN exhibiting excellent performance pilation stages, deep learning-based program representation in this regard. We augmented VulCNN with a pixel row methodscanbecategorizedintothreetypesbasedontheorga- oversampling module to reduce the computation of the three nizational form of code representation: sequence-based [36]– central indicators for the PDG and trained it using grayscale [42], syntax tree-based [43]–[47], and graph-based [48]–[55]. images. Meanwhile, VulMCI also selected 100 lines as the VulDeePecker [10] slices the program, collects code snippets, function length threshold without increasing model training andtransformsthemintocorrespondingvectorrepresentations. overhead. Figure 7 illustrates the time overhead proportions Ultimately, these vectors are used to train a Bidirectional of the six models, among which VulMCI’s time overhead is Long Short-Term Memory (BLSTM) model for vulnerability similar to VulCNN’s, approximately one-sixth of Devign’s, detection. SySeVR [15] first performs syntactic analysis and and approximately one-fourth of SySeVR’s. then semantic slicing on vulnerable code, transforming sliced code into fixed-length vectors fed into a Bidirectional Gated V. DISCUSSION Recurrent Unit (BGRU) model for training. VulDeeLocator Throughout the entire system workflow, the static analysis [42] utilizes intermediate code to define program slices for for generating the Code Property Graph (CPG) incurs the vulnerability detection, proposing a new variant of Bidirec- highest computational cost. Processing a dataset comprising tionalRecurrentNeuralNetwork(BRNN),namelyBRNN-vdl, twenty thousand function samples requires over twenty hours. for vulnerability detection and localization. Devign [13] is agraph neural network-based model that encodes the original [9] Checkmarx. (2021) Checkmarx. [Online]. Available: https://www. function code into a joint graph structure containing rich checkmarx.com/ [10] Z. Li, D. Zou, S. Xu, X. Ou, H. Jin, S. Wang, Z. Deng, program semantics. The gated graph recurrent layer learns and Y. Zhong, “Vuldeepecker: A deep learning-based system node features by aggregating and propagating information in for vulnerability detection,” in Proceedings 2018 Network and the graph, and the Conv module extracts meaningful node DistributedSystemSecuritySymposium,Jan2018.[Online].Available: http://dx.doi.org/10.14722/ndss.2018.23158 representations for graph-level predictions. AMPLE [23] sim- [11] R. Russell, L. Kim, L. Hamilton, T. Lazovich, J. Harer, O. O¨zdemir, plified node representations based on Devign and designed an P. Ellingwood, and M. McConley, “Automated vulnerability detection edge-aware graph convolutional network module, addressing in source code using deep representation learning,” Cornell University -arXiv,CornellUniversity-arXiv,Jul2018. thechallengeofgraphneuralnetworkscapturingrelationships [12] X. Duan, J. Wu, S. Ji, Z. Rui, T. Luo, M. Yang, and Y. Wu, betweendistantgraphnodes.VulCNN[14]isascalablegraph- “Vulsniper: Focus your attention to shoot fine-grained vulnerabilities,” based vulnerability detection system that effectively converts in Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence, Aug 2019. [Online]. Available: http: function source code into images while preserving program //dx.doi.org/10.24963/ijcai.2019/648 semantics, suitable for large-scale vulnerability scanning. [13] Y.Zhou,S.Liu,J.Siow,X.Du,andY.Liu,“Devign:Effectivevulner- abilityidentificationbylearningcomprehensiveprogramsemanticsvia VII. CONCLUSION graph neural networks,” arXiv: Software Engineering,arXiv: Software Engineering,Sep2019. In this paper, we propose and validate that high-quality [14] Y. Wu, D. Zou, S. Dou, W. Yang, D. Xu, and H. Jin, “Vulcnn: An images with strong continuity can effectively improve the image-inspiredscalablevulnerabilitydetectionsystem,”inProceedings detectionaccuracyofConvolutionalNeuralNetworks(CNNs). of the 44th International Conference on Software Engineering, 2022, pp.2365–2376. Additionally, we introduce the use of CFG-based pixel row [15] Z.Li,D.Zou,S.Xu,H.Jin,Y.Zhu,andZ.Chen,“Sysevr:Aframework |
oversamplingmethod,whichsynthesizesnewsamplesbycon- for using deep learning to detect software vulnerabilities,” IEEE catenating between CFG node code, enhancing the continuity TransactionsonDependableandSecureComputing,p.2244–2258,Jul 2022.[Online].Available:http://dx.doi.org/10.1109/tdsc.2021.3051525 ofcodeimages.Weconducttheoreticalanalysisandparameter [16] X.Lv,T.Peng,J.Chen,J.Liu,X.Hu,R.He,M.Jiang,andW.Cao, studies, design and compare multiple oversampling methods, “Bovdgfe: buffer overflow vulnerability detection based on graph as well as some advanced vulnerability detection systems. feature extraction,” Applied Intelligence, p. 15204–15221, Jun 2023. [Online].Available:http://dx.doi.org/10.1007/s10489-022-04214-8 VulMCI achieves high detection performance and low time [17] M. Pagliardini, P. Gupta, and M. Jaggi, “Unsupervised learning overheadinboththeSARDandNVDdatasets,demonstrating of sentence embeddings using compositional n-gram features,” in its effectiveness. Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language ACKNOWLEDGMENT Technologies, Volume 1 (Long Papers), Jan 2018. [Online]. Available: http://dx.doi.org/10.18653/v1/n18-1049 This work was supported by the National Natural Science [18] F. Yamaguchi, N. Golde, D. Arp, and K. Rieck, “Modeling and Foundation of China under Grant 62203337. The authors discovering vulnerabilities with code property graphs,” in 2014 IEEE Symposium on Security and Privacy, May 2014. [Online]. Available: would like to express their gratitude to the creators of the http://dx.doi.org/10.1109/sp.2014.44 SySeVR dataset and the open-source code provided by the [19] G. E. Dahl, T. N. Sainath, and G. E. Hinton, “Improving VulCNN authors. deep neural networks for lvcsr using rectified linear units and dropout,” in 2013 IEEE International Conference on Acoustics, REFERENCES Speech and Signal Processing, May 2013. [Online]. Available: http://dx.doi.org/10.1109/icassp.2013.6639346 [1] N. I. of Standards and Technology. (2023) National vulnerability [20] D.P.KingmaandJ.Ba,“Adam:Amethodforstochasticoptimization,” database (nvd). Accessed on Date of Access. [Online]. Available: arXivpreprintarXiv:1412.6980,2014. https://nvd.nist.gov/ [21] (2018) Software assurance reference dataset. [Online]. Available: [2] J. Jang, M. Woo, and D. Brumley, “Redebug: finding unpatched code https://samate.nist.gov/SRD/index.php clones in entire os distributions,” ;login:: the magazine of USENIX & [22] (2018) Common weakness enumeration. [Online]. Available: http: SAGE,;login::themagazineofUSENIX&SAGE,Jan2012. //cwe.mitre.org/ [3] S. Kim, S. Woo, H. Lee, and H. Oh, “Vuddy: A scalable approach [23] X.-C. Wen, Y. Chen, C. Gao, H. Zhang, J. M.Zhang, and Q. Liao, for vulnerable code clone discovery,” in 2017 IEEE Symposium “Vulnerability detection with graph simplification and enhanced graph on Security and Privacy (SP), May 2017. [Online]. Available: representationlearning,”Feb2023. http://dx.doi.org/10.1109/sp.2017.62 [24] H.Sajnani,V.Saini,J.Svajlenko,C.Roy,andC.Lopes,“Sourcerercc: [4] J. Li and M. D. Ernst, “Cbcd: Cloned buggy code detector,” in 2012 scalingcodeclonedetectiontobig-code,”InternationalConferenceon 34th International Conference on Software Engineering (ICSE), Jun Software Engineering,International Conference on Software Engineer- 2012.[Online].Available:http://dx.doi.org/10.1109/icse.2012.6227183 ing,May2016. [5] Z. Li, D. Zou, S. Xu, H. Jin, H. Qi, and J. Hu, “Vulpecker: an [25] H. Perl, S. Dechand, M. Smith et al., “Vccfinder: Finding potential automated vulnerability detection system based on code similarity vulnerabilities in open-source projects to assist code audits,” in Pro- analysis,” in Proceedings of the 32nd Annual Conference on ceedings of the 22nd ACM SIGSAC Conference on Computer and Computer Security Applications, Dec 2016. [Online]. Available: CommunicationsSecurity,Denver,Colorado,USA,2015,pp.426–437. http://dx.doi.org/10.1145/2991079.2991102 [26] T.Zimmermann,N.Nagappan,andL.Williams,“Searchingforaneedle [6] N.H.Pham,T.T.Nguyen,H.A.Nguyen,andT.N.Nguyen,“Detection in a haystack: Predicting security vulnerabilities for windows vista,” ofrecurringsoftwarevulnerabilities,”inProceedingsoftheIEEE/ACM in Proceedings of the International Conference on Software Testing, internationalconferenceonAutomatedsoftwareengineering,Sep2010. VerificationandValidation,2010,pp.421–428. [Online].Available:http://dx.doi.org/10.1145/1858996.1859089 [27] P.Morrison,K.Herzig,B.Murphy,andL.Williams,“Challengeswith [7] FlawFinder. (2021) FlawFinder. [Online]. Available: http://www. applying vulnerability prediction models,” in Proceedings of the 2015 dwheeler.com/flawfinder/ SymposiumandBootcampontheScienceofSecurity,2015,pp.1–9. [8] Rough Audit Tool for Security. (2021) Rough Audit Tool [28] A. Meneely, H. Srinivasan, A. Musa, A. R. Tejeda, M. Mokary, and for Security. [Online]. Available: https://code.google.com/archive/p/ B. Spates, “When a patch goes bad: Exploring the properties of |
roughauditing-tool-for-security/ vulnerability-contributing commits,” in 2013 ACM/IEEE InternationalSymposiumonEmpiricalSoftwareEngineeringandMeasurement,2013, [49] X.Duan,J.-Z.Wu,T.-y.Luo,andetal.,“Vulnerabilityminingmethod pp.65–74. basedoncodepropertygraphandattentionbilstm,”JournalofSoftware, [29] Y. Shin, A. Meneely, L. Williams, and J. A. Osborne, “Evaluating vol.31,no.11,pp.3404–3420,2020. complexity,codechurn,anddeveloperactivitymetricsasindicatorsof [50] D. Cao, J. Huang, X. Zhang, and X. Liu, “Ftclnet: Convolutional software vulnerabilities,” IEEE Transactions on Software Engineering, lstmwithfouriertransformforvulnerabilitydetection,”inInternational vol.37,no.6,pp.772–787,2011. ConferenceonTrust,SecurityandPrivacyinComputingandCommu- [30] Y.ShinandL.Williams,“Cantraditionalfaultpredictionmodelsbeused nications(TrustCom),Guangzhou,China,2020,pp.539–546. for vulnerability prediction,” Empirical Software Engineering, vol. 18, [51] M.Li,C.Li,S.Li,Y.Wu,B.Zhang,andY.Wen,“Acgvd:Vulnerability no.1,pp.25–59,2013. detectionbasedoncomprehensivegraphviagraphneuralnetworkwith [31] J.Walden,J.Stuckman,andR.Scandariato,“Predictingvulnerablecom- attention,” in International Conference on Information and Communi- ponents:Softwaremetricsvstextmining,”inInternationalSymposium cationsSecurity,Chongqing,China,2021,pp.243–259. onSoftwareReliabilityEngineering,2014,pp.23–33. [52] X.Cheng,H.Wang,J.Hua,G.Xu,andY.Sui,“Deepwukong:Statically [32] S. Moshtari, A. Sami, and M. Azimi, “Using complexity metrics to detecting software vulnerabilities using deep graph neural network,” improve software security,” Computer Fraud & Security, vol. 2013, ACMTransactionsonSoftwareEngineeringandMethodology(TOSEM), no.5,pp.8–17,2013. vol.30,no.3,pp.1–33,2021. [33] A.Younis,Y.Malaiya,C.Anderson,andI.Ray,“Tofearornottofear [53] W.Zheng,Y.Jiang,andX.Su,“Vulspg:Vulnerabilitydetectionbased thatisthequestion:Codecharacteristicsofavulnerablefunctionwith on slice property graph representation learning,” in International Sym- an existing exploit,” in Proceedings of the Sixth ACM Conference on posiumonSoftwareReliabilityEngineering,Wuhan,China,2021. DataandApplicationSecurityandPrivacy,2016,pp.97–104. [54] H.Wang,G.Ye,Z.Tang,andetal.,“Combininggraph-basedlearning with automated data collection for code vulnerability detection,” IEEE [34] A. Bosu, J. C. Carver, M. Hafiz, P. Hilley, and D. Janni, “Identifying TransactionsonInformationForensicsandSecurity,2020. thecharacteristicsofvulnerablecodechanges:Anempiricalstudy,”in [55] V.Okun,A.Delaitre,andP.E.Black,“Reportonthestaticanalysistool Proceedings of the 22nd ACM SIGSOFT International Symposium on exposition (sate) iv,” in NIST Special Publication, vol. 500, Jan 2013, FoundationsofSoftwareEngineering,2014,pp.257–268. p.297. [35] A. Meneely and L. Williams, “Strengthening the empirical analysis of therelationshipbetweenlinus’lawandsoftwaresecurity,”inProceed- ings of the 2010 ACM-IEEE International Symposium on Empirical Software Engineering and Measurement, Bolzano-Bozen, Italy, 2010, pp.1–10. [36] G.Grieco,G.L.Grinblat,L.Uzal,S.Rawat,J.Feist,andL.Mounier, “Towardlarge-scalevulnerabilitydiscoveryusingmachinelearning,”in Proceedings of the Sixth ACM Conference on Data and Application SecurityandPrivacy,NewOrleans,Louisiana,USA,2016,pp.85–96. [37] F.Wu,J.Wang,J.Liu,andW.Wang,“Vulnerabilitydetectionwithdeep learning,”inProceedingsoftheInternationalConferenceonComputer andCommunications,Chengdu,China,2017,pp.1298–1302. [38] R.Russell,L.Kim,L.Hamiltonetal.,“Automatedvulnerabilitydetec- tioninsourcecodeusingdeeprepresentationlearning,”inInternational ConferenceonMachineLearningandApplications(ICMLA),Orlando, Florida,USA,2018,pp.757–762. [39] H.Yan,S.Luo,L.Pan,andY.Zhang,“Han-bsvd:Ahierarchicalatten- tionnetworkforbinarysoftwarevulnerabilitydetection,”Computers& Security,vol.108,p.102286,2021. [40] X. Li, B. Feng, G. Li, T. Li, and M. He, “A vulnerability detection system based on fusion of assembly code and source code,” Security andCommunicationNetworks,2021,publishedonline. [41] J. Tian, W. Xing, and Z. Li, “Bvdetector: A program slice-based binarycodevulnerabilityintelligentdetectionsystem,”Informationand SoftwareTechnology,vol.123,p.106289,2020. [42] Z. Li, D. Zou, S. Xu, Z. Chen, Y. Zhu, and H. Jin, “Vuldeelocator: A deeplearning-basedfine-grainedvulnerabilitydetector,”IEEETransac- tionsonDependableandSecureComputing,Apr2021. [43] Y. Li, S. Wang, T. T. Nguyen, and S. Van Nguyen, “Improving bug detection via context-based code representation learning and attention- based neural networks,” Proceedings of the ACM on Programming Languages,vol.3,pp.1–30,2019. [44] A. Tanwar, H. Manikandan, K. Sundaresan, P. Ganesan, S. K. Chandrasekaran, and S. Ravi, “Multi-context attention fusion neu- ral network for software vulnerability identification,” arXiv preprint arXiv:2104.09225,2021. |
[45] H. Zhang, Y. Bi, H. Guo, W. Sun, and J. Li, “Isvsf: Intelligent vulnerabilitydetectionagainstjavaviasentence-levelpatternexploring,” IEEESystemsJournal,pp.1–12,2021. [46] S.Wang,T.Liu,andL.Tan,“Automaticallylearningsemanticfeatures fordefectprediction,”inIEEE/ACM38thInternationalConferenceon SoftwareEngineering,Austin,Texas,USA,2016,pp.297–308. [47] G. Lin, J. Zhang, W. Luo, and et al., “Poster: Vulnerability discov- ery with function representation learning from unlabeled projects,” in Proceedings of the 2017 ACM SIGSAC Conference on Computer and CommunicationsSecurity,Dallas,Texas,USA,2017,pp.2539–2541. [48] X.Duan,J.Wu,S.Ji,Z.Rui,T.Luo,M.Yang,andY.Wu,“Vulsniper: Focus your attention to shoot fine-grained vulnerabilities,” in Interna- tionalJointConferencesonArtificialIntelligence,Macao,China,2019, pp.4665–4671. |
2402.18818 CEBin: A Cost-Effective Framework for Large-Scale Binary Code Similarity Detection HaoWang1,ZeyuGao1,ChaoZhang1,MingyangSun2,YuchenZhou3,HanQiu1,XiXiao4 1TsinghuaUniversity,Beijing,China 2UniversityofElectronicScienceandTechnologyofChina,Chengdu,China 3BeijingUniversityofTechnology,Beijing,China 4TsinghuaUniversity,Shenzhen,China {hao-wang20,gaozy22}@mails.tsinghua.edu.cn,{chaoz,qiuhan}@tsinghua.edu.cn 2020090918021@std.uestc.edu.cn,zhouyuchen@emails.bjut.edu.cn,xiaox@sz.tsinghua.edu.cn ABSTRACT malwaredetectionandclassification[3,19,25],third-partylibrary Binarycodesimilaritydetection(BCSD)isafundamentaltechnique detection[49,59],softwareplagiarismdetection[32,33]andpatch forvariousapplication.ManyBCSDsolutionshavebeenproposed analysis[20,24,55].BCSD’sgrowingimportanceintheseareas recently,whichmostlyareembedding-based,buthaveshownlim- highlightsitsroleasaversatiletoolinenhancingsoftwaresecurity. itedaccuracyandefficiencyespeciallywhenthevolumeoftarget Recently,wehavewitnessednumerousBCSDsolutionsdeploy- binaries to search is large. To address this issue, we propose a ingdeeplearning(DL)modelsforfeatureextractionandcompari- cost-effectiveBCSDframework,CEBin,whichfusesembedding- son[9,10,17,31,36,37,45,54,56,57,60],showingthatDLmodels basedandcomparison-basedapproachestosignificantlyimprove canlearnfeaturesofbinaryfunctionstoidentifysimilaronesacross accuracywhileminimizingoverheads.Specifically,CEBinutilizes differentcompilers,compilationoptimizationlevels,instructionset arefinedembedding-basedapproachtoextractfeaturesoftarget architectures(ISAs),orevensomeobfuscationtechniques.Among code,whichefficientlynarrowsdownthescopeofcandidatesimilar them,theSOTAapproaches[1,29,34,41,51,57]trainlargeassem- codeandboostsperformance.Then,itutilizesacomparison-based blylanguagemodelstolearntherepresentationofbinarycode. approachthatperformsapairwisecomparisononthecandidatesto Despitethepromisingprogress,currentDL-basedBCSDsolu- capturemorenuancedandcomplexrelationships,whichgreatlyim- tionsarefacingpracticalchallengeswhenapplyingtoreal-world provestheaccuracyofsimilaritydetection.Bybridgingthegapbe- tasks,suchasdetecting1-dayvulnerabilitiesinthesoftwaresupply tweenembedding-basedandcomparison-basedapproaches,CEBin scenariowherethevolumeoftargetbinariestomatchishuge.For isabletoprovideaneffectiveandefficientsolutionfordetecting instance,onceanewvulnerabilityisdiscoveredintheupstream similarcode(includingvulnerableones)inlarge-scalesoftware codes,efficientlyandaccuratelyidentifyingwhichdownstream ecosystems.Experimentalresultsonthreewell-knowndatasets softwarehassimilarcodeandmaybeaffectediscrucial.Forsuch demonstratethesuperiorityofCEBinoverexistingstate-of-the-art realworldtasks,alargecollectionoffunctions(e.g.,allfunctionsof (SOTA)baselines.TofurtherevaluatetheusefulnessofBCSDin thesoftwareecosystem)mustbemaintainedandmatchedagainst realworld,weconstructalarge-scalebenchmarkofvulnerability, thequeryfunction(e.g.,thefunctionwiththe1-dayvulnerability), offeringthefirstpreciseevaluationschemetoassessBCSDmeth- whichbringsthefollowingthreeprimarychallenges. odsforthe1-dayvulnerabilitydetectiontask.CEBincouldidentify First,existingBCSDmethodshaveapoorbalancebetweenaccu- thesimilarfunctionfrommillionsofcandidatefunctionsinjusta racyandefficiency.ExistingBCSDmethodscanberoughlyclassi- fewsecondsandachievesanimpressiverecallrateof85.46%on fiedintocomparison-based[2,11,30,31,46]andembedding-based thismorepracticalbutchallengingtask,whichareseveralorder approaches[1,9,29,34,37,41,51,57].Comparison-basedmeth- ofmagnitudesfasterand4.07×betterthanthebestSOTAbaseline. odsbuildamodeltotakeapairofbinaryfunctionsasinputsand Ourcodeisavailableathttps://github.com/Hustcw/CEBin. comparetheirsimilaritydirectly,whichoftenhavehighoverheads andhigheraccuracy.Foragivenqueryfunction,ithastoquery themodeltocomparewitheachfunctioninthetargetdatasetto CCSCONCEPTS locatesimilarones,whichmakesitnon-scalable.Ontheotherhand, • Security and privacy → Software reverse engineering; • embedding-basedmethodsonlytakeasinglebinarycodeasinput Computingmethodologies→Machinelearning. andencodeitshigher-levelfeaturestoanembeddingspace(i.e., numericalvectors),andthenapproximatethesimilarityofagiven KEYWORDS pairoffunctionsinthisembeddingspaceusingthevectordistance BinaryAnalysis,SimilarityDetection,VulnerabilityDiscovery,Neu- (e.g., cosine), which are more scalable but have lower accuracy. ralNetworks Theembedding-basedapproachismoreefficient,sinceeachinput functiononlyneedstobeencodedonceanditssimilaronescould belocatedintheembeddingspacewithfastneighboursearchalgo- 1 INTRODUCTION rithm.Butthecomparison-basedapproachingeneralhashigher Binarycodesimilaritydetection(BCSD)isanemergingandchal- accuracy,sinceittakesapairofbinaryfunctionsasinputsand |
lengingtechniqueforaddressingvarioussoftwaresecurityprob- enablesthemodeltolearnpairwisefeatures,whiletheembedding- lems.BCSDenablesdeterminingwhethertwobinarycodefrag- basedapproachonlytakesonefunctionasinputandcanonlylearn ments(e.g.,functions)aresimilarorhomologous.BCSDcanbe thefeatureofonefunction. broadlyadoptedformanydownstreamtaskslike1-dayvulnera- bilitydiscovery[1,5–8,12,14,15,17,21,31,34,35,43,44,48,54], 4202 beF 92 ]ES.sc[ 1v81881.2042:viXraWang,etal. ThesecondchallengeisthatexistingBCSDmethodscannotpro- fine-tunetheembeddingmodel.Asdirectlyaddingalargenum- videanacceptableaccuracyperformance(i.e.,recall)whensearch- berofnegativesamplesintroducessignificanttrainingcost,RECM ingsimilarfunctionsfromalargepooloffunctionsets.Pointedout solvesthischallengebymaintaininganembeddingcacheofnegative inbothpreviousstudy[51,53]andourexperimentalresults(see samplesduringtrainingandreusingpreviousembeddings.Then, Section5.1),theperformanceofexistingBCSDdeclinesrapidlyas theembeddingmodelwastrainedusingmomentumcontrastive thescaleoffunctionstobesearchedexpands.Themainreasonis learning[18]bysplittingtheencodermodelintotwoencoders,in- thatthetrainingobjectiveofthesemodelsdoesnotmatchthismore cluding(1)thequeryencodertogettherepresentationofthequery challengingtask.Forinstance,existingworkstypicallyeitheruse function,and(2)thereferenceencodertogettherepresentation supervisedlearningtodistinguishbetweensimilarordissimilar offunctionsinthefunctionset.Inthisway,CEBindoesnotneed functionpairs,oremploycontrastivelearningtoensurethedistance torecordthegradientofthereferenceencoderduringtraining, betweensimilarfunctionsiscloser.Suchmodelsareonlytrained whichsignificantlyreducesthetrainingcostswhileachievinga todifferentiatewhichfunctionfromasmallnumberoffunc- greatimprovementintheembeddingmodel’sperformance. tionsetsissimilartothequeryfunction.Thistrainingobjective Addressing the third challenge, we aim for an objective and cannotbesimplyadaptedtothelarge-scalefunctiondatasetssuch comprehensiveevaluationofBCSD’svulnerabilitydetectioncapa- asthe1-dayvulnerabilitydetectiontask(e.g.,millionsoffunctions bilities.Tothisend,wechosearangeofwidelyusedlibrariesand tocompareinthesoftwaresupplychain),sinceinthereal-world softwareincorporating187vulnerabilitieslistedintheCVEdata- scenariostheratioofnegativesamples(i.e.,dissimilarfunctions)is base.Weidentifythevulnerablefunctionscorrespondingtoeach waylargerthanthesettingsofmodeltraining. CVEandbuildabenchmarkwith27,081,862functionsand12,086 Thethirdchallengeisthatthecommunityhasnolarge-scale vulnerablefunctionsintotal.Withthisbenchmark,wetakeasolid accessiblevalidationdatasetforBCSDtasks,suchas1-dayvulner- steptowardsevaluatingBCSDschemesinreal-worldscenariosand abilitydetection.ExistingBCSDingeneralonlydemonstratesa helpfutureresearchinthisdomain. proof-of-conceptexperiment,whichinvolvesasmallvulnerability We implement CEBin and evaluate it on three well-regarded datasetconsistingofsomeCVEs(usuallylessthan20)[1,9,10, BCSDdatasets.TheresultsshowthatCEBinconsiderablysurpasses 22,34,35,37,51,52,56]andanumberoftargetcodestosearch existingSOTAsolutions.IntheBinaryCorpdataset,CEBinleads (e.g.,abatchofIoTfirmware).Thesemethodshavetwodrawbacks. withan84.5%accuracyinidentifyingfunctionsfrom10,000can- (1)TheychoosedifferentsetsofCVEs,causingthesearchperfor- didates,surpassingthecurrentbestsolution’sresult(i.e.,57.1%). manceisnotcomparable.(2)Theycannotevaluatetherecallrate Ontwomoredemandingcross-architecturedatasets,CEBinattains sinceitisimpossibletodeterminehowmanyvulnerabilitiesexist 94.6%and87.0%Recall@1,respectively,significantlyoutperforms inthefirmwaretobetested.Notethat,therecallrateiscriticalto thebestbaselines(i.e.,9.6%and10.9%).Additionally,weconduct ensurecoveragecomprehensivenessforunderstandinghow1-day experimentsonalarge-scalecross-architecture1-dayvulnerability vulnerabilitiesaffectdownstreamsoftware. detectiontaskandobtainarecallof85.46%,whichis4.07×greater To address the above challenges, we propose CEBin, a novel thantheSOTA.Insummary,ourcontributionsareasfollows: Cost-EffectiveBinarycodesimilaritydetectionframework.CEBin • We propose a cost-effective BCSD framework CEBin, which fusesembedding-basedandcomparison-basedapproachestosignif- fusesembedding-basedandcomparison-basedapproachesina icantlyimproveaccuracywhileminimizingoverheads.Toimprove hierarchicalinferencepipelinetosignificantlyimproveaccuracy theaccuracyperformanceoftheembeddingmodelcomponent, performancewhilemaintainingefficiency. CEBinproposesaReusableEmbeddingCacheMechanism(RECM) • WeproposeaReusableEmbeddingCacheMechanism(RECM) tointroducemorenegativesamplesduringmodelfine-tuningby toenhancetheperformanceofembeddingmodelswhilepre- reusingthenegativeembeddings.Thisembeddingmodelcouldeffi- servingefficienttraining. |
cientlylocatesimilarfunctionswithrelativelyhighaccuracy,thus • Weconstructalargebenchmarkofvulnerabilitiesandbinary greatlynarrowingdownthescopeofcandidatesimilarfunctions. functions,offeringapreciseevaluationschemetoassessBCSD Tofurtherimprovetheaccuracyperformance,CEBinadoptsanex- methodsforthe1-dayvulnerabilitydetectiontask. tracomparisonmodelcomponent,whichsearchessimilarfunctions • Weconductthoroughexperimentsanddemonstratetheout- amongtheremainedcandidatesinapairwisecomparisonmanner. standing performance of CEBin for large-scale BCSD tasks, Specifically,wefusetheembedding-basedandcomparison-based whichcouldidentifythesimilarfunctionfrommillionsinjusta models.CEBinadoptsanembeddingmodelforspeedandintroduces fewsecondsandachieveanimpressiveaveragerecallof85.46%. acomparisonmodelforaccuracy.Toaddresstheinabilityofthe • WereleaseCEBinandthelargebenchmarkofvulnerabilitiesto comparisonmodeltoscaletolarge-scalefunctions,CEBinadoptsa theresearchcommunitytofacilitatefutureresearch. hierarchicalapproach,withtheembeddingmodelretrievingtop-K functionsfromalargefunctionpool,followedbythecomparison 2 BACKGROUNDANDRELATEDWORKS modelthatselectsthefinalsimilaronesfromthetop-Kfunctions. Withthisinferenceprocess,weconstrainthecosttoberelatedto 2.1 BinaryCodeSimilarityDetection(BCSD) K.TheexperimentsshowthatCEBincanincreasetheperformance BCSD technique is utilized to identify the similarities between byalargemarginwithahighspeedachieved. binarycodefragmentssuchasfunctions.BCSDcanbeadopted Forthesecondchallenge,weproposeaReusableEmbedding formanytaskslikevulnerabilitydetection,malwareclassification, CacheMechanism(RECM)tointroducemorenegativesamplesto andcodeplagiarismdetection.Oneofthemostchallengingtasks isthesoftwaresupplychainvulnerabilitydetection[34,51].ForCEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection combinesCNN,LSTM,anddeepneuralnetworkstoascertainfunc- x y x y tionequivalenceacrosscompilersandarchitectures,whileanother work[47]decomposecodeintofragmentsforfast,accurateanal- Model f Model f ysisusingfeed-forwardneuralnetworks.GMN[30]introducesa Model g cross-graphattentionmechanismwithinitsDNNmodelforgraph matchingtoevaluatesimilarityscoresbetweengraphicalelements. Similarity Similarity = cos(f(x), f(y)) = g(x, y) 2.1.3 SummaryofExistingApproaches. Theembedding-basedap- proachhasbecomemainstreaminBCSDresearchinrecentyears. Figure1:Theembedding-basedmodel(left)representsfunc- Comparedtothecomparison-basedapproach,itcanprovideef- tions𝑥,𝑦asembeddingsandcalculatesimilaritywithsimilar- ficientinferenceandisthereforesuitableforscalingtolarge-scale itymetrics(e.gcosine).Thecomparison-basedmodel(right) BCSD application scenarios, but has lower accuracy. On the one takesapairoffunctionsandoutputstheirsimilarity. hand, a recent paper [35] measured that the comparison-based modelGMN[30]achievedthebestperformanceamongallpublicly instance,oncea1-dayvulnerabilityisdiscoveredinawidely-used availableBCSDsolutions.Ontheotherhand,wecaninferthis foundationalopen-sourcecomponent,efficientlyandaccurately resultinatheoreticway.AsshowninFigure1,givenrawinputs locatingtheaffecteddownstreamsoftware(mostlyonlybinaries 𝑥 and𝑦oftwobinarycodes,theembedding-basedmodellearns withoutsourcecode)ascomprehensiveaspossibleiscrucial. 𝑓 andusesdistancemetrics(e.g.cosine)tocalculatesimilarityas Various BCSD approaches have been investigated, including cos(𝑓(𝑥),𝑓(𝑦)),whilethecomparison-basedmodellearns𝑔and graph matching [16, 61], tree-based methods [44], and feature- calculatessimilarityas𝑔(𝑥,𝑦).Itisobviousthat,𝑔(𝑥,𝑦)ismore basedtechniques[13,38].Recently,deeplearningtechniqueshave expressivethancos(𝑓(𝑥),𝑓(𝑦)).Inotherwords,awell-trained emergedaspopularmethodsforBCSDfortheiraccuracyandability comparisonmodelcanoutperformawell-trainedembeddingmodel, tolearncomplexfeaturesautomatically.Indeeplearningmodels, tobettercapturethefeaturesbetweentwobinarycodes. twoprimarymethodscanbedistinguished:embedding-basedand comparison-basedapproaches(seeoverviewinFigure1). 2.2 ContrastiveLearning Thegoalofcontrastivelearningistoincreasethesimilaritybe- 2.1.1 Embedding-basedApproaches. Therecentdevelopmentof tweensemanticallysimilardatapoints,whicharecalledembed- deepneuralnetworks(DNNs)hasinspiredresearcherstodelve dings,whileincreasingdissimilaritybetweensemanticallyunre- into embedding-based BCSD. Embedding-based BCSD methods lateddatapointsinthelatentrepresentationspace.Thisisachieved primarilyfocusonextractingfeaturesfromfunctionsandrepresent byusingpairwisecomparisoninunsupervisedorself-supervised theminalowerdimensionspace(i.e.,“embedding”).Priorresearch manners,measuringinstancedistanceusingacontrastivelossfunc- hasemployedDNNsasfeatureextractorsfortransformingbinary tion.Forinstance,Trex[41]employsapairwiselossfunctionto functionsintoanembeddingspace.Todeterminesimilarity,these minimizethedistancebetweenthegroundtruth.Someprevious functions’embeddingscanbecomparedusingdistancemetrics. works [30, 51, 58] utilize triplet loss to reduce the distance be- |
Oneadvantageoftheembedding-basedapproachistheuseoffixed tweenpositivepairsandincreasethedistancebetweennegative representations that can be precomputed.When calculating the pairs.SAFE[37]andOrderMatters[57]implementtheoutputof similaritybetweenanewfunctionandexistingones,onlythenew aSiamesenetworkasalossfunction,minimizingthedistancebe- function’sembeddingmustbeextractedfordistancemeasurement. tweenpositivepairs.Vulhawk[34]appliescross-entropylossto Genius[15]andGemini[54]employclusteringandgraphneural reducethedistancebetweengroundtruthandmaintaindistance networks(GNNs)forfunctionalvectorizationbutarehamperedby fromnegativepairsusingamany-to-manyapproach. theirrelianceoncontrolflowgraph(CFG)thatcapturelimitedse- mantics,akintoSAFE’s[37]approachmarredbyout-of-vocabulary (OOV)challenges.Extendingbeyondtheseconfines,subsequent 3 METHODOLOGY modelslikeGraphEmb[36]andOrderMatters[57]utilizedeepneu- 3.1 OverviewoftheFramework ralnetworkstoencodesemanticinformation,withAsm2Vec[9] TheCEBinframeworkoperatesinthreeprimarystages:pre-training, addressing the CFG’s structural nuances through unsupervised fine-tuning,andinference,depictedinFigure2.Inthepre-training learning. This progress sets the stage for the integration of ad- phase,weutilizeacomprehensivedatasettotrainalanguagemodel vancedpre-trainedmodelssuchasBERT,asseeninjTrans[51], optimizedforrepresentingbinarycode.Duringfine-tuning,thispre- Trex[41],andVulHawk[34],whichleveragethesemodels’capa- trainedlanguagemodelisfurtherrefinedtoproducetwodistinct bilitiestoenhancetheunderstandingandidentificationofbinary models:anembeddingmodelandacomparisonmodel.Anotable codefunctionalities. enhancementduringthisstageistheintegrationoftheReusable 2.1.2 Comparison-basedApproaches. Comparison-basedapproaches EmbeddingCacheMechanism(RECM),designedtointroducea inbinaryanalysisdirectlymeasurefunctionsimilarityusingraw plethoraofnegativesamplesforthefine-tuningoftheembedding dataorfeatureanalysis.Methodsvary:FOSSIL[2]integratesBayesian model. Inthefinalinferencephase,weemploytheembedding networkstoassessfreeopen-sourcesoftwarefunctionsthrough modeltoretrievethetopKcandidatefunctionsclosesttothequery syntax,semantics,andbehavior.Incontrast,𝛼-Diff[31]applies function.Subsequently,thecomparisonmodelfacilitatesprecise CNNstorawbytes,requiringextensivetrainingdata.BinDNN[28] finalselections.① Pre-training ② Fine-tuning ③ Inference Embedding Model Top-K Retrieval Pre-trained Model Comparison Model Final Selection Wang,etal. ① Pre-training ② Fine-tuning ③ Inference embeddingmodel,thequeryfunctionandthereferencefunctionare encodedintoembeddings,representedas𝑄1:𝑛and𝑅1:𝑛respectively. Comparison We then retrieve the embeddings 𝑅′ in the embedding cache, Model Final Selection thesizeoftheebmeddingcacheisde1 n:𝐿 otedas𝐿.Wecomputethe Pre-trained Model dotproductbetween𝑄1:𝑛and𝐶𝑜𝑛𝑐𝑎𝑡𝑒(𝑅1:𝑛,𝑅 1′ :𝐿).Onlythepairs Embedding Top-K Retrieval 𝑄1:𝑛·𝑅1:𝑛arepositivesamples,whileallothersarenegativesamples. Model Afterupdatingtheembeddingmodel,theembeddingcachewill alsobeupdatedbythenewlyencodedreferencefunctions𝑅1:𝑛. Reusable Embedding While the query encoder is updated by gradients, the refer- Cache Mechanism enceencoderisfreezedduringencodingandthenupdatedusinga momentum-basedapproach[18].Whenfine-tuningtheembedding Figure2:TheWorkflowofCEBin. model,weapplytheInfoNCEloss[39]tomaximizethemutual informationbetweenpositivepairsandnegativesamples.TheIn- 3.2 Pre-training foNCEloss,givenapositivepair(𝑄 𝑖,𝑅 𝑖)andasetofnegativepairs 3.2. 1① P Dr ae t- atra Pi rn ei pn ag ration. W②e F uin se e- ttu hn rein eg datasets,Bina③ry I Cnf oe rr pen [c 5e 1], (𝑄 𝑖,𝑅 𝑗) 𝑗≠𝑖,isdefinedas: Cisco[35],andTrex[41]asourpre-trainingcorpus.Weemploy B lifi tna thry eN fuin nj ca ti1 oI nfn o sf lo tlN o owC BE i in nL g ao rs Ps ya Nlm inT jaErm ’e sebe Ind[d2 ti e9ng r] mMtoo ed dee ilx at tr ea Lct anfuT gon upc a-kt g iRo eent (r Isie Lva )anl td o L𝐸 =−log (cid:205)𝑁 𝑗e =x 1p ex(𝑓 p( (𝑄 𝑓(𝑖 𝑄,𝑅 𝑖𝑖 ,) 𝑅) 𝑗)), (1) normPr ae l- itr za eine bd i nM ao rd yel functionsacrossvariousISAs.WeusetheWord- where𝑁 isthetotalnumberofpairs,and𝑓(·,·)isthesimilarity Piece[27]algorithmtotrainatokenizeronthewholeassembly functionbetweentwoembeddings.Wedenotetheparametersof Comparison Model Final Selection codedatasetsandTprieprlfeotLrmossalosslessencodingofassemblycode queryencoderandreferenceencoderas𝜃 𝑞 and𝜃 𝑟 respectively.We withoutnormalizationonstringandnumber,solvingtheproblem usemomentumtoupdatethereferenceencoderatthesametime: ofOut-of-Vocabulary(OOV). 𝜃𝑟 ←𝑚𝜃𝑟 +(1−𝑚)𝜃𝑞 (2) 3.2.2 ModelArchitecture. WechosetheTransformer[50]asthe wheremisthemomentumcoefficientandisusuallysetlarge(e.g., basearchitectureforourmodelbecausebothpreviouswork[35] 0.99).Duringthetrainingoftheembeddingmodel,weonlyupdate andourevaluationresultsinSection5.1ofthebaselinesindicate 𝜃 𝑞 withback-propagation. thatTransformer-basedmethodsoutperformotherdeeplearning WiththeintegrationofRECM,wecanenlargethesizeoftrain- |
approaches.BecausejTrans[51]performsbestinourevaluation, ingbatchesandintroducelargenegativesampleswithincreasing wechoosetousejTransasthebasemodelandutilizethesame tinytrainingcosts.ComparedtonotintegratingRECM,whenthe pretrainingtasks. numberofreferencefunctionsreaches𝑁 =𝑛+𝐿,trainingonestep requiresanincreaseof𝐿/𝑛timesinforwardandbackwardcom- 3.3 Fine-tuning putations,andthememoryusagealsoincreasesbyapproximately The fine-tuning process is divided into two stages as shown in 𝐿/𝑛times.Forinstance,inexperimentsofSection5whereweused Figure3.Stage1focusesontrainingtheembeddingmodel,while 8V100GPUsfortrainingwith𝑛 = 128and𝐿 = 8,192.Without integratingRECM,itwouldrequireabout512V100GPUswhich Stage2trainsthecomparisonmodel. isextremelyexpensive.Figure8showstheimpactofthesizeof 3.3.1 RECMIntegratedEmbeddingModelTraining. Asmentioned theembeddingcacheontheperformanceoftheembeddingmodel, intheSection1,thesecondchallengepointsoutthatthemainissue whichshowsthatourdesigncangreatlyenhancetheperformance withthecurrentSOTAmethodsisthatthetrainingobjectiveof oftheembeddingmodel. theseapproachesdoesnotmatchthemorechallengingreal-world scenarios.Notethatintroducingmorenegativesamplesisessential 3.3.2 ComparisonModelTraining. Ourmotivationforintroducing thecomparisonmodelisinspiredbyimagesimilaritydetection toimprovingthemodel’sdiscriminationcapabilities.Astraight- scenarios. The direct comparison method enables the model to forwardapproachwouldbetodirectlysamplealargenumberof compareinstancesside-by-side,allowingforatoken-by-tokencom- negative examples during the training phase of the embedding parisonofthefunctions.Thisapproachismorepreciseforsimilarity modelforcontrastivelearning.However,addingalargenumberof detectiontasksthantheindirectcomparisonmethod. negativesamplesinanend-to-endtrainingmannerrequiressub- To train the comparison model, we initialize it with the pre- stantialcomputationalresources,suchasavastamountofGPUs. trainedmodelandmodifytheinputtoacceptapairoffunctions Toaddressthischallenge,weproposeaReusableEmbedding simultaneously.Theoutputofthecomparisonmodelrepresentsthe CacheMechanism(RECM)toreusepreviouslyencodedembeddings. similaritybetweenthegivenpairoffunctions.Duringtraining,we Wefirstsplittheembeddingmodelintoaqueryencoderanda inputabatchofpositivepairs,where𝑄 and𝑅 formapositivepair, referenceencoder.Thetrainingdataisformattedasapair(𝑄 𝑖,𝑅 𝑖) 𝑖 𝑖 fedintothemodel,where𝑄 and𝑅 respectivelyrepresentthequery and𝑄 𝑖 and𝑅 𝑖+1serveasanegativepair.Weconcatenatethefunc- 𝑖 𝑖 tionpairsandprovidethemasinputtothemodel.Wethenusethe function and the reference function, and they are semantically tripletlosstotrainthecomparisonmodeltodiscriminatebetween equivalentbecausetheyarecompiledfromthesamesourcecode. positiveandnegativepairseffectively,whichcanbeformulatedas: Asshowninthestage1ofFigure3,afterbeingencodedbythe 1https://binary.ninja L𝐶 =max(0,𝐷(𝑄𝑖,𝑅𝑖)−𝐷(𝑄𝑖,𝑅𝑖+1)+𝛼), (3) Stage 1: Embedding Model Training Stage 2: Comparison Model Training Gradient InfoNCELoss TripletLoss Gradient Q 1 Q1·R1 Q1·R2 ... Q1·Rn Q1·R' 1 Q1·R' 2 Q1·R' 3 ... Q1·R' k Comparison Model Q 2 Q2·R1 Q2·R2 ... Q2·Rn Q2·R' 1 Q2·R' 2 Q2·R' 3 ... Q2·R' k ... ... ... ... ... ... ... ... ... ... Q R Q R 1 1 1 2 Q n Qn·R1 Qn·R2 ... Qn·Rn Qn·R' 1 Qn·R' 2 Qn·R' 3 ... Qn·R' k Q 2 R 2 Q 2 R 3 ... ... Q R Q R n n n 1 ' ' ' ' R 1 R 2 ... R n R1 R2 R3 ... Rk Positive Negative Pairs Pairs Embedding Model Reusable Embedding Cache Concatenation Query Encoder Reference Encoder R 1 ... R n R' 1 ... R' k-n Updated Reusable Embedding Cache Query Reference Query Reference Function Function Function FunctionCEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection Stage 1: Embedding Model Training Stage 2: Comparison Model Training Gradient InfoNCELoss TripletLoss Gradient Q1 Q1·R1 Q1·R2 ... Q1·RnQ1·R' 1Q1·R' 2Q1·R' 3 ... Q1·R' L Comparison Model Q2 Q2·R1 Q2·R2 ... Q2·RnQ2·R' 1Q2·R' 2Q2·R' 3 ... Q2·R' L ... ... ... ... ... ... ... ... ... ... Q1 R1 Q1 R2 Qn Qn·R1 Qn·R2 ... Qn·RnQn·R' 1Qn·R' 2Qn·R' 3 ... Qn·R' L Q2 R2 Q2 R3 ... ... Qn Rn Qn R1 R1 R2 ... Rn R' 1 R' 2 R' 3 ... R' L Positive Negative Pairs Pairs Embedding Model Reusable Embedding Cache Concatenation Query Encoder Reference Encoder R1 ... Rn R' 1 ... R' L-n Updated Reusable Embedding Cache Query Reference Query Reference Function Function Function Function Figure3:Theillustrationoffine-tuningphaseforCEBin.Instage1,semanticallyequivalentfunctionpairs(𝑄 𝑖,𝑅 𝑖)areencoded withqueryencoderandthereferenceencoderrespectively.Thecorrespondingpairs(𝑄 𝑖,𝑅 𝑖)areconsideredaspositivepairs. Andotherpairs(𝑄 𝑖,𝑅 𝑗)𝑖≠𝑗 alongwithallpairs(𝑄 𝑖,𝑅′ 𝑗)containingpreviousreferencefunctionsintheResuableEmbedding Cacheareconsideredasnegativeparis.TheInfoNCELossiscalcuatedgivenpositivepairsandmassivenegativepairs.The lossisback-propagatedtoupdatequeryencoderandmomentumisusedtoupdatethereferneceencoder.Instage2,pairs |
offunctionsarefeedintomodelsimultaneouslyafterconcatenation.(𝑄 𝑖,𝑅 𝑖)isconsideredasapositivepairand(𝑄 𝑖,𝑅 𝑖+1)is consideredasanegativepair.Thenweusethetriplelosstotrainthecomparisonmodel. where𝐷(·,·)representsthesimilarityscoreoutputbycompari- pool’sembeddingvectors.BybuildingavectorindexusingANN, sonmodeland𝛼 isthemarginofthepositiveandnegativepairs. ourmodelcanhandlelarge-scaleBCSDscenariosinaresource- Bycombiningthefine-tuningoftheembeddingmodelinStage efficientmanner. 1withtheintroductionofthecomparisonmodelinStage2,we Stage3:HierarchicalBinaryCodeSimilarityDetection. accommodatethedomain-specificrequirementsoftheBCSDtask Thethirdstageoftheinferenceprocessinvolvesutilizingthefine- andimprovethemodel’sabilitytodiscernthesimilaritybetween tunedembeddingmodelandthecomparisonmodelfromCEBinto binarycodepairseffectively. performBCSD.Givenaqueryfunction,wefirstusetheembedding modeltoretrievethetop-Kclosestfunctionsfromthefunction 3.4 Inference poolusingtheANN-basedvectorindex.Thishelpstonarrowdown themostsimilarfunctionswhilemaintaininghighefficiency.After TheCEBininferenceprocesshasthreestagesasshowninFigure4. obtainingthekcandidatefunctions,weusethecomparisonmodel Thethreestagesperformfunctionembeddinginference,vector todoBCSDwiththequeryfunctionandcandidatefunctions. indexbuilding,andbinarycodesimilaritydetection,respectively. Thehierarchicalcombinationoftheembeddingmodelandthe Thishierarchicaldesignaimstobalanceperformanceandinference comparisonmodelensuresthatourBCSDmethodisbothefficient cost,integratingtheadvantagesofboththeembeddingmodeland andaccurate. Thecomputationalcostofusingthecomparison thecomparisonmodel. modelbyconcatenatingthequeryfunctionandtop-Kcandidate Stage1:FunctionEmbeddingInference.Inthefirststage,we functionsasinputismanageableanddoesn’tincreasesubstantially usetheembeddingmodeltoconstructembeddingvectorsforeach functionwithinthefunctionpoolthatweaimtocompare.Asshown asthesizeoftheoriginalfunctionpoolgrows.ThisallowsCEBinto effectivelyidentifythemostsimilarbinarycodesequenceswithin inFigure4,weemploythereferenceencoderfromtheembedding massivefunctions. modeltogeneratevectorsforthefunctionsinthefunctionpool. Stage2:VectorIndexBuilding.Inthesecondstage,webuild OurextensiveexperimentsinSection5showthatCEBin’sap- proachinconjunctionwiththeANNengineishighlycost-effective, avectorindexforeachfunctioninthefunctionpoolusingthe supportinglarge-scalecomparisonswithhighefficiency.Further- constructedembeddingvectors.Weusetheapproximatenearest more,thecomparisonmodelsignificantlyenhancesthedetectionre- neighbor(ANN)algorithmtoenableefficientinference.ANNap- sultsbyprovidingafine-grainedsimilarityassessment.Weachieve proximatesthenearestneighborsinhigh-dimensionalspaces,allow- ingforfastsimilaritysearchandcomparisonamongthefunction3. Retrieving Binary Function Repository V Ine dc eto xr Candidates Candidate Functions Comparing Model 1. Building Vector Index 4. Comparing Candidates 2. Quering Similar Embedding Model ANN Engine Functions Query Function FR ue ntr cie tiv oe nd s f1 Function Pool Wang,etal. ledoM gniddebmE noitcnuF Fucntion Pool ANN Engine Fucntion Pool Vectors Vectors Stage 2: Vector Index Building Fucntion Fucntion ANN Candidate Pool Pool Engine Pool ANN Engine Query Function Vectors ledoM nosirapmoC noitcnuF Stage 1: Function Embedding Inference Stage 3: Hierachical Binary Code Simiarity Detection Retrieved Function ledoM gniddebmE noitcnuF Fucntion Pool Vectors Stage 2: Vector Index Building Fucntion Fucntion ANN Candidate Pool Pool Engine Pool ANN Engine Query Function Vectors ledoM nosirapmoC noitcnuF Stage 1: Function Embedding Inference Stage 3: Hierachical Binary Code Simiarity Detection Retrieved Function ledoM gniddebmE noitcnuF Fucntion Pool Vectors Stage 2: Vector Index Building Function Pool ANN Engine ANN Engine Vectors ledoM nosirapmoC noitcnuF Stage 1: Function Embedding Inference Stage 3: Hierachical Binary Code Simiarity Detection Function Candidate Pool Pool Retrieved Function Query Function ledoM gniddebmE noitcnuF Function Pool Vectors Stage 1: Embedding Model Training Stage 2: Comparison Model Training Gradient InfoNCELoss TripletLoss Gradient Q1 Q1·R1 Q1·R2 ... Q1·RnQ1·R' 1Q1·R' 2Q1·R' 3 ... Q1·R' k Comparison Model Q2 Q2·R1 Q2·R2 ... Q2·RnQ2·R' 1Q2·R' 2Q2·R' 3 ... Q2·R' k ... ... ... ... ... ... ... ... ... ... Q1 R1 Q1 R2 Qn Qn·R1 Qn·R2 ... Qn·RnQn·R' 1Qn·R' 2Qn·R' 3 ... Qn·R' k Q2 R2 Q2 R3 ... ... Qn Rn Qn R1 R1 R2 ... Rn R' 1 R' 2 R' 3 ... R' k Positive Negative Pairs Pairs Embedding Model Reusable Embedding Cache Concatenation Query Encoder Reference Encoder R1 ... Rn R' 1 ... R' k-n Updated Reusable Embedding Cache Query Reference Query Reference Function Function Function Function ledoM gniddebmE noitcnuF Query Function Candidate Function ANN Pool Pool Engine ledoM nosirapmoC noitcnuF Stage 2: Vector Index Building ANN Engine ANN Engine Retrieved Function Vectors Query Pool Em Mb oe dd ed ling ANN Candidates Com Mp oa dr eis lon Retrieved Engine Vectors ledoM nosirapmoC Stage 1: Function Embedding Inference Stage 3: Hierachical Binary Code Simiarity Detection Function Candidate Pool Pool Retrieved Function Function Pool Embedding Query Model Function ledoM gniddebmE f 2 ... Vectors f n Stage 1: Function Embedding Inference Function Pool Query Function ledoM |
gniddebmE Stage 2: Vector Index Building ANN Engine ANN Engine Vectors Vectors ledoM nosirapmoC Stage 3: Hierarchical Binary Code Similarity Detection Function Candidate Pool Pool Retrieved Function Embedding Model Stage 1: Function Embedding Inference Function Pool Function Pool Query Function redocnE ecnerefeR Stage 2: Vector Index Building ANN Engine ANN Engine Vectors Vectors ledoM nosirapmoC Stage 3: Hierarchical Binary Code Similarity Detection Function Candidate Pool Pool Retrieved Function Query Encoder Figure4:TheillustrationofinferenceforCEBin.Instage1,weuseareferenceencodertoencodeallfunctionsweaimto compareintovectors.Instage2,webuildavectorindexforeachfunctionanditscorrespondingvectorusingANNalgorithm, sothatwecanretrieveKmostsimilarvectorsgivenaqueryvector.Instage3,givenaqueryfunction,weuseaqueryencoder toobtaintheembeddingvectorandretrievethetop-Kclosestfunctionsfromthefunctionpoolusingapre-builtvectorindex. ThentheKcandidatefunctionsalongwiththequeryfunctionarefedintothecomparisonmodeltoperformthefinalselection. betteraccuracywithoutincurringadramaticincreaseincomputa- whenthesizeofthefunctionpoolbecomesverylarge.Therefore, tionalcostthroughthehierarchicalinferenceframework. weuseMRRandRecall@1following[51]toevaluateandcompare theperformanceofCEBinandthebaselinemethods. Duringthepre-trainingstage,weuseamoreextensivedataset 4 EXPERIMENTALSETUP andadoptthesameconfigurationofjTrans[51].Thepre-training WecompareCEBinagainstmultiplebaselines:Genius[15],Gem- modelisoptimizedwithAdam[26]withparametersof𝛽1=0.9,𝛽2= ini[54],SAFE[37],Asm2Vec[9],GraphEmb[36],OrderMatters[57], 0.98,𝜖 =1𝑒-12,andan𝐿2weightdecayof0.01.Themodeltrains Trex[42],GNNandGMN[30],andjTrans[51].Weimplement onmini-batchesconsistingof𝐵=128binaryfunctionswithacap CEBinandbaselinesusingFaiss[23]andPytorch[40].Ourexperi- of𝑇 =512tokensperfunction. mentsareconductedonseveralserverstoacceleratetraining.The Duringthefine-tuningphase,weassignthetemperature𝑇 = GPUsetupincludes8Nvidia-V100.Theexperimentenvironment 0.05,thenegativequeuesize𝐿=8192,andthemomentum𝑚=0.99. consistsofthreeLinuxserversrunningUbuntu20.04withIntel Thecomparisonmodelutilizesamarginof𝛼 =0.25forTripletLoss. Xeon96-coreandequippedwith768GBofRAM. ThemodelsaretrainedusingtheAdamalgorithm[26]withthese WeevaluateCEBinwiththefollowingthreedatasets.Welabel parameters:𝛽1=0.9,𝛽2=0.999,𝜖 =1𝑒-8,andan𝐿2weightdecay functionsasequaliftheysharethesamenameandwerecompiled of0.0001. fromthesamesourcecode. ForCEBin’sinferencephase,weretrievethetop-50closestfunc- tionforexperimentsonBinaryCorp,Cisco,andTrexdatasets.We • BinaryCorp[51]issourcedfromtheArchLinuxofficialrepos- choose K=50 because we find that the embedding model’s Re- itoriesandArchUserRepository.CompiledusingGCC11.0on call@50isalmostcloseto1.0asshownintheSection5.2.1,thus X64withvariousoptimizations,itfeaturesahighlydiverseset providing a sufficiently good set of candidate functions for the ofprojects. comparisonmodel.Weretrievetop-300closestfunctionforthe • CiscoDataset[35]comprisessevenpopularopen-sourceprojects, vulnerabilitysearchexperimentsbecausethemaximumnumberof ityields24distinctlibrariesuponcompilation.Binariesinthe vulnerablefunctionscouldbeupto240foreachquery. Cisco dataset are compiled with GCC and Clang compilers, spanningfourversionseach,acrosssixISAs(x86,x64,ARM32, ARM64,MIPS32,MIPS64)andfiveoptimizationlevels(O0-O3, 5 EVALUATION Os).Thissetupallowsforcross-architectureanalysisandevalu- ationofcompilerversions,withamoderatenumberofprojects. ToproveCEBin’seffectivenessinaddressingpreviouschallenges, weproposetheseresearchquestions(RQs): • TrexDataset[42]isbuiltuponbinariesreleasedby[42],which consistsoftenlibrarieschosentoavoidoverlapwiththeCisco • RQ1:HowdoesCEBinperformcomparedtoSOTABCSDsolu- dataset.SimilartotheCiscoDataset,theTrexdatasetfacilitates tionsindifferentsettings,includingcross-architecture,cross- cross-architectureandcross-optimizationevaluation. compilers,andcross-optimizations? Manypreviouswork[34,35,37,42,54]usetheareaundercurve • RQ2:HowdothedesignchoiceswithintheCEBinframework contributetotheoverallperformance? (AUC)ofthereceiveroperatingcharacteristic(ROC)curveorpre- cision to evaluate the performance of BCSD solutions. But this • RQ3:HowdoesCEBinperforminvulnerabilitysearchovera challengingvulnerabilitysearchingbenchmark? metricistoosimpleforexistingsolutionssoSOTABCSDsolutions performsimilarly.However,wenoticethatpreviousworks[35,51] • RQ4:HowisthegeneralizationabilityoftheCEBin? announcedthatrankingmetrics,themeanreciprocalrank(MRR), • RQ5:WhatistheinferencetimecostofCEBincomparedwith otherSOTAbaselines? andtherecall(Recall@K)aremorepracticalforBCSDespeciallyCEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection Table1:ComparisonbetweenCEBinandbaselinesforthecross-optimizationtaskonBinaryCorp-3M(Poolsize=10,000) MRR Recall@1 Models O0,O3 O1,O3 O2,O3 O0,Os O1,Os O2,Os Average O0,O3 O1,O3 O2,O3 O0,Os O1,Os O2,Os Average Genius 0.041 0.193 0.596 0.049 0.186 0.224 0.214 0.028 0.153 0.538 0.032 0.146 0.180 0.179 |
Gemini 0.037 0.161 0.416 0.049 0.133 0.195 0.165 0.024 0.122 0.367 0.030 0.099 0.151 0.132 GNN 0.048 0.197 0.643 0.061 0.187 0.214 0.225 0.036 0.155 0.592 0.041 0.146 0.175 0.191 GraphEmb 0.087 0.217 0.486 0.110 0.195 0.222 0.219 0.050 0.154 0.447 0.063 0.135 0.166 0.169 OrderMatters 0.062 0.319 0.600 0.075 0.260 0.233 0.263 0.040 0.248 0.535 0.040 0.178 0.158 0.200 SAFE 0.127 0.345 0.643 0.147 0.321 0.377 0.320 0.068 0.247 0.575 0.079 0.221 0.283 0.246 Asm2Vec 0.072 0.449 0.669 0.083 0.409 0.510 0.366 0.046 0.367 0.589 0.052 0.332 0.426 0.302 Trex 0.118 0.477 0.731 0.148 0.511 0.513 0.416 0.073 0.388 0.665 0.088 0.422 0.436 0.345 jTrans 0.475 0.663 0.731 0.539 0.665 0.664 0.623 0.376 0.580 0.661 0.443 0.586 0.585 0.571 CEBin-E 0.787 0.874 0.924 0.858 0.909 0.893 0.874 0.710 0.818 0.885 0.795 0.863 0.842 0.819 CEBin 0.850 0.886 0.953 0.903 0.927 0.895 0.902 0.776 0.826 0.920 0.839 0.874 0.834 0.845 Table2:ResultsofdifferentbinarysimilaritydetectionapproachesonCisco(poolsize=10,000) MRR Recall@1 XA+ XA+ Models XA XC XO XA+XO XC+XO XA XC XO XA+XO XC+XO XC+XO XC+XO GNN 0.205 0.158 0.104 0.119 0.189 0.093 0.129 0.104 0.080 0.084 0.165 0.063 Trex 0.085 0.401 0.410 0.145 0.313 0.124 0.052 0.341 0.360 0.113 0.268 0.096 CEBin-E 0.760 0.907 0.859 0.817 0.866 0.766 0.692 0.871 0.816 0.766 0.823 0.706 CEBin 0.977 0.992 0.973 0.978 0.984 0.961 0.968 0.988 0.963 0.969 0.977 0.946 Table3:Resultsofdifferentbinarysimilaritydetectionap- optimizationoptions,andtheircombinations.Inthisexperiment, proachesonTrex(poolsize=10,000) weselectseveralcross-architecturebaselinesforcomparisons,such asGNN,andTrex.Consistentwithpreviouswork,wetrainCEBin MRR Recall@1 andGNNonCisco’strainingsetandassessperformanceonCisco’s Models XA XO XA+XO XA XO XA+XO testset.Aspreviousresearch[35]highlights,retrainingTrexon Trex 0.142 0.218 0.175 0.065 0.123 0.107 Ciscodatasetischallenging,wedirectlyusethemodelreleasedby GNN 0.163 0.148 0.151 0.145 0.102 0.109 CEBin-E 0.612 0.646 0.576 0.509 0.553 0.474 Trexauthors. CEBin 0.911 0.933 0.911 0.882 0.906 0.870 Toensurecomprehensivetesting,weemploysixdifferentevalua- tiontasks.(1)XOreferstofunctionpairswithvaryingoptimizations butidenticalcompiler,compilerversion,andarchitecture.(2)XC 5.1 Performance(RQ1) referstofunctionpairswithdifferentcompilersbutthesamear- 5.1.1 Cross-Optimizations: BinaryCorp. In this experiment, we chitectureandoptimization.(3)XAreferstofunctionpairswith assessCEBin’sperformanceontheBinaryCorpdataset,whichin- varyingarchitecturesbutidenticalcompiler,compilerversion,and cludesx64binariescompiledwithGCC-11acrossvariousoptimiza- optimization. (4) XC+XO refers to function pairs with different tionlevels(O0,O1,O2,O3,andOs).Weconductextensiveexperi- compilersandoptimizationsbutthesamearchitecture.(5)XA+XO mentstoevaluatetheperformanceoftheselectedbaselines,which referstofunctionpairswithvaryingarchitecturesandoptimiza- are limited to a single architecture and those supporting cross- tionsbutidenticalcompilerandcompilerversions.(6)XA+XC+XO architecture.Weevaluatetheperformanceofcross-optimization referstofunctionpairsfromanyarchitecture,compiler,compiler BCSDtaskswithvaryingdifficultyoptimizationpairs(e.g.,O0v.s. version,andoptimization.WetestthesixtasksontheCiscoDataset. O3)whilemaintainingconsistentexperimentalsetupswithpre- Wetesttasks(1),(3),and(5)ontheTrexdatasetsinceitonlyuses viouswork[51]forfaircomparison.Wereporttheexperimental onecompiler(i.e.,GCC7.5).Weevaluateperformanceinamuch resultsforfunctionpoolsize10,000asshowninTables1.CEBin-E morechallengingscenarioswherepoolsize=10,000comparedto denotesfortheembeddingmodelofCEBin. previousworks. The experimental results in Table 1 demonstrate that CEBin Table2–3reporttheexperimentalresults.Theresultsrevealthat significantlyoutperformsallbaselines.CEBinoutperformsthebest- CEBinsignificantlyoutperformsbaselinesinmixedcross-architecture, performing baseline jTrans by significantly improving MRR by cross-compiler,andcross-optimizationtasks.Comparedtothebest 44.8%andRecall@1by47.9%.Theexperimentalresultsshowthe baselineTrex,theMRRincreasesfrom0.124to0.961,andRecall@1 advantageofCEBinincross-optimizationtasks,improvingtheeffec- increasesfrom0.096to0.946.OntheTrexDataset,CEBinoutper- |
tivenessoftheembeddingmodeltrainingbyusingmorenegative formsthebestresultofthebaseline,withMRRincreasingfrom samplesduringtraining. 0.175to0.911andRecall@1increasingfrom0.109to0.870. TheresultsdemonstrateCEBin’sadvantagesinchallengingBCSD 5.1.2 Cross-Architectures,Compilers,andOptimizations:Ciscoand tasks.Trainingmoreefficientlyonalargerquantityofnegative TrexDataset. WeevaluateCEBinandbaselinesonCiscoandTrex samplesenablestheembeddingmodeltoperformbetter.Asour datasetsacrossvariousfactors,includingarchitectures,compilers,Wang,etal. 1.0 0.8 0.6 0.4 0.2 0 1@llaceR (O0,O3) (O1,O3) 1.0 0.8 0.6 0.4 0.2 0 1@llaceR (O2,O3) (O0,Os) 1.0 0.8 0.6 0.4 0.2 0 1 2 3 4 log10(Poolsize) 1@llaceR 1.0 0.8 0.6 0.4 0.2 0 (O1,Os) (O2,Os) 1 2 3 4 log10(Poolsize) CEBin GMN SAFE GNN CEBin-E Trex OrderMatters Gemini jTrans Asm2Vec GraphEmb Figure5:Theperformanceofdifferentbinarysimilarityde- tectionmethodsonBinaryCorp.Thex-axisislogarithmic anddenotesthepoolsize. traininggoalinvolvesdiscriminatingsimilarbinarycodesinlarger batchesofnegatives,CEBinsignificantlyoutperformsthebaseline, especiallyforthischallenginglargepoolsizesettings.Additionally, integratingthecomparisonmodelfurtherenhancesperformance asitachievesmorefine-grainedsimilaritydetection.IntheXA+XO experimentconductedontheTrexdataset,thecomparisonmodel significantlyimprovesRecall@1from0.474to0.870. 5.1.3 TheImpactofPoolsize. AsindicatedinSection1,forprac- ticaltaskslike1-dayvulnerabilitydetectioninsoftwaresupply chains,maintenanceofaparticularlylargepoolsizeisnecessary andvaluable.However,inourpriorexperiments,wediscoverthatas poolsizeincreases,performancedeclinesacrossthethreedatasets. Thus,weexploretheinfluenceofdifferentpoolsizewhilemaintain- ingothersettings.Thepoolsizeissetas2𝑖,𝑖 ∈ [1,13],and10,000. WerecordRecall@1fordifferentpoolsize. TheFigure5–7presentstheresults,clearlyshowingthatasthe poolsizeincreases,therelativeperformanceofallbaselinesisinfe- riortoCEBin.Furthermore,thedeclineintheperformanceofCEBin isnotsoobviouswhichsuggeststhatCEBinismorecapableofad- dressinglargepoolsizesettings.TheresultsalsoshowthatCEBin offersagreaterperformanceenhancementcomparedtoCEBin-E inmoredifficultscenariossuchasO0andO3optimizationoptions intheBinaryCorpexperimentandtheXA+XC+XOintheCisco 1@llaceR XA XC 1.0 0.8 0.6 0.4 0.2 0 1@llaceR XO XA+XO 1.0 0.8 0.6 0.4 0.2 0 2 4 6 8 10 12 log2(Poolsize) 1@llaceR XC+XO XA+XC+XO 2 4 6 8 10 12 log2(Poolsize) CEBin CEBin-E GMN Trex GNN Figure6:Theperformanceofdifferentbinarysimilarityde- tectionmethodsonCiscoDataset.Thex-axisislogarithmic anddenotesforthepoolsize. 1.0 0.8 0.6 0.4 0.2 0 1@llaceR XA XO 2 4 6 8 10 12 1.0 log2(Poolsize) 0.8 0.6 0.4 0.2 0 2 4 6 8 10 12 log2(Poolsize) 1@llaceR XA+XO CEBin CEBin-E GMN GNN Trex Figure7:Theperformanceofdifferentbinarysimilarityde- tectionmethodsonTrexDataset.Thex-axisislogarithmic anddenotesforthepoolsize.CEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection 0.9 0.8 0.7 0.6 0.5 0.4 0.3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 log2(L) 1@llaceR 1.0 0.9 0.8 0.7 O0-3 O0-s 0.6 O1-3 O1-s O2-3 O2-s 0.5 0 1 2 3 4 5 6 7 8 9 10 log2(k) Figure8:TheperformanceofCEBin-EonBinayCorpusing differentsizeofembeddingcache. dataset,wherebinaryfunctionsexhibitlargerdiscrepancies.CEBin, trainedontheCiscodataset,displaysremarkablepoolsizerobust- nessontheTrexdataset,demonstratingoutstandinggeneralization performance.Finally,weemphasizethatwhenthepoolsizeissmall (e.g.,poolsize=2),thedifferenceinrecall@1amongdifferentmeth- odsistiny,indicatingresultsmeasuredwithaverysmallpoolsize inmanyexistingworkscannotaccuratelyrepresenttheseBCSD solutions’performanceinreal-world. 5.2 ImpactofOurDesignChoices(RQ2) Inthissection,weaimtovalidatetheeffectsofourtwocoredesigns: introducingmorenegativesamplesthroughRECMduringtraining andhierarchicalinferenceonperformance. 5.2.1 ReusableEmbeddingCacheMechanism. Toinvestigatethe impactofthenumberofnegativesamplesduringtraining,wekeep otherpartsoftheembeddingmodeltrainingconsistentandonly changethesizeoftheRECM,alsorepresentsthenumberofnegative samples,usedduringtraining.WesetL,thesizeofRECM,aspowers of2rangingfrom2to65536.ThenweevaluatetheRecall@1for differentoptimizationpairsatapoolsizeof10,000onBinaryCorp. TheexperimentalresultsaredisplayedinFigure8,wherethex-axis representsthepoolsize(alogarithmicaxis). Basedontheexperimentalresults,weobservethatanincreased numberofnegativesamplessubstantiallyimprovestheoveralleffec- tivenessoftheembeddingmodelacrossvariouscross-optimization |
tasks.Forexample,inthemostchallengingtask(O0andO3),Re- call@1increasesfrom0.337(L=2)to0.709(L=8192).Inlesschal- lengingscenariosuchascomparingO2andO3,recall@1rosefrom 0.647(L=2)to0.887(L=4096).Interestingly,wefoundthatalarger Ldoesnotalwaysleadtobetterresults.Thiscanbeattributedto thecontinuousupdateofencodersduringtheencodingprocess whereRECMemployedfortraining.Althoughalargemomentum maintainsaslowupdatetoensureconsistencyofembeddingsin theembeddingcache,excessivereusewithanexceedinglylarge sizeLintroducesinconsistenciesthatslightlyreduceperformance. Accordingtoexperimentalresults,performanceimprovementbe- ginstodwindlewhenLexceeds1024.Acomparativeanalysisre- vealedthattheoptimalaverageperformanceamongthesixcases isattainedatL=8,192withanaveragerecall@1of0.819.Theexper- imentalresultsverifythattheintegrationofRECMsignificantly improvestheperformance. llaceR XO XA XA+XO Figure 9: Recall@K of CEBin-E on Trex Dataset for pool- size=10,000. 5.2.2 ComparisonModel. Toinvestigatetheroleofthecomparison modelinCEBin,weexaminebothCEBinandCEBin-Eacrossall RQ1 experiments, where CEBin-E employs only the embedding model.TheenhancementofCEBininrelationtoCEBin-Eindicates thepointofthecomparisonmodelduringhierarchicalinference. ResultsareshowninTables1–3andFigures5–7. Our findings reveal that the comparison model delivers per- formance gains in cross-architecture, cross-compiler, and cross- optimizationcontexts,withlargerimprovementsobservedinmore challengingtasks.Inthecross-optimizationtaskoftheBinaryCorp dataset with poolsize=10,000, the comparison model boosts the averageRecall@1by3.0%,withthemostarduousO0,O3taskel- evatingRecall@1by9.3%.FortheXA+XC+XOtaskintheCisco dataset when poolsize=10,000, CEBin’s Recall@1 rises by 34.0% comparedtoCEBin-E.IntheXA+XOtaskontheTrexdatasetwhen poolsize=10000,Recall@1increasesfrom0.474to0.870,whichis an83.5%improvement.AsCEBinistrainedonCiscoandthetrain- ingsetlackstheGCC7.5compiler,theTrexdatasetrepresentsan out-of-distribution(OOD)dataset.Theperformancesignificantly declineswithonlytheembeddingmodel,yetincorporatingthe comparisonmodelmarkedlyheightensCEBin’srobustness. Toshowthepotentialimprovementthecomparison-basedmodel canbring,Figure9presentstheRecall@KofCEBin-EontheTrex dataset.TheexperimentalresultshowsthattheRecall@50ofCEBin- EissignificantlyhigherthanRecall@1,whichindicatesthepoten- tialimprovementsthatcanbebroughtaboutbyusingthecompar- isonmodel.However,theRecall@50ofCEBin-Eisonlyslightly higherthantheRecall@1ofCEBin,whichsuggeststhatourcom- parisonmodelperformsverywell.Theexperimentsdemonstrate thatthecomparisonmodeleffectivelylearnsmoreintricatefea- tures,augmentingBCSDperformance.It’sworthnotingthat,the Recall@50oftheembeddingmodelisalmostconvergent.Consider- ingthebalancebetweenoverheadandperformance,wechoseK=50 foralltheexperimentspresentedearlierasthecandidateresults aregoodenoughforcomparisonmodel. 5.3 VulnerabilityDetection(RQ3) To develop a realistic vulnerability dataset, we gather commits thatfix187CVEsfrom5projects,includingcurl,vim,libpng, opensshandopenssh-portable.Theseprojectsarecompiledus- ingmultiplecompilersandarchitecturestorepresentthediverseWang,etal. 70 60 50 40 30 20 10 0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 Recall tnuoC dtls1_send_client_key_exchangeastheysharehighlysim- GNN Trex CEBin ilarsemanticinformationwithinthemaximumtokenlength. GNN: 16.85% CEBin: 85.46% • Insensitivitytospecificinstructions.Iffunctionsonlydiffer Trex: 15.89% byveryfewinstructionsandthemodelcannotadequatelydis- tinguishthem,itmayconsiderthemassimilar.InOpenSSL’s CVE-2012-2110,themodeltreatsCRYPTO_realloc_clean(vul- nerable)andCRYPTO_reallocasalike,despitethelatterhaving threefewerconsecutivefunctioncalls. • Functionnamealteredduringcompilation.Compilermay modifyfunctionnamesleadingtomisjudgments.Incurl’sCVE- 2022-27780, the model identifies the vulnerable function as hostname_check.isra.1 instead of hostname_check. After manuallyexamining,weconfirmthatthemisjudgmentstems Figure 10: The Vulnerability Search Results of CEBin and fromthecompilerchangingthefunctionname. Trex.Thisfigurerepresentsthedistributionofrecallvalues ofdifferentmethods.Thedashedlinesshowthemeanrecall ofdifferentmodels. 5.4 GeneralizationPerformance(RQ4) AspreviouslydiscussedandshowninTable3,andFigure7,after training on the Cisco Dataset, we observe that CEBin achieves excellent results on the Trex Dataset, demonstrating its strong configurationsfoundinreal-worldsoftwaresupplychains.Wepro- generalizationcapability.Tofurtherinvestigatethegeneralization videsdetailsaboutthedatasetincludingthenumberofvulnerable ofCEBin,weconductanevenmorechallengingexperiment.We functionsandthepoolsizecorrespondingtoeachCVEsearchinour labelthemodelstrainedseparatelyonBinaryCorpandCiscoas |
releasedcode.Wefirstpinpointrelevantfunctionswithincommits CEBin-BinaryCorpandCEBin-Cisco.Notably,BinaryCorpisacross- addressingCVEsbyanalyzingtheirrootcauses,giventheCVE optimization (XO) dataset compiled on x64 using one compiler, anditsassociatedcommit.Next,weevaluateCEBinbyestablishing GCC11.0,whiletheCiscoDatasetcomprisessixarchitecturesand asearchpoolcomprisingallcompiledfunctions.Wethenselect eightcompilers.BecauseCEBin-BinaryCorpistrainedbasedon onevulnerablefunctiontoserveasaqueryandattempttoidentify cross-optimizationtasks,wemeasureitsperformanceintermsof otherinstancesofthesamevulnerabilityintheentirepool.Given cross-optimizationBCSDontheCiscoDatasetandTrexDataset 𝑚totalvulnerablefunctions,weextractthe𝑚mostsimilarmatches fordifferentarchitectures,alongsideCEBin-Cisco.Table4indicates tothequeryanddeterminethenumberofthese(denotedas𝑚)that thatCEBin-BinaryCorpoutperformsCEBin-CiscointheXOtask areindeedvulnerable.Finally,wecalculatetherecallrateby 𝑚 𝑘, onx64andotherarchitectures,andontheTrexDataset,withan whichallowsustoassesstheeffectivenessofdifferentapproaches. averagerecall@1increaseof0.028.Thefullresultsareavailableat ResultAnalysisInFigure10,wepresenttherecallratedistri- Table7–9intheAppendix. butionforCEBin,GNN,andTrexonavulnerabilitydataset.Among Theresultsareexcitingandindicatethatamodelfine-tunedwith 187CVEs,CEBinachievesanaveragerecallrateof86.46%,while XOdatasetfromonearchitecturecanbereadilytransferredtoother TrexandGNNhaveaveragerecallof15.89%and16.85%,respec- architectures.Webelievethatthisoutcomeisampleevidencethat tively.TherecallratedistributionrevealsthatmostofCEBin’srecall theIL-basedpre-trainedCEBinmodeleffectivelynormalizesbinary ratesfallwithinarangegreaterthan0.9.Incontrast,therecallrates functionsacrossdifferentarchitecturesandextractsrobustseman- forTrexprimarilyfallwithinthe0.05to0.15range.Thisobserva- ticfeatures.ItisworthnotingthatCEBin-BinaryCorpperforms tionimpliesthatforlargepoolsizevulnerabilitysearches,Trexand betterthanCEBin-Cisco,whichwespeculatemaybeattributedto GNNexperienceasignificantdecreaseinperformance,whilethe theBinaryCorpdatasetcontaining1,612projectsandofferingmore impactonCEBinisrelativelysmall.Asaresult,CEBinsignificantly diversebinaryfunctions.TheCiscoDatasetconsistsofonlyseven outperformsbothTrexandGNN.Forinstance,inCVE-2012-0884, projects,meaningthatitmaynotbesufficientlydiversifiedfroma CVE-2013-4353,CVE-2015-0288,andCVE-2015-1794,CEBinsuc- functionsemanticsperspective,despiteencompassingmanydiffer- cessfullyidentifiesallvulnerabilitieswithinpoolsizesofover60,000. entarchitecturesandcompilervariations.Theuseofapre-trained Meanwhile,TrexandGNNcouldonlydetectlessthan25%ofthe modelwithILhastosomeextentmitigatedtheeffectsofdifferent vulnerablefunctionsinthesecases. architectures,andtheBinaryCorpdatasetismorediversifiedthan UnderstandingFailureCasesWeinvestigatevarioushigh- theCiscoandTrexdatasets,thatisthereasonCEBin-BinaryCorp rankingfailurecasesinthisexperimentandidentifyseveralpoten- performsbetterthanCEBin-Cisco. tialcausesbehindtheseinaccuracies: • Truncationofexcessivelylongfunctions.Functionswith tokensexceedingthemaximumlengtharetruncatedwhenem- 5.5 InferenceCost(RQ5) bedding. If two functions are similar before truncation, one WeevaluatetheinferencecostofCEBinagainstvaryingpoolsizes might be misidentified as similar to the other after trunca- andcompareittobaselines.Forembedding-basedapproaches,we tion. For example, in OpenSSL’s CVE-2008-1672, the model pre-computethecorrespondingvectorsforthefunctionpool.When confusesssl3_send_client_key_exchange(vulnerable)with assessinganewqueryfunction,wemeasurethecostfromacquiringCEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection Table 4: Recall@1 comparison between CEBin-Cisco and onthemodelperformanceandtheevaluationofthefinalresults. CEBin-BinaryCorp of cross-optimization task on Cisco Futureworkscanexplorewaystoconstructabetterdataset,suchas datasetforpoolsize=10,000.(Simplifiedtable) performingmorefine-graineddeduplicationtoensuretheaccuracy ofexperimentsandenhancetheperformanceofthemodel. Model Third,ourworkonlyfocusesoncoarse-grainedfunctionlevel Architecture CEBin- CEBin- Improvement similaritydetection.Wecannotperfectlysolvethe1-dayvulnerabil- Cisco BinaryCorp itydetectionproblemasthegeneralBCSDcan’tdistinguishwhether x86 0.984 0.988 ↑0.004 x64 0.968 0.978 ↑0.010 afunctionispatchedornot.FutureworkscancombineBCSDso- MIPS32 0.979 0.991 ↑0.012 lutionswithfine-grainedtechniquessuchasdirectedfuzzingto MIPS64 0.997 0.988 ↓0.009 betterdetect1-dayvulnerabilities. ARM32 0.962 0.967 ↑0.005 ARM64 0.969 0.973 ↑0.004 Average 0.977 0.981 ↑0.004 7 CONCLUSION In this paper, we propose CEBin, a novel cost-effective binary Table 5: Recall@1 comparison between CEBin-Cisco and codesimilaritydetectionframeworkthatbridgesthegapbetween CEBin-BinaryCorpofcross-optimizationtaskonTrexdataset embedding-basedandcomparison-basedapproaches.CEBinem- |
ploysarefinedembedding-basedapproachtoextractrobustfeatures forpoolsize=10,000. fromcode,efficientlynarrowingdowntherangeofsimilarcode. Followingthat,itusesacomparison-basedapproachtoimplement Model Architecture CEBin- CEBin- Improvement pairwisecomparisonsandcapturecomplexrelationships,signifi- Cisco BinaryCorp cantlyimprovingsimilaritydetectionaccuracy.Throughcompre- x86 0.907 0.948 ↑0.041 hensiveexperimentsonthreedatasets,wedemonstratethatCEBin x64 0.889 0.945 ↑0.056 outperformsstate-of-the-artbaselinesinvariousscenarios,such MIPS32 0.851 0.885 ↑0.034 MIPS64 1.000 1.000 − ascross-architecture,cross-compiler,andcross-optimizationtasks. ARM32 0.862 0.909 ↑0.047 WealsoshowcasethatCEBinsuccessfullyhandlesthechallengeof ARM64 0.925 0.917 ↓0.008 large-scalefunctionsearchinbinarycodesimilaritydetection,mak- Average 0.906 0.934 ↑0.028 ingitaneffectivetoolforreal-worldapplications,suchasdetecting 1-dayvulnerabilitiesinlarge-scalesoftwareecosystems. Table6:Inferencespeed(seconds)ofGNN,Trex,CEBin-Eand CEBinonvariouspoolsize. Poolsize Model 100 10,000 1,000,000 4,000,000 GNN 0.004 0.004 0.012 0.037 Trex 0.018 0.018 0.050 0.182 CEBin-E 0.807 0.814 0.887 1.034 CEBin 2.717 2.772 2.898 3.105 theembeddingvectorwiththeembedding-basedmodeltocom- paringitwitheachfunctioninthepooltoobtaintheresults.The experimentalresultsinTable6revealthetimeeachmethodrequires forhandlingdifferentpoolsizes. ThoughCEBin’sinferencecostisrelativelyhigherthanthebase- line,itdoesnotincreaserapidlyasthepoolsizeexpands.Evenwith apoolsizeof4million,CEBincanprocessitinonly3.1seconds, therebydemonstratingscalabilityforreal-worldsoftwaresupply chain1-dayvulnerabilitydiscoverytasks. 6 LIMITATIONS CEBinsuffersfromseverallimitations.First,whilewehavedemon- stratedthegoodperformanceofCEBin’sBCSDonpublicdatasets, wehaveonlytestedthereal-worldperformanceoftheBCSDmodel inscenariosof1-dayvulnerabilitydetection.Futureworkcancon- ductmorecomprehensivedownstreamtaskstoaddressthechal- lengesofapplyingBCSDtechnologyinreal-worldsenarios. Second,thereexistclonedfunctionsacrossdifferentprojectsin alldatasets,thusleadingtofalsenegativesinthedatasets.Even thoughtheproportionislow,itmightbringsomenegativeimpactsWang,etal. A DATASETS • jTrans[51]isaTransformer-basedapproachthatembedscon- We evaluate CEBin with the following three datasets. We label trolflowinformationofbinarycodeintoTransformer-based functionsasequaliftheysharethesamenameandwerecompiled languagemodelswithajump-awarerepresentationofbinaries. fromthesamesourcecode. C COMPLETEEXPERIMENTALRESULTSON • BinaryCorp[51]issourcedfromtheArchLinuxofficialreposi- CISCODATASETS toriesandArchUserRepository.Itcontainstensofthousandsof software,includingeditors,instantmessengers,HTTPservers, webbrowsers,compilers,graphicslibraries,andcryptographic Table 7: Recall@1 comparison between CEBin-Cisco and libraries.CompiledusingGCC11.0onX64withvariousopti- CEBin-BinaryCorpofcross-compilertaskonCiscodataset mizations,itfeaturesahighlydiversesetofprojects. forpoolsize=10,000.(Fulltable) • CiscoDataset[35]comprisessevenpopularopen-sourceprojects (ClamAV,Curl,Nmap,OpenSSL,Unrar,Z3,andzlib).Ityields Model 24distinctlibrariesuponcompilation.Librariesarecompiled ISA Optimization CEBIN- CEBIN- Improvement Cisco BinaryCorp usingtwocompilerfamilies,GCCandClang,acrossfourmajor O0 0.988 0.994 ↑0.006 versionseach.TargetingsixdifferentISAs(x86,x64,ARM32, O1 0.993 0.986 ↓0.007 ARM64,MIPS32,andMIPS64)andfiveoptimizationlevels(O0, x86 O2 0.986 0.993 ↑0.007 O1,O2,O3,andOs),theCiscodatasetenablescross-architecture O3 0.990 1.000 ↑0.010 Os 0.993 0.986 ↓0.007 evaluationandanalysisofcompilerversions,whilecontaining O0 0.976 0.968 ↓0.008 amoderateprojectcount. O1 0.990 0.970 ↓0.020 • TrexDataset[42]isbuiltuponbinariesreleasedby[42],which x64 O2 0.981 0.991 ↑0.010 consistsoftenlibrarieschosentoavoidoverlapwiththeCisco O3 0.982 0.982 − Os 0.981 0.990 ↑0.009 dataset(binutils,coreutils,diffutils,findutils,GMP,ImageMag- O0 0.982 0.994 ↑0.012 ick,libmicrohttpd,libTomCrypt,PuTTY,andSQLite).Precom- O1 0.969 0.993 ↑0.024 piledforx86,x64,ARM32,ARM64,MIPS32,andMIPS64,this MIPS32 O2 0.986 0.993 ↑0.007 dataset offers four optimization levels (O0, O1, O2, O3) and O3 0.990 0.990 − Os 0.983 0.997 ↑0.014 GCC-7.5.SimilartotheCiscoDataset,theTrexdatasetfacili- O0 1.000 1.000 − tatescross-architectureandcross-optimizationevaluation. O1 0.933 1.000 ↑0.067 MIPS64 O2 1.000 0.923 ↓0.077 O3 0.889 1.000 ↑0.111 Os 1.000 1.000 − B BASELINES O0 0.991 0.976 ↓0.015 • Genius[15]:isanon-deeplearningapproachextractingrawfea- O1 0.990 0.986 ↓0.004 |
ARM32 O2 0.990 0.983 ↓0.007 turesasattributedcontrolflowgraphsandemployinglocality- O3 0.990 0.987 ↓0.003 sensitivehashing(LSH)togeneratenumericvectorsforvulner- Os 0.990 0.983 ↓0.007 abilitysearch. O0 0.990 0.980 ↓0.010 • Gemini[54]extractsmanually-craftedfeaturesforeachbasic O1 0.993 0.989 ↓0.004 ARM64 O2 0.993 0.996 ↑0.003 blockandthenusesGNNstolearntheCFGrepresentationof O3 0.996 0.996 − thetargetfunctions. Os 0.993 0.993 − • SAFE[37]employsanRNNwithattentionmechanisms,this Average 0.984 0.987 ↑0.003 baselinegeneratesarepresentationoftheanalyzedfunction usingassemblyinstructionsasinput. • Asm2Vec[9]appliesrandomwalksontheCFGandusesthe Table8:ResultsofCross-ArchitectureonTrexDataset PV-DMmodeltojointlylearnembeddingsofthefunctionand instructiontokens. Model • GraphEmb[36]learnsembeddingsofinstructiontokensand Compiler Optimization CEBIN- CEBIN- Improvement usesStructure2vec[4]tocombineembeddingsandgeneratethe Cisco BinaryCorp O0 0.940 0.792 ↓0.148 finalrepresentation. O1 0.879 0.801 ↓0.078 • OrderMatters[57]:concatestwotypesofembeddings.Ituses GCC7.5 O2 0.871 0.786 ↓0.085 BERTtocreateanembeddingforeachbasicblockandemploys O3 0.837 0.756 ↓0.081 aCNNontheCFGtogeneratethesecondtypeofembedding. Os N/A N/A N/A • Trex[42]introducesadynamiccomponentextractingfunction Average 0.882 0.784 ↓0.098 tracesbasedonahierarchicaltransformerandmicro-traces. Thiscross-architecturesolutionisbuiltontheTransformer. • GNN and GMN [30] proposes graph-matching models for graphmatching.Previouswork[35]evaluatesthetwoapproaches ontheCiscoandTrexdatasetsandthetwoapproachesachieved theSOTAperformance.CEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection Table 9: Recall@1 comparison between CEBin-Cisco and CEBin-BinaryCorp of cross-optimization task on Cisco datasetforpoolsize=10,000.(Fulltable) Model Improve- ISA Compiler CEBIN- CEBIN- ment Cisco BinaryCorp Clang3.5 0.989 0.989 − Clang5.0 0.985 0.985 − Clang7.0 0.986 0.986 − Clang9.0 0.985 0.982 ↓0.003 x86 GCC4.8 0.982 0.993 ↑0.011 GCC5.0 0.986 0.989 ↑0.003 GCC7.0 0.979 0.989 ↑0.010 GCC9.0 0.978 0.989 ↑0.011 Clang3.5 1.000 1.000 − Clang5.0 0.989 1.000 ↑0.011 Clang7.0 0.989 1.000 ↑0.011 Clang9.0 0.977 0.989 ↑0.012 x64 GCC4.8 0.943 0.956 ↑0.013 GCC5.0 0.955 0.967 ↑0.012 GCC7.0 0.967 0.957 ↓0.010 GCC9.0 0.929 0.955 ↑0.026 Clang3.5 1.000 1.000 − Clang5.0 1.000 1.000 − Clang7.0 1.000 0.971 ↓0.029 Clang9.0 0.943 1.000 ↑0.057 MIPS32 GCC4.8 0.979 0.989 ↑0.010 GCC5.0 0.969 0.986 ↑0.017 GCC7.0 0.966 0.986 ↑0.020 GCC9.0 0.972 0.993 ↑0.021 Clang3.5 0.974 1.000 ↑0.026 Clang5.0 1.000 1.000 − Clang7.0 1.000 1.000 − Clang9.0 1.000 1.000 − MIPS64 GCC4.8 1.000 1.000 − GCC5.0 1.000 1.000 − GCC7.0 1.000 1.000 − GCC9.0 1.000 0.900 ↓0.100 Clang3.5 0.919 0.946 ↑0.027 Clang5.0 0.923 0.949 ↑0.026 Clang7.0 0.975 0.975 − Clang9.0 0.950 0.975 ↑0.025 ARM32 GCC4.8 0.979 0.976 ↓0.003 GCC5.0 0.986 0.966 ↓0.020 GCC7.0 0.983 0.973 ↓0.010 GCC9.0 0.983 0.976 ↓0.007 Clang3.5 N/A N/A N/A Clang5.0 0.967 1.000 ↑0.033 Clang7.0 0.933 0.968 ↑0.035 Clang9.0 0.933 0.903 ↓0.030 ARM64 GCC4.8 0.992 0.985 ↓0.007 GCC5.0 0.985 0.989 ↑0.004 GCC7.0 0.993 0.986 ↓0.007 GCC9.0 0.978 0.978 − Average 0.977 0.981 ↑0.004Wang,etal. Table10:FunctionsrelatedtoCVE,thenumberofvulnerable CVE Function #Vuln/Poolsize functionsandsearchpoolsize CVE-2016-2109 asn1_d2i_read_bio 22/94669 CVE-2016-2176 X509_NAME_oneline 55/108141 CVE Function #Vuln/Poolsize CVE-2016-2178 dsa_sign_setup 3/16683 CVE-2004-0421 png_format_buffer 202/35707 CVE-2016-2182 BN_bn2dec 8/23085 CVE-2006-2937 asn1_d2i_ex_primitive 4/13864 CVE-2016-4802 telnet_do 143/48113 CVE-2008-0891 ssl_parse_clienthello_tlse 33/26950 CVE-2016-5419 create_conn 156/83446 xt CVE-2016-542 close_all_connections 6/47839 CVE-2008-1672 ssl3_send_client_key_excha 15/6549 CVE-2016-5420 Curl_ssl_config_matches 80/47835 nge CVE-2016-6302 tls_decrypt_ticket 22/32827 CVE-2009-3245 ec_GF2m_simple_group_copy 35/59421 CVE-2016-6303 MDC2_Update 7/18735 CVE-2010-2939 ssl3_get_key_exchange 46/54623 CVE-2016-6305 ssl3_read_bytes 34/37485 CVE-2012-0050 dtls1_process_record 37/54993 CVE-2016-7054 chacha20_poly1305_cipher 3/30741 |
CVE-2012-0884 pkcs7_decrypt_rinfo 27/66747 CVE-2016-8615 Curl_cookie_add 20/7490 CVE-2012-2110 CRYPTO_realloc_clean 29/64273 CVE-2016-8618 alloc_addbyter 17/7490 CVE-2012-2333 dtls1_enc 53/74497 CVE-2016-8623 cookie_sort 17/7684 CVE-2013-0166 OCSP_basic_verify 37/90825 CVE-2016-8624 parseurlandfillconn 53/49288 CVE-2013-1944 tailmatch 40/39329 CVE-2016-8625 create_conn 80/48570 CVE-2013-2174 Curl_urldecode 92/32786 CVE-2016-9586 dprintf_formatf 142/58629 CVE-2013-4353 ssl3_take_mac 2/96321 CVE-2017-1000099 file_do 135/49834 CVE-2013-6450 dtls1_hm_fragment_free 13/92288 CVE-2017-1000101 glob_range 16/49831 CVE-2014-0195 dtls1_reassemble_fragment 82/124593 CVE-2017-1000254 ftp_statemach_act 146/54082 CVE-2014-0221 dtls1_get_message_fragment 60/118673 CVE-2017-1000257 imap_state_fetch_resp 50/53720 CVE-2014-0224 ssl3_do_change_cipher_spec 98/144390 CVE-2017-17087 readfile 62/181458 CVE-2014-2970 ssl_set_client_disabled 74/119785 CVE-2017-2629 allocate_conn 47/49714 CVE-2014-3508 OBJ_obj2txt 64/123191 CVE-2017-3731 aes_gcm_ctrl 7/25732 CVE-2014-3509 ssl_scan_serverhello_tlsex 21/118259 CVE-2017-3733 ssl3_get_record 9/35117 t CVE-2017-8817 setcharset 50/54625 CVE-2014-3511 ssl23_get_client_hello 85/116759 CVE-2017-8818 allocate_conn 38/47104 CVE-2014-3513 ssl_scan_clienthello_tlsex 18/119553 CVE-2017-9502 parseurlandfillconn 51/49701 t CVE-2018-0500 Curl_smtp_escape_eob 137/55602 CVE-2014-3567 tls_decrypt_ticket 55/120491 CVE-2018-0732 generate_key 94/228493 CVE-2014-3571 ssl3_read_n 72/138185 CVE-2018-0734 dsa_sign_setup 66/244832 CVE-2014-3572 ssl3_get_key_exchange 62/138390 CVE-2018-0735 ec_scalar_mul_ladder 77/264580 CVE-2014-3613 Curl_cookie_add 146/47865 CVE-2018-0737 rsa_builtin_keygen 29/212152 CVE-2014-3620 Curl_cookie_add 145/47844 CVE-2018-0739 asn1_item_embed_d2i 94/215620 CVE-2014-3707 ContentTypeForFilename 46/47928 CVE-2018-1000120 ftp_done 132/55531 CVE-2015-0208 rsa_item_verify 42/139706 CVE-2018-1000122 readwrite_data 46/55203 CVE-2015-0209 d2i_X509_AUX 69/190737 CVE-2018-1000300 Curl_pp_readresp 131/55393 CVE-2015-0286 ASN1_TYPE_cmp 42/139924 CVE-2018-1000301 Curl_http_readwrite_header 144/55404 CVE-2015-0287 ASN1_item_ex_d2i 95/143459 s CVE-2015-0288 X509_to_X509_REQ 39/99957 CVE-2018-13785 png_check_chunk_length 89/26645 CVE-2015-1787 ssl3_get_client_key_exchan 77/139708 CVE-2018-16839 Curl_auth_create_plain_mes 66/50330 ge sage CVE-2015-1788 BN_GF2m_mod_inv 85/142251 CVE-2018-16840 Curl_close 89/50330 CVE-2015-1789 X509_cmp_time 65/133323 CVE-2018-16842 voutf 17/50340 CVE-2015-1790 PKCS7_dataDecode 75/142150 CVE-2019-12735 openscript 45/113131 CVE-2015-1791 ssl_session_dup 46/132745 CVE-2019-15601 file_connect 107/51494 CVE-2015-1794 BN_MONT_CTX_set 59/134445 CVE-2019-20079 win_enter_ext 67/204235 CVE-2015-3143 ConnectionExists 49/46810 CVE-2019-20807 f_histadd 27/112368 CVE-2015-3236 Curl_http 137/47203 CVE-2019-3823 smtp_endofresp 71/51511 CVE-2016-0702 BN_mod_exp_mont_consttime 128/138567 CVE-2019-5436 tftp_connect 88/50206 CVE-2016-0705 dsa_priv_decode 67/134703 CVE-2019-5482 tftp_connect 91/51140 CVE-2016-0754 parse_filename 15/47889 CVE-2019-7317 png_image_free 16/25666 CVE-2016-0755 ConnectionExists 51/47881 CVE-2020-12062 sink 240/108766CEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection CVE Function #Vuln/Poolsize CVE Function #Vuln/Poolsize CVE-2020-1414 order_hostkeyalgs 37/83955 CVE-2022-0554 do_buffer_ext 98/245652 CVE-2020-14145 order_hostkeyalgs 8/19083 CVE-2022-0572 ex_retab 82/246390 CVE-2020-1967 tls1_check_sig_alg 55/304247 CVE-2022-0629 ga_concat_shorten_esc 54/238129 CVE-2020-1971 GENERAL_NAME_get0_value 45/382577 CVE-2022-0685 vim_isupper 34/231658 CVE-2020-8177 tool_header_cb 16/58485 CVE-2022-0696 uc_list 24/233219 CVE-2020-8231 conn_is_conn 3/58574 CVE-2022-0714 change_indent 71/236013 CVE-2020-8284 Curl_init_userdefined 18/58854 CVE-2022-0729 regmatch 29/227856 CVE-2020-8285 wc_statemach 61/58853 CVE-2022-0778 BN_mod_sqrt 90/398807 CVE-2021-22876 Curl_follow 122/59705 CVE-2022-1154 regmatch 35/230013 CVE-2021-2289 suboption 203/100517 CVE-2022-1160 get_one_sourceline 58/233298 CVE-2021-2290 Curl_attach_connnection 8/59816 CVE-2022-1343 ocsp_verify_signer 72/414281 CVE-2021-2292 suboption 114/60082 CVE-2022-1381 parse_command_modifiers 75/225192 |
CVE-2021-22924 create_conn 70/60174 CVE-2022-1420 eval_lambda 33/226666 CVE-2021-2294 mqtt_send 155/69096 CVE-2022-1616 append_command 67/222888 CVE-2021-22947 ftp_statemachine 138/59965 CVE-2022-1619 cmdline_erase_chars 40/223361 CVE-2021-23840 evp_EncryptDecryptUpdate 57/250531 CVE-2022-1620 fname_match 53/215101 CVE-2021-23841 X509_issuer_and_serial_has 50/249972 CVE-2022-1621 store_word 49/218615 h CVE-2022-1629 find_next_quote 37/224725 CVE-2021-3711 ec_field_size 62/375683 CVE-2022-1733 skip_string 73/223723 CVE-2021-3778 find_match_text 35/266390 CVE-2022-1735 changed_common 91/239180 CVE-2021-3796 nv_replace 80/248784 CVE-2022-1769 get_one_sourceline 118/406467 CVE-2021-3872 win_redr_status 59/257985 CVE-2022-1771 getcmdline_int 77/229041 CVE-2021-3875 get_address 98/259779 CVE-2022-1785 ex_substitute 80/229555 CVE-2021-3903 update_topline 79/247614 CVE-2022-1851 op_format 51/226855 CVE-2021-3927 ex_put 45/232436 CVE-2022-1886 do_put 61/221747 CVE-2021-3928 suggest_trie_walk 60/232186 CVE-2022-1897 nv_g_cmd 69/223944 CVE-2021-3968 n_start_visual_mode 73/231725 CVE-2022-1898 nv_brackets 72/226336 CVE-2021-3973 get_visual_text 76/231162 CVE-2022-1927 parse_cmd_address 71/221446 CVE-2021-3974 nfa_regmatch 71/232251 CVE-2022-1942 open_cmdwin 39/222734 CVE-2021-3984 find_start_brace 97/232521 CVE-2022-1968 update_search_stat 58/224440 CVE-2021-4019 find_help_tags 83/225489 CVE-2021-4044 ssl_verify_cert_chain 167/432281 CVE-2021-4069 ex_open 64/224618 CVE-2021-4136 eval_lambda 33/227017 CVE-2021-4166 do_arg_all 45/219193 CVE-2021-4173 get_function_body 44/209648 CVE-2021-4187 get_function_args 44/223736 CVE-2021-4192 reg_match_visual 71/221447 CVE-2021-4193 getvcol 38/216149 CVE-2022-0128 find_ex_command 82/221859 CVE-2022-0156 get_function_args 42/209234 CVE-2022-0213 win_redr_status 53/222554 CVE-2022-0261 block_insert 26/211252 CVE-2022-0318 block_insert 29/210836 CVE-2022-0351 eval7 86/207850 CVE-2022-0359 init_ccline 38/213956 CVE-2022-0361 ex_copy 75/230686 CVE-2022-0368 u_undo_end 54/239900 CVE-2022-0392 bracketed_paste 100/262165 CVE-2022-0407 yank_copy_line 58/250423 CVE-2022-0408 suggest_trie_walk 72/266034 CVE-2022-0413 ex_substitute 90/243845 CVE-2022-0417 paste_option_changed 34/250760 CVE-2022-0443 free_buf_options 67/235800Wang,etal. REFERENCES [25] TaeGuenKim,YeoReumLee,BooJoongKang,andEulGyuIm.Binaryexecutable [1] SunwooAhn,SeonggwanAhn,HyungjoonKoo,andYunheungPaek.Practical filesimilaritycalculationusingfunctionmatching.TheJournalofSupercomputing, binarycodesimilaritydetectionwithbert-basedtransferablesimilaritylearning. 75(2):607–622,2019. InProceedingsofthe38thAnnualComputerSecurityApplicationsConference, [26] DiederikP.KingmaandJimmyBa.Adam:Amethodforstochasticoptimization. ACSAC’22,page361–374,NewYork,NY,USA,2022.AssociationforComputing InYoshuaBengioandYannLeCun,editors,3rdInternationalConferenceonLearn- Machinery. ingRepresentations,ICLR2015,SanDiego,CA,USA,May7-9,2015,Conference [2] SaedAlrabaee,PariaShirani,LingyuWang,andMouradDebbabi. Fossil:A TrackProceedings,2015. resilientandefficientsystemforidentifyingfossfunctionsinmalwarebinaries. [27] TakuKudo. Subwordregularization:Improvingneuralnetworktranslation ACMTransactionsonPrivacyandSecurity,page1–34,Feb2018. modelswithmultiplesubwordcandidates.arXivpreprintarXiv:1804.10959,2018. [3] SilvioCesare,YangXiang,andWanleiZhou.Controlflow-basedmalwarevariant- [28] Y.Lecun,L.Bottou,Y.Bengio,andP.Haffner.Gradient-basedlearningapplied detection.IEEETransactionsonDependableandSecureComputing,11(4):307–317, todocumentrecognition.ProceedingsoftheIEEE,86(11):2278–2324,1998. 2013. [29] XuezixiangLi,YuQu,andHengYin.Palmtree:Learninganassemblylanguage [4] HanjunDai,BoDai,andLeSong.Discriminativeembeddingsoflatentvariable modelforinstructionembedding.InProceedingsofthe2021ACMSIGSACConfer- modelsforstructureddata.InInternationalconferenceonmachinelearning,pages enceonComputerandCommunicationsSecurity,CCS’21,page3236–3251,New 2702–2711.PMLR,2016. York,NY,USA,2021.AssociationforComputingMachinery. [5] YanivDavid,NimrodPartush,andEranYahav.Statisticalsimilarityofbinaries. [30] YujiaLi,ChenjieGu,ThomasDullien,OriolVinyals,andPushmeetKohli.Graph ACMSIGPLANNotices,51(6):266–280,2016. matchingnetworksforlearningthesimilarityofgraphstructuredobjects.In [6] YanivDavid,NimrodPartush,andEranYahav.Similarityofbinariesthrough Internationalconferenceonmachinelearning,pages3835–3845.PMLR,2019. re-optimization. InProceedingsofthe38thACMSIGPLANConferenceonPro- [31] BingchangLiu,WeiHuo,ChaoZhang,WenchaoLi,FengLi,AihuaPiao,and |
grammingLanguageDesignandImplementation,pages79–94,2017. WeiZou. 𝛼diff:cross-versionbinarycodesimilaritydetectionwithdnn. In [7] YanivDavid,NimrodPartush,andEranYahav.Firmup:Precisestaticdetection Proceedingsofthe33rdACM/IEEEInternationalConferenceonAutomatedSoftware ofcommonvulnerabilitiesinfirmware.ACMSIGPLANNotices,53(2):392–404, Engineering,pages667–678,2018. 2018. [32] LannanLuo,JiangMing,DinghaoWu,PengLiu,andSencunZhu.Semantics- [8] YanivDavidandEranYahav.Tracelet-basedcodesearchinexecutables.Acm basedobfuscation-resilientbinarycodesimilaritycomparisonwithapplications SigplanNotices,49(6):349–360,2014. tosoftwareplagiarismdetection. InProceedingsofthe22ndACMSIGSOFT [9] StevenHHDing,BenjaminCMFung,andPhilippeCharland.Asm2vec:Boosting InternationalSymposiumonFoundationsofSoftwareEngineering,pages389–400, staticrepresentationrobustnessforbinaryclonesearchagainstcodeobfuscation 2014. andcompileroptimization.In2019IEEESymposiumonSecurityandPrivacy(SP), [33] LannanLuo,JiangMing,DinghaoWu,PengLiu,andSencunZhu.Semantics- pages472–489.IEEE,2019. basedobfuscation-resilientbinarycodesimilaritycomparisonwithapplications [10] YueDuan,XuezixiangLi,JinghanWang,andHengYin.Deepbindiff:Learning tosoftwareandalgorithmplagiarismdetection.IEEETransactionsonSoftware program-widecoderepresentationsforbinarydiffing.InNetworkandDistributed Engineering,43(12):1157–1177,2017. SystemSecuritySymposium,2020. [34] ZhenhaoLuo,PengfeiWang,BaoshengWang,YongTang,WeiXie,XuZhou, [11] ThomasDullienandRolfRolles.Graph-basedcomparisonofexecutableobjects DanjunLiu,andKaiLu.Vulhawk:Cross-architecturevulnerabilitydetection (englishversion).Sstic,5(1):3,2005. withentropy-basedbinarycodesearch.In30thAnnualNetworkandDistributed [12] SebastianEschweiler,KhaledYakdan,andElmarGerhards-Padilla.discovre:Effi- SystemSecuritySymposium,NDSS2023,SanDiego,California,USA,February27- cientcross-architectureidentificationofbugsinbinarycode.InNDSS,volume52, March3,2023.TheInternetSociety,2023. pages58–79,2016. [35] AndreaMarcelli,MarianoGraziano,XabierUgarte-Pedrero,YanickFratantonio, [13] MohammadRezaFarhadi,BenjaminCMFung,PhilippeCharland,andMourad MohamadMansouri,andDavideBalzarotti.Howmachinelearningissolvingthe Debbabi.Binclone:Detectingcodeclonesinmalware.In2014EighthInternational binaryfunctionsimilarityproblem.In31stUSENIXSecuritySymposium(USENIX ConferenceonSoftwareSecurityandReliability(SERE),pages78–87.IEEE,2014. Security22),pages2099–2116,Boston,MA,August2022.USENIXAssociation. [14] QianFeng,MinghuaWang,MuZhang,RundongZhou,AndrewHenderson,and [36] LucaMassarelli,GiuseppeADiLuna,FabioPetroni,LeonardoQuerzoni,and HengYin. Extractingconditionalformulasforcross-platformbugsearch. In RobertoBaldoni.Investigatinggraphembeddingneuralnetworkswithunsuper- Proceedingsofthe2017ACMonAsiaConferenceonComputerandCommunications visedfeaturesextractionforbinaryanalysis.InProceedingsofthe2ndWorkshop Security,pages346–359,2017. onBinaryAnalysisResearch(BAR),2019. [15] QianFeng,RundongZhou,ChengchengXu,YaoCheng,BrianTesta,andHeng [37] LucaMassarelli,GiuseppeAntonioDiLuna,FabioPetroni,RobertoBaldoni, Yin.Scalablegraph-basedbugsearchforfirmwareimages.InProceedingsofthe andLeonardoQuerzoni. Safe:Self-attentivefunctionembeddingsforbinary 2016ACMSIGSACConferenceonComputerandCommunicationsSecurity,pages similarity. InInternationalConferenceonDetectionofIntrusionsandMalware, 480–491,2016. andVulnerabilityAssessment,pages309–329.Springer,2019. [16] DebinGao,MichaelKReiter,andDawnSong. Binhunt:Automaticallyfind- [38] LinaNouh,AshkanRahimian,DjedjigaMouheb,MouradDebbabi,andAiman ingsemanticdifferencesinbinaryprograms. InInternationalConferenceon Hanna.Binsign:Fingerprintingbinaryfunctionstosupportautomatedanalysis InformationandCommunicationsSecurity,pages238–255.Springer,2008. ofcodeexecutables.InIFIPInternationalConferenceonICTSystemsSecurityand [17] JianGao,XinYang,YingFu,YuJiang,andJiaguangSun.Vulseeker:asemantic PrivacyProtection,pages341–355.Springer,2017. learningbasedvulnerabilityseekerforcross-platformbinary. In201833rd [39] AaronvandenOord,YazheLi,andOriolVinyals.Representationlearningwith IEEE/ACMInternationalConferenceonAutomatedSoftwareEngineering(ASE), contrastivepredictivecoding.arXivpreprintarXiv:1807.03748,2018. pages896–899.IEEE,2018. [40] AdamPaszke,SamGross,FranciscoMassa,AdamLerer,JamesBradbury,Gregory [18] KaimingHe,HaoqiFan,YuxinWu,SainingXie,andRossGirshick.Momentum Chanan,TrevorKilleen,ZemingLin,NataliaGimelshein,LucaAntiga,Alban contrastforunsupervisedvisualrepresentationlearning.InProceedingsofthe Desmaison,AndreasKöpf,EdwardYang,ZachDeVito,MartinRaison,Alykhan IEEE/CVFconferenceoncomputervisionandpatternrecognition,pages9729–9738, Tejani,SasankChilamkurthy,BenoitSteiner,LuFang,JunjieBai,andSoumith |
2020. Chintala.PyTorch:AnImperativeStyle,High-PerformanceDeepLearningLibrary. [19] XinHu,KangGShin,SandeepBhatkar,andKentGriffin.Mutantx-s:Scalable CurranAssociatesInc.,RedHook,NY,USA,2019. malwareclusteringbasedonstaticfeatures.In2013{USENIX}AnnualTechnical [41] KexinPei,ZhouXuan,JunfengYang,SumanJana,andBaishakhiRay. Trex: Conference({USENIX}{ATC}13),pages187–198,2013. Learningexecutionsemanticsfrommicro-tracesforbinarysimilarity. arXiv [20] YikunHu,YuanyuanZhang,JuanruLi,andDawuGu.Cross-architecturebinary preprintarXiv:2012.08680,2020. semanticsunderstandingviasimilarcodecomparison.In2016IEEE23rdInter- [42] KexinPei,ZhouXuan,JunfengYang,SumanJana,andBaishakhiRay.Learning nationalConferenceonSoftwareAnalysis,Evolution,andReengineering(SANER), approximateexecutionsemanticsfromtracesforbinaryfunctionsimilarity.IEEE volume1,pages57–67.IEEE,2016. TransactionsonSoftwareEngineering,2022. [21] HeHuang,AmrMYoussef,andMouradDebbabi.Binsequence:Fast,accurate [43] JannikPewny,BehradGarmany,RobertGawlik,ChristianRossow,andThorsten andscalablebinarycodereusedetection.InProceedingsofthe2017ACMonAsia Holz.Cross-architecturebugsearchinbinaryexecutables.In2015IEEESympo- ConferenceonComputerandCommunicationsSecurity,pages155–166,2017. siumonSecurityandPrivacy,pages709–724.IEEE,2015. [22] JiyongJang,AbeerAgrawal,andDavidBrumley.Redebug:Findingunpatched [44] JannikPewny,FelixSchuster,LukasBernhard,ThorstenHolz,andChristian codeclonesinentireosdistributions.In2012IEEESymposiumonSecurityand Rossow.Leveragingsemanticsignaturesforbugsearchinbinaryprograms.In Privacy,pages48–62,2012. Proceedingsofthe30thAnnualComputerSecurityApplicationsConference,pages [23] JeffJohnson,MatthijsDouze,andHervéJégou.Billion-scalesimilaritysearch 406–415,2014. withGPUs.IEEETransactionsonBigData,7(3):535–547,2019. [45] KimberlyRedmond,LannanLuo,andQiangZeng.Across-architectureinstruc- [24] UlfKargénandNahidShahmehri.Towardsrobustinstruction-leveltracealign- tionembeddingmodelfornaturallanguageprocessing-inspiredbinarycode mentofbinarycode.In201732ndIEEE/ACMInternationalConferenceonAuto- analysis.arXivpreprintarXiv:1812.09652,2018. matedSoftwareEngineering(ASE),pages342–352.IEEE,2017. [46] NoamShalevandNimrodPartush.Binarysimilaritydetectionusingmachine learning.InProceedingsofthe13thWorkshoponProgrammingLanguagesandCEBin:ACost-EffectiveFrameworkforLarge-ScaleBinaryCodeSimilarityDetection AnalysisforSecurity,PLAS’18,page42–47,NewYork,NY,USA,2018.Association TestingandAnalysis,ISSTA2023,page1106–1118,NewYork,NY,USA,2023. forComputingMachinery. AssociationforComputingMachinery. [47] NoamShalevandNimrodPartush.Binarysimilaritydetectionusingmachine [54] XiaojunXu,ChangLiu,QianFeng,HengYin,LeSong,andDawnSong.Neu- learning.InProceedingsofthe13thWorkshoponProgrammingLanguagesand ralnetwork-basedgraphembeddingforcross-platformbinarycodesimilarity AnalysisforSecurity,pages42–47,2018. detection.InProceedingsofthe2017ACMSIGSACConferenceonComputerand [48] PariaShirani,LeoCollard,BasileLAgba,BernardLebel,MouradDebbabi,Lingyu CommunicationsSecurity,pages363–376,2017. Wang,andAimanHanna. Binarm:Scalableandefficientdetectionofvulner- [55] ZhengziXu,BihuanChen,MahinthanChandramohan,YangLiu,andFuSong. abilitiesinfirmwareimagesofintelligentelectronicdevices. InInternational Spain:securitypatchanalysisforbinariestowardsunderstandingthepainand ConferenceonDetectionofIntrusionsandMalware,andVulnerabilityAssessment, pills.In2017IEEE/ACM39thInternationalConferenceonSoftwareEngineering pages114–138.Springer,2018. (ICSE),pages462–472.IEEE,2017. [49] WeiTang,PingLuo,JialiangFu,andDanZhang.Libdx:Across-platformand [56] JiaYang,CaiFu,Xiao-YangLiu,HengYin,andPanZhou.Codee:Atensorembed- accuratesystemtodetectthird-partylibrariesinbinarycode. In2020IEEE dingschemeforbinarycodesearch.IEEETransactionsonSoftwareEngineering, 27thInternationalConferenceonSoftwareAnalysis,EvolutionandReengineering 2021. (SANER),pages104–115,2020. [57] ZepingYu,RuiCao,QiyiTang,SenNie,JunzhouHuang,andShiWu. Order [50] AshishVaswani,NoamShazeer,NikiParmar,JakobUszkoreit,LlionJones, matters:Semantic-awareneuralnetworksforbinarycodesimilaritydetection. AidanNGomez,ŁukaszKaiser,andIlliaPolosukhin.Attentionisallyouneed. InProceedingsoftheAAAIConferenceonArtificialIntelligence,volume34,pages Advancesinneuralinformationprocessingsystems,30,2017. 1145–1152,2020. [51] HaoWang,WenjieQu,GiladKatz,WenyuZhu,ZeyuGao,HanQiu,Jianwei [58] ZepingYu,WenxinZheng,JiaqiWang,QiyiTang,SenNie,andShiWu.Codecmr: Zhuge,andChaoZhang.jtrans:Jump-awaretransformerforbinarycodesimi- Cross-modalretrievalforfunction-levelbinarysourcecodematching.Advances larity.arXivpreprintarXiv:2205.12713,2022. inNeuralInformationProcessingSystems,33:3872–3883,2020. |
[52] HuaijinWang,PingchuanMa,YuanyuanYuan,ZhiboLiu,ShuaiWang,Qiyi [59] XiaoyaZhu,JunfengWang,ZhiyangFang,XiaokangYin,andShengliLiu.Bbde- Tang,SenNie,andShiWu.Enhancingdnn-basedbinarycodefunctionsearch tector:Apreciseandscalablethird-partylibrarydetectioninbinaryexecutables withlow-costequivalencechecking.IEEETransactionsonSoftwareEngineering, withfine-grainedfunction-levelfeatures.AppliedSciences,13(1),2023. 49(1):226–250,2023. [60] FeiZuo,XiaopengLi,PatrickYoung,LannanLuo,QiangZeng,andZhexinZhang. [53] XiangzheXu,ShiweiFeng,YapengYe,GuangyuShen,ZianSu,SiyuanCheng, Neuralmachinetranslationinspiredbinarycodesimilaritycomparisonbeyond GuanhongTao,QingkaiShi,ZhuoZhang,andXiangyuZhang.Improvingbinary functionpairs.arXivpreprintarXiv:1808.04706,2018. codesimilaritytransformermodelsbysemantics-driveninstructiondeemphasis. [61] zynamics.Bindiff."https://www.zynamics.com/bindiff.html",2018. InProceedingsofthe32ndACMSIGSOFTInternationalSymposiumonSoftware |
2403.03024 Toward Improved Deep Learning-based Vulnerability Detection AdrianaSejfia SatyakiDas sejfia@usc.edu satyakid@usc.edu UniversityofSouthernCalifornia UniversityofSouthernCalifornia California,USA California,USA SaadShafiq NenadMedvidović saad4is@hotmail.com neno@usc.edu JohannesKeplerUniversity UniversityofSouthernCalifornia Austria California,USA ABSTRACT 34,35],discovernewwaysinwhichtheycanoccur[31],automate Deeplearning(DL)hasbeenacommonthreadacrossseveralrecent theirdetection[33,37],andsoon.Inparticular,studiesfocusingon techniquesforvulnerabilitydetection.Theriseoflarge,publicly automatedvulnerabilitydetectionhavegarneredincreasedinterest. availabledatasetsofvulnerabilitieshasfueledthelearningpro- Acommonrecentthreadacrossthesestudiesistheiruseofdeep cessunderpinningthesetechniques.Whilethesedatasetshelpthe learning (DL) based techniques [14, 15, 21, 23, 29, 30, 42], with DL-basedvulnerabilitydetectors,theyalsoconstrainthesedetec- publiclyavailabledatasetsofvulnerablecodeservingasdriversfor tors’predictiveabilities.Vulnerabilitiesinthesedatasetshaveto thisbodyofwork. berepresentedinacertainway,e.g.,codelines,functions,orpro- Usingthesedatasets,existingtechniquesattempttolearnhow gramsliceswithinwhichthevulnerabilitiesexist.Werefertothis vulnerablecodeismanifestedsothattheycansubsequentlydetect representationasabaseunit.Thedetectorslearnhowbaseunits newoccurrences.However,thisisconstrainedbytherepresenta- canbevulnerableandthenpredictwhetherotherbaseunitsare tionofvulnerabilitiesinthedatasets:somedatasetshighlightthe vulnerable.Wehavehypothesizedthatthisfocusonindividualbase functions[14,42],othersthelinesofcode[21,23],andyetothers unitsharmstheabilityofthedetectorstoproperlydetectthosevul- theprogramdependencegraph(PDG)slices[15]thatcontainthe nerabilitiesthatspanmultiplebaseunits(orMBUvulnerabilities). vulnerabilities.Inturn,thechosenrepresentationservesasthebase Forvulnerabilitiessuchasthese,acorrectdetectionoccurswhen unitfordetection.Simplyput,theexistingDL-baseddetectorswork allcomprisingbaseunitsaredetectedasvulnerable.Verifyinghow bylearninghowinstancesofagivenbaseunitcanbevulnerable existingtechniquesperformindetectingallpartsofavulnerability andthenpredictingwhetherotherinstancesofthesamebaseunit isimportanttoestablishtheireffectivenessforotherdownstream arevulnerable. tasks.Toevaluateourhypothesis,weconductedastudyfocusing This strategy works well and is useful when all of the code onthreeprominentDL-baseddetectors:ReVeal,DeepWukong,and pertainingtoavulnerabilityiscontainedwithinasinglebaseunit.A LineVul.OurstudyshowsthatallthreedetectorscontainMBU concreteexampleofthistypeofvulnerabilityisCVE-2021-33815[4], vulnerabilitiesintheirrespectivedatasets.Further,weobserved relatedtoarrayaccessintheFFmpegopen-sourcelibraryforA/V significantaccuracydropswhendetectingthesetypesofvulner- processing[5].Thisvulnerabilityexistedinasingleline,withina abilities.Wepresentourstudyandaframeworkthatcanbeused singlefunction[8].Asimplifiedviewofthevulnerabilityanditsfix tohelpDL-baseddetectorstowardtheproperinclusionofMBU ispresentedinListing1,withaleading“+”denotingaddedcode vulnerabilities. andaleading“–”deletedcode.Specifically,thevulnerabilitywas causedbythewaytheifconditionwascheckingforthesizeof ACMReferenceFormat: thearraytobeallocatedinthelatercalltomemset. Adriana Sejfia, Satyaki Das, Saad Shafiq, and Nenad Medvidović. 2024. TowardImprovedDeepLearning-basedVulnerabilityDetection.In2024 Listing1:FixforCVE-2021-38315inFFmpeg IEEE/ACM46thInternationalConferenceonSoftwareEngineering(ICSE2024), April14–20,2024,Lisbon,Portugal.ACM,NewYork,NY,USA,12pages. unsigned long dest_len = dc_count * 2LL; https://doi.org/10.1145/3597503.3608141 - if (dc_count > (6LL*td->xsize*td->ysize+63)/64) + if (dc_count != (td->xsize>>3)*(td->ysize>>3)*3) 1 INTRODUCTION return INVALIDDATA; Softwarevulnerabilitieshavebeenthefocusofavarietyofstudies. memset(td->data, 0, dest_len + PADDING); Researchershavetriedtobetterunderstandvulnerabilities[13,22, Whiledetectingsuchvulnerabilitiesisuseful,manyreal-world Permissiontomakedigitalorhardcopiesofpartorallofthisworkforpersonalor vulnerabilitiesspanmorethanonebaseunit(line,function,orslice). classroomuseisgrantedwithoutfeeprovidedthatcopiesarenotmadeordistributed An example is CVE-2014-3647 [2], discovered in the Linux ker- forprofitorcommercialadvantageandthatcopiesbearthisnoticeandthefullcitation nel.Thisvulnerabilitywasrootedinhowthekernelchangedthe onthefirstpage.Copyrightsforthird-partycomponentsofthisworkmustbehonored. Forallotheruses,contacttheowner/author(s). register(RIP)thatcontainedtheinstructiontobeexecutedwhen ICSE2024,April14–20,2024,Lisbon,Portugal performingcertainoperations,suchasjmp,call,orret;thevul- ©2024Copyrightheldbytheowner/author(s). nerabilityultimatelycouldallowOSguestuserstocauseadenialof ACMISBN979-8-4007-0217-4/24/04. |
ERROR: type should be string, got "https://doi.org/10.1145/3597503.3608141 service.Thisvulnerabilitywasfixedthroughtwopatches[8,9].For 4202 raM 5 ]ES.sc[ 1v42030.3042:viXraICSE2024,April14–20,2024,Lisbon,Portugal AdrianaSejfia,SatyakiDas,SaadShafiq,andNenadMedvidović fromReVeal’sfunctionsandthenranDeepWukong’smodelon thetransformeddataset.DeepWukong’sreportedaccuracyonits owndatasetisalwaysabove90%,butwhenappliedtothedataset usedbyReVealtheaccuracydroppedto56%.Suchsignificantde- creasesrecurredacrossourpilots,wheneveranexistingdetector wasappliedondatadrawnfromdifferentdistributionsthanthose onwhichithasbeentrained.Thisledustopostulatethat,ifthese state-of-the-artdetectorsdidnotexplicitlytakeintoaccountvulner- abilitiesthatspanmorethanoneoftheirbaseunitofchoice,their performanceonMBUvulnerabilitieswillanalogouslysuffer. Forourin-depthstudyofthisissue,wefocusedonthreepromi- nentDL-basedvulnerabilitydetectors:theabove-mentionedReVeal Figure1:SomefunctionsinvolvedintheCVE-2014-3647vul- andDeepWukong,aswellastheline-leveldetectorLineVul[21]. nerability.Eachrectanglerepresentsafunction. Wescrutinizedthedata,approaches,andimplementationsofthe threedetectorstoanswerthefollowingresearchquestions: illustration,asimplifiedviewofthefunctionsinvolvedinthevulner- • RQ1:Whatpercentageofthevulnerabilitiesinthedetectors’ ability,alongwiththeirinterdependencies,ispresentedinFigure1. datasetsareMBUvulnerabilities? Ourhypothesiswasthat Specifically,thevulnerabilitywasspreadacross(1)functionsthat ifMBUvulnerabilitiesformedonlyanegligiblepartofthe performedtheabove-mentionedjmp,call,andretoperations; datasets,thesedatasetswerenotrepresentativeofreal-world (2)functionsthatensuredthekernelisnotleftinaninconsistent vulnerabilities.However,wediscoveredthatMBUvulnerabil- stateincasesoffailure(segm_desc);and(3)functionsthatassigned ities’presenceinthesedatasetsissignificant:theycomprise theRIPs(assign_eip_near).Allthesefunctionstookpartinthe 22%ofallvulnerabilitiesinReVeal’sdataset,53%inDeep- vulnerability,meaningthatallofthem(aswellasseveralothers Wukong’sdataset,and61%and37%,respectively,intwo notshowninthefigure)hadtobetaggedasvulnerableinorderfor differentconfigurationsofLineVul’sdataset.Thecomplete thevulnerabilityitselftobedetected. resultscanbefoundinSection4.2. ThisdiscrepancybetweentheprevalentfocusofDL-basedvul- • RQ2:HowarethecomprisingpartsofMBUvulnerabilities nerabilitydetectorsonindividualbaseunits(IBUs)andthespreadof usedinthetrainingandevaluationofthedetectors?Ourgoal manyreal-worldvulnerabilitiesacrossmultiplebaseunits(MBUs) wastodeterminewhetherthedetectorsconsiderrealistic motivatedustoexaminehowexistingdetectorsperformonMBUs.To scenariosbygroupingallbaseunitspertainingtoasingle ourknowledge,nopriorresearchhasstudiedthisproblem.Specifi- vulnerabilitywhentraining,validating,testing,andreport- cally,fordeveloperstounderstandavulnerabilitythatspansmore ingtheaccuracies.Wefoundthatthethreedetectorsfailto thanonebaseunit,allinvolvedbaseunitsneedtobedetectedas properlytakeMBUvulnerabilitiesintoaccount.Moredetails vulnerable.IntheexampleofCVE-2014-3647fromFigure1,de- onthefindingscanbefoundinSection4.3.Theanswersto tectingonlyoneinvolvedlineorfunctionwouldnotresultinthe thisquestionalsospawnedRQ3andRQ4. successfulmitigationofthisvulnerability,stillleavingthesecurity • RQ3:Howaccuratearethedetectorsinactuallyuncovering threatinthecode.EstablishingtheeffectivenessofDL-basedde- vulnerabilities?Sincetheaccuracyreportsofthevulnerabil- tectorsforMBUvulnerabilitiesisalsoimportantforsubsequent itydetectorsfocusonbaseunitsasopposedtovulnerabilities, research.Forexample,astudyfocusedonautomatedvulnerability weanalyzedthethreedetectors’evaluationresultstoobtain patchgenerationmayrelyonaDL-baseddetectortoautomatically theiraccuraciesoncompletevulnerabilities,bygrouping collectdataonwhatcodeisvulnerable.Inaccuratedetectionof allbaseunitsofeachMBUvulnerabilitypriortoreporting. MBUswilldirectlyharmsuchastudyandallofitsfollow-ons. Sincewewerespecificallylookingatthevulnerabledatain This is why we decided to examine how state-of-the-art DL- thedataset,wecomputed(1)thetruepositiverates(TPR), baseddetectorsperformoncompletevulnerabilities,asopposedto (2)precision,and(3)Matthewscorrelationcoefficient(MCC), onlytheircomprisingIBUs.Ourguidinghypothesiswasthatthe whichwasincludedduetoitsapplicabilityincasesofim- performanceofthesedetectorsonMBUvulnerabilitiesisdependent balanceddatasets,ascenariowhichvulnerabilitydetectors onhowtheyweretrained.Thishypothesiswasinspiredbyseveral face.Wefoundthatthevaluesofthethreemetricsgenerally pilotexperimentsweranonDL-baseddetectorswithpubliclyavail- dropwhenconsideringcompletevulnerabilitiesasopposed ablemodels.Specifically,weobtainedresultsofeachdetector’s totheirconstituentbaseunits.Thedetailsofouranalysis" |
performanceondatausedinstudiesreportedforotherdetectors. canbefoundinSection4.4. Ineachcase,wesawasignificantdropinadetector’saccuracyas • RQ4:Doestrainingandevaluatingthevulnerabilitydetectors comparedtoitspublishedresults. inamorerealisticwayaffecttheiraccuracies?Forthisques- As an example, in one of these experiments, we considered tion,weretrainedthedetectorsbyadjustingthedivision twoprominentDL-baseddetectors:ReVeal[14],afunction-level ofthedataintotraining,validating,andtestingsets.When pipelineforvulnerabilitydetection,andDeepWukong[15],aslice- dividingthedataacrossthesethreesets,wefocusedoncom- leveldetector.Aspartoftheexperiments,wecheckedtheperfor- pletevulnerabilitiesinsteadofbaseunits.Inotherwords,we manceofDeepWukongonReVeal’sdataset.Wefirstobtainedslices implementedaconstraintthatensuredasingleMBU’sbaseTowardImprovedDeepLearning-basedVulnerabilityDetection ICSE2024,April14–20,2024,Lisbon,Portugal unitsareallassignedtooneofthetraining,validating,or inthecode,causingthesamevulnerabilityinvariouslocations, testingsets,andarenotspreadoutamongstthethreesets. developers often opt to fix many or all of these manifestations Wefoundthatthethreemetrics’valuesareimpactedbythis, ofthesamevulnerabilityinthesamevulnerability-fixingpatch. morerealistictrainingandtestingapproach.Ourfindings Listing2:BufferoverflowissueinQEMU arereportedinSection4.5. FunctionA(){ SomeofthepriorworkwestudieddidconsiderMBUvulnerabil- ... ities[14],butmostlyexpressedconcernsthatsuchvulnerabilities - if (offset > 0x200) maycontainnoiseandwouldthuspollutethelearningprocess.We + if (offset >= 0x200) manuallyanalyzedaportionoftherelevantdatasetstoverifythese ... } claims.Ouranalysisrevealedthat(1)thisisnotalwaysthecaseand FunctionB(){ (2)whenthatdoeshappen,therearewaystoautomaticallyiden- ... tifytrueMBUvulnerabilities,asdescribedinSection3.Giventhis - if (offset > 0x200) findingandthedifficultiesexistingdetectorsexperiencewithMBU + if (offset >= 0x200) vulnerabilities(Section4),inSection5wepresentanautomated ... } frameworktoenableMBUvulnerabilities’appropriateinclusionin FunctionC(){ DL-baseddetectors.Wemaketheartifactsfromourstudyandthe ... componentsofourframeworkpubliclyavailable[1]. - if (offset > 0x200) Thekeycontributionsofthispaperarethusthree-fold: + if (offset >= 0x200) ... • AdefinitionandcategorizationofMBUvulnerabilities. } • A systematic analysis of the prevalence and detection ac- .... curacyofMBUvulnerabilitiesinstate-of-the-artDL-based Asanexample,thishappenedwitharecurringbufferoverflow detectors. vulnerabilityintheopen-sourceemulatorQEMU[10].Apartialren- • AnautomatedframeworkforappropriateinclusionofMBU ditionoftheissueanditscorrespondingfixcanbefoundinListing2, vulnerabilitiesinDL-baseddetection. followingthesameformattingconventionaspresentedabove[?]. Theissue,presentinthedeletedlines,arosefromthefactabuffer’s 2 MBUVULNERABILITIES length(offset)wasnotcheckedproperlybeforewritingdata. Thefixingpatchmodifiedthecorrespondingchecksinthesame Thecomprisingbaseunits(programlines,slices,orfunctions)of wayinthethreefunctionspresentinthefigure,aswellasthreead- anMBUvulnerabilitycombinetocontributetothevulnerability. ditionalfunctionsthathavebeenelidedforspace.Thevulnerability Whileeachofthesebaseunitsmaycontributetodifferentaspectsof ineachofthesefunctionsisindependentoftheotherfunctionsthat thevulnerability,itisthroughtheirinterplaythatthevulnerability wereanalogouslychanged.Wetermthesetypesofvulnerabilities ismanifested.GoingbacktotheexampleofCVE-2014-3647[2] repeatedIBU.1WewanttonotethatrepeatedIBUvulnerabilities (recallFigure1),thisvulnerabilityinvolvedseveralfunctionsthat arenotduplicatevulnerabilities.Whiletheunderlyingissueisthe invokedeachother.Twoprimaryissuesthat,intandem,createdthis sameinthemanycodelocationstheyexist,thecontextinwhich vulnerabilitywere(1)notcheckingwhethercertaindestinations theyexistandthewayinwhichtheycanbemisusedmaydiffer. werecanonical(functionscoloredinblueandgreen)beforemaking Vulnerabilitypatchesmaycontainirrelevantchangestothefix RIP changes and (2) improperly handling faults in RIP loading of the vulnerability. Previous work has pointed to the fact that (functionscoloredinyellowandgreen). securityfixescaninduceotherlogic-preservingchanges,referred ThecharacterizationofMBUvulnerabilitiesisimportantbecause toascasualty[36]andtrivial[25]changes.Whilenecessaryto italsohelpsusidentifyvulnerabilitiesthatarenotMBU.Beforewe makethecodework,thesechangesdonotrevealinformationabout dwellonthis,abitofadditionalcontextisnecessary.Thevulner- howthatcodeisvulnerable,andtheymayendupinflatingthesize abilitydatasetsusedinDL-baseddetectorsareprimarilycollected ofapatchandobscuringthesourceofthevulnerability.Thatiswhy byfocusingonthecodepatchesthatfixedthevulnerabilities:by identifyingwhetheracompoundpatchfixesanMBUvulnerability |
consideringthepartsofthecodethatwerechangedtofixavulner- involves isolating the irrelevant changes. There are automated ability,onecanderivewhichcodelocationswerevulnerableinthe toolsthathelptowardsthatgoal[25,36].Sometimes,collectingthe firstplace.Forinstance,indatasetswherethebaseunitisafunc- vulnerabilitydatainvolvesmanuallylabelingthevulnerablestatus tion,allfunctionsthatwerechangedinthepatch(es)thatfixeda ofindividualbaseunits[42],reducingthelikelihoodthatirrelevant givenvulnerabilityarecollected(andsometimescleanedinorderto changesarepresentinthepatches. reducethepresenceofirrelevantchanges)andaddedtothedataset. Oneobservationwemadebasedonamanualanalysisofthe 3 DISTINGUISHINGCOMPOUNDPATCHES existing datasets is that while patches themselves may be com- pound, i.e., they introduce changes to multiple base units, this BeforewestartedourstudyofMBUvulnerabilities,weneeded doesnotnecessarilymeanthosepatchesfixMBUvulnerabilities. to correctly identify them. From the datasets used in the three Specifically,compoundpatchesmayfixavulnerabilitythatisin- dependently manifested in multiple code locations, that is, the 1Notethat,aswithMBUvulnerabilities,thedefinitionofwhatconstitutesarepeated IBUvulnerabilityisdependentonthebaseunit.Forexample,avulnerabilitymaybe codelocationsaresimilarlyvulnerableandtheyarenotdepen- repeatedIBUwhenthebaseunitisafunction,butnotwhenitisaline,ifthechanges dentoneachother.Incaseswhenanerrorwasrepeatedlymade inthefunctionarespreadacrossmultiplelines.ICSE2024,April14–20,2024,Lisbon,Portugal AdrianaSejfia,SatyakiDas,SaadShafiq,andNenadMedvidović detectors,wewereabletoonlyobtaininformationaboutwhich inC3’sempiricalresults,ASTsandDBSCANwereshowntoper- vulnerability-fixingpatcheswerecompoundbutnotwhichvulner- formbetterthantheothertwooptions(line-basedchangesand abilitieswereMBUs.Asdiscussedintheprevioussection,com- HCA,respectively).Notethatourtwomodificationsdonotalter poundpatchescanfixeitherMBUvulnerabilitiesorrepeatedIBU thecorealgorithmofC3,justwhenandhowitisapplied. vulnerabilities.Thechallengeweneededtoaddresswastocorrectly Listing3:FixforCVE-2017-0596inAndroid distinguishthepatchesthatfixedMBUvulnerabilitiesfromthose thatfixedrepeatedIBUvulnerabilities.Thiswouldpermitusto ERRORTYPE SoftMPEG4Encoder::releaseEncoder() { - if (!mStarted) { identifyMBUvulnerabilitiesandconducttherestofthestudy. - return OMX_ErrorNone; Theproblemofdistinguishingcompoundpatcheswasessentially + if (mEncParams) { oneofestablishinghowsimilarchangesinapatchare.Repeated + delete mEncParams; IBUvulnerabilitiescontainhighlysimilar,repetitivechanges,as + mEncParams = NULL; canbeseenintheexampleofthebufferoverflowvulnerabilityde- } - pictedinListing2.Thesamechangehappenedinmultiplelocations - mStarted = false; inthecode.MBUvulnerabilitiesfollowmoreintricatepatternsof + if (mHandle) { codechanges. This iswhat happenedwiththe fixfor theCVE- + delete mHandle; 2017-0596vulnerabilityinAndroid[3].Thiswasanelevationof + mHandle = NULL; + privilegevulnerabilityandmaliciousactorscouldexecutearbitrary } coderemotely.Thefixinvolvedmakingchangestovariousfunc- tions,threeofwhichareshowninListing3.Thechangesinthese +void SoftAACEncoder2::onReset() { threefunctionsvarysignificantly,especiallywhencomparedto + delete[] mInputFrame; thechangesthatfixedthevulnerabilityinListing2.Inthefirst + mInputFrame = NULL; + mInputSize = 0; function,ifconditionsweremodifiedandcallsandassignments + weredeleted.Thesecondfunctiondidnotexistbeforeandinthe + mSentCodecSpecificData = false; thirdfunction,acalltothissecondfunctionwasadded. + mInputTimeUs = -1ll; Beyondestablishingthesimilarityofthechanges,weneeded + mSawInputEOS = false; + mSignalledError = false; anapproachthatcouldtellusifallofthechangesinapatchwere +} sufficientlysimilartobelongtoonegroupornot.Ifthechanges belongtoonegroup,thenwecanconcludeacompoundpatchhad SoftAACEncoder2::~SoftAACEncoder2() { repeatedandverysimilarchanges,andthus,fixesarepeatedIBU - delete[] mInputFrame; vulnerability.Otherwise,wecanconcludethepatchfixesanMBU - mInputFrame = NULL; + onReset(); vulnerability.Clusteringisoneapproachthathelpswithgrouping } elements based on their similarity. That is why we considered C3wasoriginallyevaluatedongeneralpatches.Sincewespecif- reusingapproachesemployedtoclustercodechanges,suchasthe icallywantedtousethisapproachforMBUvulnerabilitypatches, C3approachproposedbyKreutzeretal.[26]. wecollectedarepresentativegroundtruthtomeasureitsaccuracy C3takesahistoryofcommitsfromarepository,groupschanges inthiscontext.Ourgroundtruthwasobtainedfromasampleof basedonfunctions,computesthepairwisesimilarityofsuchchanges, theavailabledatasetofReVeal,i.e.,theFFmpeg[5]andQEMU[10] andfinallyclustersthem.C3canbeconfiguredto(1)representthe securitycommits.Bothofthesesystemsarelarge,havebeenused changes via lines of code or Abstract Syntax Trees (ASTs), and in practice for more than two decades, and have a rich history |
(2)useahierarchicalclusteringalgorithm(HCA)ortheDBSCAN ofpubliclyavailablevulnerabilities.Becauseoftheirhistory,we algorithmfortheclusteringpart.Thesetwoclusteringalgorithms wereconfidentthatthecompoundpatchestheycontainarerep- workwellincaseswhenonedoesnotknowapriorithenumberof resentativeofvulnerabilitiesingeneral.Toobtainasamplesize, clusterstoexpect. weusedthewell-knownmarginoferrorsamplesizeformulaand The C3 approach by and large applies to the problem of dis- followedcommonpracticefortheparametersoftheformula:90% tinguishingcompoundpatcheswithtwoexceptions.First,forour fortheconfidenceleveland10%forthemarginoferror[38].The purposes,oneonlyneedstoconsiderthecommit/s(i.e.,thepatches) formula and the parameters resulted in a sample of 67 patches. thatfixedagivenvulnerabilityandnotthewholehistoryofcom- Twosoftwareengineeringresearcherswithseveralyearsofexpe- mits.ThisisasimplificationofC3’soriginalapproachaswewould riencelabeledthechangesacrossthese67patchesanddiscussed notneedtoconductpairwisecomparisonsforchangesthathave disagreements.Disagreementsthatcouldnotberesolvedbetween happenedthroughoutthehistoryofasystem.Second,becausethe thetwoengineers,wereresolvedbyathirdresearcherwithmore definitionofcompoundpatchesisdeterminedbythebaseunit, thansevenyearsofexperience.Ultimately,outofthe67patches, ourgroupingofthechangesalsohadtobedoneusingthevarious 19wereconcludedtoberepeatedIBU,andtheremaining48,were baseunits,andnotjustfunctions.Tofitthescenarioofcompound MBU. patches,wemodifiedC3’sapproachtoaddressthesetwoexcep- ThemodifiedC3approachyieldedaprecisionof84%,recallof tions.SinceC3doesnothaveapubliclyavailableimplementation, 78%,andoverallaccuracyof73%,whereourclassofinterest(posi- weimplementeditalongwiththetwomodificationsourselves.Fur- tiveclass)wasMBUvulnerabilities.Accuracymetricsaround75% ther,inourimplementationofC3,wepickedrepresentingcode aregenerallyacceptableinthecommunity,but,wewereconcerned changesusingASTsandtouseDBSCANfortheclusteringportion;TowardImprovedDeepLearning-basedVulnerabilityDetection ICSE2024,April14–20,2024,Lisbon,Portugal aboutmissing22%ofMBUvulnerabilities(astherecallmetricwas 4.1 Obtainingandcuratingdatasets 78%).Oursubsequentanalysesofestablishingtheusefulnessofthe Initsdataset,ReVealcontainsfunctionsthatarelabeledasvul- detectorsforMBUvulnerabilitieswouldbenegativelyaffectedby nerableandnon-vulnerable.Forouranalysis,weneededaccess it.In22%ofthecaseswhenwewouldhaveMBUvulnerabilities, tochangesthathappenedtothevulnerablefunctions.Sinceour wewouldconsiderthemasrepeatedIBU.Thiswouldharmour approachtodetectingMBUvulnerabilitiesreliesonpatches,we conclusions.Additionally,weenvisionafutureinwhichDL-based neededaccesstometadata,i.e.,linksorhashes,thatcouldhelpus detectors,priortotraining,identifywhichvulnerabilitiesintheir identifyandretrievethepatch.ReVealreleasedpatchhashesfor datasetareMBUsothattheycanensurethesevulnerabilitiesare onlyaportionofthefunctionsintheirdataset,theonesobtained consideredappropriatelyintheirtraining,testing,andreported intheFFmpegandQEMUsystems.Wecontactedtheauthorsof accuracies(wepresentmoreofthisvisioninSection5).IftheC3 ReVealforpatchinformationfortheremainingofthedataintheir approachisusedinthefuturetodistinguishcompoundpatches datasetbuttheyinformedusthatduetoanerrorinthedatacol- priortothetrainingofDL-baseddetectors,wearguehavingahigh lection,theydidnothaveit.WeidentifiedMBUpatchesfromthe recallisimportant,evenifatrade-offbetweenprecisionandre- portionofthedatawithpubliclyavailableinformation,removed callisneeded.Thisissobecause,withalowrecall,thedetectors IBUvulnerabilitiestorunouranalysis,andpresentresultsonlyon wouldlearnthattheMBUvulnerabilitiesthatarenotrecalledare thatportionofthedata. reallyrepeatedIBUsandshouldbebrokendowntotheirbaseunits. WehadasimilarproblemwiththedatasetusedinDeepWukong. Thiswouldharmtheeffectivenessofthesedetectorswhenusedby DeepWukong’sbaseunitisPDGslices.Theirdatasetalsocontains developersorwhenusedinsubsequentstudies. testcasesthatcorrespondtoonevulnerability:eachtestcaseis Seekingtoboosttherecallespeciallywewentbacktotheground usedtogeneratevulnerableslices.Thesubjectsystemsusedin truthdata.Ourinitialobservationregardingthesimilarityofthe thisdatasetwerethesyntheticallygeneratedSARD[12],redis[11], changesinrepeatedIBUvulnerabilitiesascomparedtoMBUvul- andlua[7].Thevulnerabilitiesofthelasttwosystemswereob- nerabilitiesgaveusanidea.Wecheckedtoseeifusingasimple tainedthroughpatches,butthedatasetdidnothaveinformation similaritythresholdwouldprovideuswithbetterresults,especially aboutthosepatches’metadata.WereachedouttoDeepWukong’s betterrecall.Tocalculatethesimilarity,wereusedC3’slongest authorsaswellforthisinformationbuttheyinformedustheyno commonsubsequence.Weempiricallysetaminimumsimilarity longerpossessit.OurattemptstotracetheavailablecodeinDeep- |
thresholdbetweencodechangesbelongingtodifferentbaseunits Wukong’sdatasettocertaincommitsintherepositoriesoftheir inacompoundpatchto70%.We(1)checkedpairwisesimilarities subjectsystemsalsofailed:thecodeinthedatasetisamodified betweenallcodechangesperbaseunitinapatch,(2)obtained versionoftheoriginalcodeandcannotbetraced.Becauseofthis, theminimumoutofallthesimilarities,and(3)iftheminimum wecouldnotrunouroriginalcheckforrepeatedIBUvulnerabilities passed our threshold we concluded the vulnerability the patch inDeepWukong’sdataset.Therewasstillananalysiswecouldper- fixedwasrepeatedIBU;otherwise,thevulnerabilitywasdeemed formwiththedatawehad,however:ifweassumethatalltestcases tobeMBU.Thesimilarity-basedapproachresultedinaprecision thatgeneratemultipleslicespervulnerabilityareinfactMBUs,this of83%,perfectrecall,andoverallaccuracyof85%.Sincethepre- wouldgiveustheupperboundofDeepWukong’saccuracy.Weran cisionremainedalmostunchanged,andtherecallandaccuracy ouranalysiswiththisassumption. wentup,thesimilarity-basedapproachwassuperiortothemore Finally, LineVul uses the BigVul [20] dataset for its training convolutedclustering-basedapproach.However,sincewederived andevaluation.TheauthorsreportLineVul’sperformanceonboth theminimumsimilaritythresholdfromthesamedataweusedfor detectingvulnerablefunctionsandlocalizingvulnerablelines.We theaccuracycalculation,toensurewewerenotoverfitting,we checkedtheBigVuldatasetforMBUvulnerabilitiesusingboththese ranoursimilarity-basedapproachinanotherverificationdataset. baseunits(functionsandlines). Thisverificationdatasetcomprised67patchesfromChromium, UsingthesethreedatasetsandtherespectiveDL-basedapproaches, Android,php,Linuxkernel,Qemu,andFFMPEG.Anexperienced inourstudy,wefocusedonfourresearchquestions.First,welooked researcher manually verified the results of the similarity-based into (1) quantifying the presence of MBU vulnerabilities in the approach.Wemakethemanuallyobtainedverificationdatasetpub- datasets,and(2)establishinghowthethreeapproachesuseMBU liclyavailableonourwebsite[1].Theprecisionandrecallinthe vulnerabilitiesintheirtraining,validation,andtestingsets,and verificationdatasetwereboth95%.Thisincreasedourconfidence howtheMBUvulnerabilitiesareincludedinthereportedaccura- thatthesimilarity-basedapproachcanbeusedtocorrectlyand cies.Then,becauseourresultsrevealedMBUvulnerabilitiesare accuratelydistinguishcompoundpatches. notproperlyincludedintrainingandevaluation,wealsolooked into(3)obtainingtheaccuraciesofthethreedetectorsoncom- pletevulnerabilities,asopposedtoindividualbaseunits,andfinally (4)measuringtheimpacttrainingandevaluatingwithcomplete vulnerabilitiesinmindwouldhaveontheaccuraciesofthethree 4 FINDINGS detectors. Notethatwhileall threeofthedatasets alsocontain WithanapproachthathelpedusidentifyMBUvulnerabilities,we non-vulnerablesamples,e.g.,baseunits,orevenentirepatches, settoanswerourfourresearchquestionsusingthethreeDL-based thatweredeemedtonotfixvulnerabilities,wefocusedmostofour detectors.Thesedetectors’datasetshaddifferentparticularsthat analysesonlyonthosethatwerelabeledasvulnerable.Intotal,we neededtobeconsidered.Wewillbrieflygoovertheseparticulars beforeweexplaintheanalysesweconductedaspartofourstudy.ICSE2024,April14–20,2024,Lisbon,Portugal AdrianaSejfia,SatyakiDas,SaadShafiq,andNenadMedvidović analyzed1,587vulnerabilitiesusedinReVeal,3,662usedinDeep- Wukong,and2,078usedinLineVul.Next,wediscusstheresults weobtainedfromthisstudythroughthefourresearchquestions. 4.2 RQ1:PresenceofMBUvulnerabilities WepresentanddiscussourresultsonthepresenceofMBUvulner- abilitiesacrossthethreedatasets. 1)ReVeal:ThevulnerablefunctionsintheReVealdatasetwere obtained from 6,195 vulnerability-fixing patches. 1,587 of these patcheswerecompound,whichinthecaseofReVealmeansthey changedmorethanonefunction.Outofthecompoundpatches,our automatedapproachfound210wererepeatedIBUvulnerabilities, meaningthattheremaining1,377or22%ofthevulnerabilitieswere MBUs.55%oftheoverallvulnerablefunctionsintheReVealdataset camefromtheMBUvulnerabilities.Wepresentthedistribution Figure3:VulnerabilitiesintheDeepWukongdataset,grouped ofthenumberoffunctionsinalloftheReVealvulnerabilitiesin bytheirnumberofslices Figure2. vulnerablefunctionsintheseMBUvulnerabilitiesaccountedfor 2)DeepWukong:53%ofthe6,911vulnerabilitiesinDeepWukong 75%ofallthevulnerablefunctionsinthedataset.Thedistribution spanmorethanonePDGsliceandthusareMBUvulnerabilities. offunctionspervulnerabilityintheLineVulndatasetcanbefound TheslicesobtainedfromtheMBUvulnerabilitiesaccountfor77% inFigure5. oftheoverallvulnerableslicesinthisdataset.Thedistributionof TheseresultsrevealedthatMBUvulnerabilitiesdoformpart slicesacrossallthevulnerabilitiesinDeepWukongcanbeseenin ofthedatasetsoftheseDL-baseddetectorsandtheirbaseunits Figure3. contributeasignificantchunkoftheoverallvulnerablebaseunits. |
3)LineVul:WepresenttwodifferentviewsoftheLineVuldataset: ThisfurtherreinforcedourargumentthatMBUvulnerabilitiesneed separatedbasedonlinesandbasedonfunctions.Whenlookingat tobetakenintoaccountwhentrainingandtestingthesemodels. lines,outofatotalof3,286vulnerabilities,2,078camefromline- basedcompoundpatches.Ourautomatedapproachfoundthat63 4.3 RQ2:UsageofMBUvulnerabilitiesin ofthosepatcheswereactuallyfixingrepeatedIBUvulnerabilities. trainingandevaluation Intotal,outofallthevulnerabilitiesinLineVul’sdataset,2,015or 61%wereline-basedMBUvulnerabilities.Thevulnerablelinesin KnowingthatMBUvulnerabilitiescontributesignificantlytothe theseMBUvulnerabilitiesaccountedfor96%ofallthevulnerable datasetsofourthreesubjectDL-basedvulnerabilitydetectors,next, linesintheLineVuldataset.Wepresentthedistributionofthelines wesetouttounderstandhowaretheyusedinlearning(training) pervulnerabilityinFigure4. andevaluation(validation,testing,andaccuracyreports).Todoso, Intermsoffunctions,theLineVuldatasetcontained1,401function- welookedatboththeunderlyingapproachesaswellastheactual basedcompoundpatchesthatfixedvulnerabilities,outofwhich open-sourceimplementationsofthethreedetectors. 189wereautomaticallyfoundtoberepeatedIBUvulnerabilities. Throughthispartofthestudy,weaimedtoascertainwhether RemovingtheserepeatedIBUvulnerabilitiesfromthecompound thedetectorsensuredthat(1)everyvulnerability,alongwithallits patchesrevealedthat1212or37%ofthevulnerabilitiesintheLine- Vuldatasetwereactuallyfunction-basedMBUvulnerabilities.The Figure2:VulnerabilitiesintheReVealdataset,groupedby Figure4:VulnerabilitiesintheLineVuldataset,groupedby theirnumberoffunctions theirnumberoflinesTowardImprovedDeepLearning-basedVulnerabilityDetection ICSE2024,April14–20,2024,Lisbon,Portugal whenavalidationsetisused,eveninvalidation.Infact,across allthreeapproaches,wefoundanoverlapbetweenthetrainand testsets.ReVealdoesnothaveafixedtrainingandtestingset,so weusedtheircodetogeneratetrainandtestsetsformodels.We followedtheirdefaultconfigurationfortrainandtestseparation across30runs.Inthose30runs,wesawthataround95%ofthe MBUvulnerabilitieshadbaseunitsinbothtrainingandtestingsets. InDeepWukong,22%oftheMBUvulnerabilitieshadtheirbase unitsbrokendownalongthetraining,testing,andvalidationsets. Lastly,36%ofLineVul’sMBUvulnerabilitieswereincludedinthe training,testing,andvalidationsetssimultaneously.Thissuggests thatthesemodelsarenottrained,validated,andtestedinarealistic way[24].Weexplorefurthertheeffectsoflearningandevaluating thethreedetectorsinthisforminSection4.5. Second,wefocusedonhowthethreedetectorsincludeMBU vulnerabilitiesintheiraccuracyreports,whicharepartoftheireval- Figure5:VulnerabilitiesintheLineVuldataset,groupedby uation.Properreportingofaccuraciesforvulnerabilitydetectionis theirnumberoffunctions crucialbecauseitillustrateshowusefulthesedetectorscanbein therealworld.AccuracyreportswhereanMBUvulnerability’sbase unitsarenotlookedatcomprehensivelyandintotalaremisguiding. baseunits,isalwaysusedeitherfortrainingortesting(orvalidation, Whendeveloperstackleavulnerability,theyneedtoknowallofthe whenapplicable),exclusively,and(2)whenreportingaccuracies, comprisingpartsofthevulnerability;thisistrueforbothMBUand allofthebaseunitsofMBUvulnerabilitieswereaccountedfor. IBUvulnerabilities.Approachesandimplementationsthatclaim First,weexploredthestrategiesthedetectorsusedtoassign tohelpdevelopersfindvulnerabilitiesneedtoensurethattheir each sample in their datasets into the traditional data splits as- accuracycalculationsreflecthowwelltheseapproachescanfind sociated with DL. Using MBU vulnerabilities either in training, allofthevulnerablecodelocations. validation,ortesting,exclusively,isimportanttofollowarealistic Wefoundthatallofthedetectorsfailtoproperlytakeintoac- learningandevaluationscenario.Thedatasetsofthethreedetec- countMBUvulnerabilitiesintheiraccuracyreports:theMBUvul- torswereobtainedthroughpubliclyavailableinformation.Various nerabilitiesarebrokendownintotheircomprisingbaseunitsand systemsreporttheirvulnerabilitieseitherthroughtheNational thereportedaccuraciesareperbaseunit.Thisstandsincontrastto VulnerabilityDatabase(NVD)ortheirownwebsites.WhenMBU theclaimsinallofthethreepapersthattheproposedapproaches vulnerabilitiesarereported,alloftheircomprisingbaseunitsare “detectvulnerabilities,”andnotjusttheirbaseunits.Forinstance, partofthesamereportsimultaneously.Thepurposeofsplittingthe theauthorsofReVealclaimthatReVeal“canfindalargernumber dataintotraining,validation,andtestingistosimulateascenarioin oftrue-positivevulnerabilities,”wheninrealitytheyreportaccura- whichthelabelsofthesamplesintrainingareknownbeforehand ciesonvulnerablefunctionsandnotcompletevulnerabilities[14]. (historicaldata),whereasthoseofsamplesinvalidationandtesting DeepWukong’sfirstresearchquestionreads“CanDeepWukongac- |
areunknown.ToensurethattheDLmodelthatistrained,validated, curatelydetectvulnerabilities?”butintheiranswer,theauthorssay andtestedonthatdataisrealisticitisnecessarytoensurethatthe theylookedatindividualslices,notcompletevulnerabilities[15]. assumptionofwhichlabelsareknownandwhichareunknownat LineVul’sfirstresearchquestionissimilar:theauthorsaskhow trainingtimeisalsorealistic.Usingapartofthesamevulnerability accurateLineVulison“function-levelvulnerabilitypredictions.” fortrainingandanotherpartfortesting,forexample,doesnotsim- However,laterinthepaper,theytalkaboutpredictingonlyvulner- ulatearealisticscenario,maytainttheresults,andthusmaylead ablefunctionsandnotallofavulnerability[21].Itisimportantfor toincorrectconclusions.Theimportanceofsimulatingarealistic theseandotherdetectorstoproperlyincludeMBUvulnerabilities scenarioinDLapplicationshasbeenbroughtupinpreviouswork, intheiraccuracycalculations. whereitwasreferredtoasthe“realisticlabelingassumption”[24]. Intheirpaper,Jimenezetal.discusstheimportanceoftakinginto 4.4 RQ3:ActualaccuraciesonMBU accounttemporalconstraintswhenusingvulnerabilitydatafor trainingandtesting[24].BreakingdownMBUvulnerabilitiesinto vulnerabilities theirbaseunitsandusingthemacrosstraining,validation,and Aftertheresultsfromtheprevioussection,wesetouttounderstand testingalsoviolatestheseconstraints:itisincorrecttoassumeyou how the detectors’ overall accuracy metrics are adjusted when know the labels of some of the base units involved in an MBU takingintoaccountcompletevulnerabilitiesandalsospecifically vulnerability(i.e.,theonesthatareassignedtothetrainingset) howaccuratethedetectorsareonMBUvulnerabilities.Forthe andnotothers(i.e.,theonesthatareassignedtothevalidationor former,welookedattheprecision,TPR(equivalenttorecall),and testingsets)whentheyareallreportedandmadepubliclyavailable theMCCmetrics.Forthelatter,sincewewerespecificallyinterested atthesametime. inhowthesetoolsdetectvulnerabilities,i.e.,thepositiveclass,we Ourfindingsrevealthatacrossallthreedetectors,MBUvulnera- wantedtoisolatetheiraccuracyonlyonvulnerabilities.Thatis bilitiesarebrokendownacrosstrainingandtesting,andincases whywelookedattheTPRdifferencebetweenIBUsandMBUs.ICSE2024,April14–20,2024,Lisbon,Portugal AdrianaSejfia,SatyakiDas,SaadShafiq,andNenadMedvidović Before we present the results of the three detectors, we will ReVeal DWK LV brieflypresentthedataandthesettingsweused. Metric Setting Mean(SD) Med ReVealdidnothaveapubliclyavailablemodelatthetimeof Base 0.91(0.04) 0.91 (0.93) 0.87 ourstudy,soweretrainedtheirmodelwiththeirpubliclyavailable Adjusted 0.90(0.05) 0.89 (0.92) 0.84 TPR codeandwiththeportionofdataforwhichwecouldobtainthe IBU 0.92(0.04) 0.92 (0.92) 0.88 relevantmetadata(refertoSection4.1).Wefollowedtheirtrain,test, MBU 0.77(0.09) 0.76 (0.91) 0.62 anditerationconfigurations.ReVealbydefaultdoes30iterations. Base 0.49(0.01) 0.48 (0.94) 0.99 Prec DeepWukongandLineVulreleasedtheirrespectivemodelsaswell Adjusted 0.41(0.01) 0.41 (0.94) 0.99 astheirfixedtestsets,sowewereabletousetheirtrainedmodels Base 0.13(0.04) 0.14 (0.92) 0.91 MCC ontheirtestsets. Adjusted 0.11(0.04) 0.11 (0.92) 0.90 Thecompositionoftherespectivetestsetsforthethreedetectors canbefoundinFigure6.ForReVealandDevign,wepresentthe Table1:TPR,Precision(Prec),andMCC,ofReVeal,Deep- averagesofthe35runssincewedidnotnoticealotofvariance: Wukong(DWK),andLineVul(LV)intheirtestsets,perbase around 1,729 vulnerabilities, out of which 811 are MBU. Deep- unit,i.e.,theiroriginalwayofmeasuringaccuracy(Base), Wukonghadaround1,000MBUvulnerabilitiesoutofthe3,000in pervulnerability(Adjusted),andTPRperIBUvulnerabilities itstestset,whereasLineVulhadonly128MBUvulnerabilitiesout (IBU)andperMBUvulnerabilities(MBU).ForReVeal,we ofapproximately2,700totalvulnerabilities. presentthemean,standarddeviation(SD),andmedian(Med) AfinalnoteonLineVul’stestset:LineVulassignsvulnerability forthe30runs. scorestolinesinfunctionsitidentifiesasvulnerable.Itthenreports theTop-10accuracyforlocalizingvulnerablelinesperfunction,i.e., table).Inthesamevein,afalsenegative isdefinedasthosevul- thepercentageoffunctionsforwhichatleastoneactualvulnerable nerabilitiesforwhichthedetectorfailstoidentifyallbaseunits lineisincludedinthetop10linesrankedbytheirvulnerability asvulnerable.Thedefinitionsoffalsepositiveandtruenegative score.Becauseofthescore,wewereunabletoobtainfine-grained remainunchanged. resultsaboutwhichspecificlinesLineVulpredictsasvulnerable; ForReVeal,foreachmetric,wereporttheaveragealongwith weneedthefine-grainedresultspereachlineforoursubsequent standarddeviation(columnMean(SD))andthemedianofthe30 |
analysisofaccuraciesoncompletevulnerabilities.Thelackoffine- iterations.Thecompleteresultsfromall30iterationscanbefound grainedresultsrenderedgettingtheaccuraciesfortheline-based onourwebsite[1]. settingofLineVulimpossible.Thus,wepresenttheresultsonlyat TheDeepWukongresultsarewithintheparenthesistoindicate thefunctionlevel. thefactthattheyareanupperboundsince,asexplainedabove,we Theoverviewoftheresultsfromthispartofourstudycanbe assumedtheirmulti-slicetestcasesperfectlycorrespondtoMBU foundinTable1.Foreachofthedetectors,wefirstcalculatedtheir vulnerabilities. accuracymetricspervulnerabilitybaseunit(theBaserows),as Inregardstothevulnerablesamples,someoftheresultscon- theydointheiroriginalapproachesandimplementations.Inthis firmedourexpectations.Allthreedetectorsover-reporttheirTPR, case,atruepositiveinstanceisanyvulnerablebaseunitcorrectly albeitDeepWukongandReVealdosobysmallmarginsonly.LineVul predicted,whereasafalsenegativeinstanceisanyvulnerablebase over-reportsthemby3percentagepoints.However,theTPRson unitlabeledasnon-vulnerable.Wethenadjusttheoriginalmetric MBUvulnerabilitiesdropsignificantlyby15-26percentagepoints. (resultspresentedintheAdjustedrows)byconsideringvulnera- SincethesedetectorsdonotaccountforMBUvulnerabilitieswhen bilities,i.e.,groupingallbaseunitsofanMBUvulnerability,and training,itisexpectedtoseethistypeofperformance. definingatruepositiveinstanceonlyifallofthebaseunitsofa WenoteDeepWukong’sveryhighaccuracyupperboundacross vulnerabilityhavebeencorrectlypredicted(rowAdjustedinthe theboard.Unfortunately,wedonothaveaccesstotherawdata usedintheirdatasetswhichlimitedourabilitytofurtherinspect theresults.DeepWukonghasthehighestpercentageofMBUvul- nerabilitiesinitsdataset,whichmayindicatethereisacorrelation betweenincludingahigherrateofMBUvulnerabilitiesandhigher TPRs.WhetherincludingmoreMBUvulnerabilitiesleadstobetter resultsmeritsfurtherexplorationandresearch.Weshouldnote thatinstudieswiththeothertwodatasets,DeepWukong’smodel wasnotabletoreplicatethesamelevelsofaccuracy;infact,the adjustedaccuracymetricsandtheTPRonMBUsfromthesestudies followthesametrendasthemetricsofReVealandLineVulseenin Table1. The results on the precision and MCC metric offer another perspectiveontheperformanceofthethreedetectors.ReVeal’s precisiondropsthemostwhenconsideringcompletevulnerabili- Figure6:VulnerabilitiesinthetestsetsofReVeal(averages ties.LineVul’smetricsdecreaseslightlywhenweuseouradjusted acrossthe30runs,acrosswhichtherewaslittlevariance), metrics.DeepWukong’supperboundsforthemetricsremainun- DeepWukong,andLineVul changedinthetworuns.TowardImprovedDeepLearning-basedVulnerabilityDetection ICSE2024,April14–20,2024,Lisbon,Portugal ReVeal trainingconstraint,webalancedthenumberofcompletevulnera- DWK LV Metric Setting Mean(SD) Med bilitiestonon-vulnerablesamples.Thismeantthatthenumberof Base 0.87(0.04) 0.87 (0.93) 0.91 vulnerablefunctionsinthetrainingsetwashigherthanintheorig- Adjusted 0.87(0.04) 0.88 (0.90) 0.86 inaltrainingofLineVul,whichcorrespondedtobetterperformance TPR IBU 0.91(0.03) 0.92 (0.89) 0.93 indetectingvulnerabilities,butworseperformanceindetecting MBU 0.66(0.08) 0.67 (0.91) 0.73 non-vulnerablesamples.Thetrade-offbetweenprecisionandrecall Base 0.51(0.03) 0.52 (0.97) 0.54 inmodelslikeLineVul’smeritsfurtherexploration.DeepWukong’s Prec Adjusted 0.40(0.03) 0.40 (0.93) 0.31 resultsshouldagainbeinterpretedasanupperboundonitsperfor- Base 0.08(0.04) 0.08 (0.94) 0.68 mance.Theydonotchangesignificantlyundertherealistictraining MCC Adjusted 0.11(0.04) 0.12 (0.91) 0.50 constraint. Table2:TPR,Precision(Prec),andMCC,ofReVeal,Deep- Wukong(DWK),andLineVul(LV)whentrained,validated 5 FRAMEWORK andtestedfocusingonvulnerabilities,perbaseunit,i.e.,their Wereleaseaframeworkconsistingofcomponentsweusedinthis originalwayofmeasuringaccuracy(Base),pervulnerability study.Weaimtofacilitatetheprocessofstudying,understanding, (Adjusted),andTPRperIBUvulnerabilities(IBU)andper anddetectingMBUvulnerabilities.Theframeworkcanbeused MBUvulnerabilities(MBU).ForReVeal,wepresentthemean, towardsimprovingthewayDL-baseddetectiontechniqueshandle standarddeviation(SD),andmedian(Med)forthe30runs. MBUvulnerabilities,butalsoforfurtherexplorationofdifferent aspectsofthecurrentDL-basedvulnerabilitydetectorsandtheir The difference in how the metrics change between the Base datasets.Anoverviewofourframework,itscomponents,andhow andAdjustedcasesillustratesthatthevulnerabilitydetectorshave itcanbeusedisdepictedinFigure7.Weexplainthecomponents differentstrengths.Includingallthemetricsintheaccuracyreports andtheusageweenvisionforourframeworknext. helpstheconsumersofthesedetectorstomakemoreinformed decisionsaboutwhentousethem. PatchCollectorobtainsvulnerabilitypatchesusedindatasets.It |
takesasinputvulnerabilitymetadata,i.e.,patchhashesandreposi- torynameswheresuchpatchescanbeobtainedaswellasthebase 4.5 RQ4:Trainingandevaluatingundera unitthevulnerabilitiesareexpressedin.Optionalmetadatathat realisticscenario canbeincludedaspartoftheinputisacountofthebaseunits.If OurRQ2alsorevealedthatthethreedetectorsdonottakeinto thisoptionalmetadataisgiven,thePatchCollectorobtainsonly accountcompletevulnerabilitieswhentraining,validating,and thecompoundpatchesdirectly.Otherwise,itfirstobtainsthecode testing,splittingthebaseunitsofthesamevulnerabilityacrossthe changesinthepatch,groupsthemperbaseunit,andthenconcludes threedifferentsets.Ourfinalresearchquestionexplorestheimpact whetherthepatchshouldbekept(ifitiscompound)forfurther ofthisontheaccuraciesofthethreedetectors.Wehypothesized analysis.PatchCollector,then,representsthechangesthathave thattheaccuraciesareover-reported. happenedinthepatchintheformofASTeditscripts,byusing Thisresearchquestionrequiredretrainingthethreedetectors. GumTree[19]. We followed the original approaches to retrain, revalidate, and WehavealsoaddedaPatchCleanercomponent.Asmentioned retestthedetectorsineverywaybutone:insteadoffocusingon above,previousresearchstudieshavecomplainedaboutthepres- baseunitswhensplittingthedata,wefocusedoncompletevul- enceofnoiseinvulnerabilities[14,36]. Atthesametime,some nerabilities.WepresenttheresultsofthisexperimentinTable2. Theseresultspointedtointerestingunder- lyingphenomena,attimesconfirmingandat othersrejectingourhypothesis.Tomakesense oftheseresults,wecomparethemtothosepre- sentedinTable1,depictingtheoriginalresults forthethreedetectors.ReVeal’sperformance acrossmostmetrics(withtheexceptionofpre- cision)sufferswhentrainedandtestedrealis- tically.Thismatchesourexpectationsandhy- pothesis.However,LineVul’sperformanceon theTPRmetricsmostlyimprovesunderreal- istic training! On the other hand, its perfor- mance on precision and MCC drops signifi- cantly.Oneexplanationforthecontradicting changes in LineVul’s metrics is that LineVul balancesitstrainingset:originally,therewere as many vulnerable functions as there were Figure7:FrameworkfordetectingandunderstandingMBUvulnerabilities non-vulnerablefunctions.UndertherealisticICSE2024,April14–20,2024,Lisbon,Portugal AdrianaSejfia,SatyakiDas,SaadShafiq,andNenadMedvidović studiesshowhowtodetectpartofthatnoise[25,36].Tofacili- dependencies,maybemorechallengingfordeveloperstofindon tatetheprocessofremovingnoise,wehaveincludedtheCasCADe theirown,evenmoresothanIBUones. technique[36],arule-basednoise-detectiontechnique,inourPatch Further,otherresearcherscanreuseourframeworktoanalyze Cleanercomponent. otherDL-basedvulnerabilitydetectors.Detectingvulnerabilities WedidnotoriginallyincludethePatchCleanerinourstudypre- usingDL-basedsolutionsseemstobeagrowingfield.Butatthe sentedinSection4becausePatchCleanerwouldaltertheground sametime,itisimportanttoverifythesesolutionsareusefulforreal- truth.IfthePatchCleanerfoundnoiseinthedata,wewouldhave worldscenarios.Ourframeworkhelpswiththat.Otherresearchers removedthatnoise;thegroundtruthcollectedbythedetectors can also expand our framework. One important way in which wouldhavechanged,whichwouldnotresultinanaccuratecompar- that can be done is through expanding the types of base units isonbetweenthereportedaccuracymetricsintheoriginalpapers weconsider.Vulnerabilitydetectiontools,forinstance,attimes andtheaccuracymetricsweobtained.Todemonstratetheusageof focusoncoarser-grainedcomponents;inthefuture,othertypes thePatchCleanerwedid,however,runanexperimentonaportion ofrepresentations(i.e.,data-flowonly,AST-based,orspecificcode ofthedatausedbyReVeal,around1000compoundvulnerability- regions not bound within the current base units) may become fixingpatches.SinceReVealusesfunctionsasthebaseunit,using prevalent.Supportingavarietyoftypesofbaseunitshelpsfacilitate CasCADe,weidentifiedfunctionsthatcontainedonlyAPI-based the processof verifyingthe resultsand usefulnessof DL-based casualtychangesorlogic-preservingchangesthathappeninside approaches. functionsbecauseofchangestoAPIs.Thesechangesareconsidered asnotpertainingtothevulnerability,thusthefunctionsthatsolely 6 RELATEDWORK containthemshouldnotbeconsideredvulnerable.Wefound25 DL-baseddetectorsarethemainsubjectofthisstudy.Thethree functions,spreadaround35patches,hadsolelycasualtychanges. detectorswechosetoanalyzerepresentexamplesofprominentvul- Thelowoccurrenceofcasualtychangeswasexpectedinthiscase nerabilitydetectionapproaches.OthersincludeDevign,afunction- becausethedatasetwasmanuallylabeled[42]andthuslesslikely levelDL-basedvulnerabilitydetector[42].TheportionoftheReVeal tocontainnoise. datasetweusedinthisstudyoriginallycamefromtheauthorsof OurPatchCleaner,followingCasCADe’sinitialapproach,isrule- Devign.VulDeePecker[30]andSysevr[29]proposeacombination basedandthuscanbeextended.Newrulesortechniquesonhow ofslice-baseddetectionofvulnerabilities.Finally,LineVDdetects |
todetectnoisecanbeaddedtoit.Theywouldrequireaone-off vulnerabilitiesatthelinelevel[23].TheseDL-basedstudieshave integrationwiththerestoftheframework. beenenabledbyvulnerabilitydatacollectioneffortssuchasthe MBUVulnerabilityIdentifiertakestheAST-representedpatches workofFanetal.[20],whichwasusedbyLineVulandmanyother asinputandidentifieswhichonesareMBUvulnerabilities.Itfol- researchstudies. lowsthesimilarity-basedapproachintroducedinSection3,which Whilepattern-baseddetectorsarebeingoutnumberedbyDL- formedpartofC3’sapproach[26].TheIdentifiercanbeconfigured basedones,initialstudiesonhowtobestrepresentcodeforvul- tolookforchangesbasedonthevariousbaseunits.Further,follow- nerabilitiesusedpatterns[40]andhaveinspiredbetterrepresenta- ingC3’soriginalapproachitencodestheAST-basededitscripts tionsforcodeevenintechniquesusedtoday.Whileinthisstudy forfasterprocessing.Thiscomponentusesthelongest-common- welookedatspecificallyDL-baseddetectors,theconceptofMBU subsequencemethodtocalculatethesimilarity. vulnerabilityappliestootherdetectorsaswell.Wecantestpattern- Finally,usingtheidentifiedMBUvulnerabilitiesandrawpre- baseddetectorsonhowwelltheydetectMBUvulnerabilities. dictions,theAccuracyCalculator providesaccuracymetricsper TheaccuracyoftheDLandotherdata-baseddetectorshasbeen vulnerability.Themetricscanbefurtherexpanded. demonstratedtovaryquitealotwhenthedatachanges[14,24].We Weenvisionourframeworktobeusedintandemwiththedevel- havealsonoticedthisinourownexperiments.Becauseofthis,the opmentofnewDL-basedvulnerabilitydetectorsandperhapseven qualityofthedataincludedinvulnerabilitydatasetshasbeenthe toimproveexistingones.Forinstance,theoutputofourMBUVul- subjectofpreviousresearch[16].Securitydataqualitytranscends nerabilityIdentifiercanbeusedearlyinthedatacollectionstageto vulnerability detection: security bug report prediction has also ensurethatenoughMBUvulnerabilitiesarepresentinthedataset. gainedtractionanddataqualitymattersforthistypeofinsight Further,theoutputofthiscomponentshouldbetightlycoupled too[39,41].Ourstudy,inaway,alsospeakstotheunderlying withtheselectionoftrainingandtestingsets.Aswefoundout, qualityofthedatausedinvulnerabilitydetection:weexploreif DL-baseddetectorsdonotcurrentlyensureMBUvulnerabilitiesare thedatasetscontainMBUvulnerabilities.Inaddition,wepresenta usedexclusivelyeitherfortrainingortesting.Withourframework, newwaytoapproachdatasetsthatcontainthem. theycanobtaininformationthathelpsthemrealisticallysettheir Croftetal.intheirworkcompiletheprocessesofdataprepa- trainingandtestingprocesses.Inaddition,withthehelpofPatch rationforvulnerabilitydetection[18].Infact,theydorefertothe Cleaner,DL-baseddetectorscanbemoreconfidentinthequalityof usageofbaseunitsandhowthatconstrainsvulnerabilitydetec- theirdata.Finally,wearguethatDL-baseddetectorsshouldreport tionapproaches,thoughtheydonotrefertoabaseunitbythat ourAccuracyCalculatormetrics.Itiscrucialtoshowaccuracymet- name.Withtheboomofdata-drivenvulnerabilitydetection,un- ricspervulnerabilitytomorerealisticallyrepresenttheusefulness derstandingvulnerabilitydatasetshasalsobecomeimportant[28]. ofthesedetectors.Butitisalsoimportanttospecificallyreport Ourstudyalsoprovidesadeeperunderstandingofvulnerability accuracymetricsforMBUvulnerabilities.Thesevulnerabilities,pre- databasesthroughanalyzingtheirinclusionofMBUvulnerabilities. ciselybecausetheyspanmultiplecodelocationsthathaveintricate Otheraspectsofvulnerabilitydatasetshavealsobeenstudied. Forinstance,Leetal.checkhowvulnerabilitydatacanbeusedtoTowardImprovedDeepLearning-basedVulnerabilityDetection ICSE2024,April14–20,2024,Lisbon,Portugal prioritizevulnerabilities[27].Properprioritizationofvulnerabil- Further,allthevulnerabilitiesweanalyzedexistincodewritten itieshasalsobeenstudiedbylookingattheinconsistenciesthat inC/C++.Furtherstudiesareneededtoanalyzethepresenceof canexistinvulnerabilityseverityscores[17].Theauthorsclaim MBUvulnerabilitiesinotherprogramminglanguages.Weexpect thatseverityscoresarenotproperlyconsideredwhenreporting ourstudytofacilitatethisexplorationsincetheconceptsusedin vulnerabilities,affectingdownstreamtasks.Whileprioritization thepaperarenotlimitedtoanyprogramminglanguage.Ourpro- wasnotthemainintentionbehindourwork,ouranalysisofthe posedframework,whichcanbedirectlyusedinsuchexploration, datacanbeusedtocategorizevulnerabilitiesandprioritizethem. islanguageagnosticaswell. Forinstance,detectorsmayrankMBUvulnerabilitieshigherthan 3)ConstructValidity:Accuratedistinguishingofcompoundpatches IBUones. isnecessarytomitigateconstructvaliditythreats.Wehavebased Lookingathowvulnerabilitydetectorsperforminrealisticsce- bothourdefinitionandautomatedapproachonreal-worldpatches narioshasbeenthefocusoftheworkbyJimenezetal.[24].ReVeal, andreal-worldvulnerabilities.Ourapproachhasbeenshownto besidesthedetectionplatformitprovides,alsostudiesotherDL- beeffectiveandwemaketheresultspubliclyavailable,inorderto |
baseddetectorsinrealisticscenarios[14].Ourworkinidentifying enablefurtherinspection. MBUvulnerabilitiescomplementstheseexistingefforts. Finally,wemadeuseofclusteringcodechangesinourwork. OurapproachwasamodificationofC3’sapproach[26].Others 8 CONCLUSIONANDFUTUREWORK havelookedathowtominepatternsfromchanges[32].Tothe Inthisstudy,weintroducetheconceptofMBUvulnerabilities.Our bestofourknowledge,wearethefirsttoapplycodeclusteringto studyofthreeprominentDL-baseddetectors,ReVeal,DeepWukong, distinguishIBUfromMBUvulnerabilities. andLineVul,suggeststhatcurrentlythesedetectorsarenottrained andtestedinarealisticfashion,andfurther,theydonotreport accuraciesoncompletevulnerabilities,failingtoincludeallcom- 7 LIMITATIONSANDTHREATSTOVALIDITY ponentsofMBUvulnerabilities.Ourgoalthroughthisstudywas Partsofourworkreliedonmanualstepsandthird-partytools, toestablishthepracticesoftheseDL-detectorsinincludingMBU bothofwhichcouldintroduceerrorsinourstudyandthreatenits vulnerabilitiesacrosstheirlearningandevaluationprocessaswell validity.Wediscussthestepswetooktomitigatethesepotential astheirabilitiestoproperlydetectsuchvulnerabilities. errors. OurstudyindicatesthatexistingDL-baseddetectorsdonotwork 1)InternalValidity: Wemanuallycollectedtwogroundtruth aswellindetectingallcomprisingpartsofMBUs.Thismatched datasetsinthisstudytodeterminetheaccuracyofourMBUVul- ourexpectationsastheseDL-baseddetectorsdonotseemtowork nerabilityIdentifier.Themanualcollectionofthedataexposedus wellindatatheyarenottrainedon.Thisperformanceshedslight topotentialbiasesbeingintroduced.However,tomitigatebiases ontheeffectivenessofthesedetectorsfordetectingvulnerabilities anderrors,theoriginalgroundtruthdatasetinvolvedthreeexperts asawhole,especiallywhenthesevulnerabilitiesareMBUs. withseveralyearsofexperience.Onepersonworkedonthemanual ThemessageofthisstudyforresearchersofDL-basedvulnerabil- taggingoftheverificationdatasetbutwereleaseboththeground itiesisto(1)changehowtrainingandtestingaredonesothatthese truthdatasetspubliclysothattheresearchcommunitycanverify processescanbetterreflectarealisticscenarioand(2)includeallof ourclaimsaswell. thecomprisingpartsofavulnerabilityintheiraccuracymetrics. Werelyonseveralthird-partytoolsforourcollectionandanaly- Wehavegroupedcomponentsfromourstudyintoaframework sisofdata.Forinstance,weuseGumTreeforAST-basededitscript thathelpstothatend. generationandweareboundbyitslimitations.Whenpossible,we Ourfutureplansinthisareaaretwo-fold.First,weaimtofurther haveattemptedtoboostitsaccuracybyimprovingthealignment investigatethenatureofMBUvulnerabilities.Weaimtoestablish ofthetrees.WeuseLLVM[6]inthePatchCleanerandarebound why certain vulnerabilities are spread along multiple locations bythelimitationsofstaticanalysis. andwhethersuchvulnerabilitiessharesomecharacteristics.Our 2)ExternalValidity:Ourusageofthethreeparticulardatasets intuitionisthatcharacteristicssuchastheirseverityorrootcause andthreedetectorsisanexternalvaliditythreat.Wefocusonthree mayimpactthespreadofMBUvulnerabilitiesalongtheirbaseunits. DL-baseddetectorsandtheirdatasetinthisstudy.Thegeneral- Second,weplantofurtherinspectthecorrelationbetweenthemere izabilityofourconclusionsbecauseofthisisalsoathreattoour presenceofMBUvulnerabilitiesinthetrainingsetandimproved study’svalidity.Tomitigatethisthreat,wepickeddetectorswith vulnerabilitydetection.Ourgoalistoconductasystematicstudy differentbaseunits,illustratingtheadaptabilityoftheconceptof toproperlyestablishthefactorsthatimpacttheperformanceofthe MBUvulnerabilities. detectorsonMBUvulnerabilities. We aimed to reproduce the results of the three detectors as faithfullyaspossible,toensurewecanproperlyillustratetheirper- formanceontheMBUvulnerabilitiesdefinedintheirowndatasets. However,wewerealsounabletoobtainpartofthedatausedin ACKNOWLEDGMENTS ReVealandDeepWukongduetothelackofmetadata.Moreover, ThisworkissupportedbyaGooglePhDFellowship,theDepart- ourusageofthesethreedetectorsrendersthestudysubjecttothe mentofHomelandSecurityunderawardnumber70RCSA22C00000008, limitationsandbiasesofthedetectors.Itshouldbenoted,though, subawardnumberA2774-03,theNationalScienceFoundationun- thatourpurposewastorealisticallyestablishthesedetectors’per- derawardnumber182335,andtheAustrianScienceFundunder formance,andtheirlimitationsandbiasesimpactthatperformance. grantnumberFWFP31989-N31.ICSE2024,April14–20,2024,Lisbon,Portugal AdrianaSejfia,SatyakiDas,SaadShafiq,andNenadMedvidović REFERENCES Engineering.351–360. [1] [n.d.].AnonymousProjectWebsite. https://anonymousseres.github.io/icse/ [26] PatrickKreutzer,GeorgDotzler,MatthiasRing,BjoernMEskofier,andMichael [2] [n.d.].CVE-2014-3647. https://nvd.nist.gov/vuln/detail/CVE-2014-3647 Philippsen.2016. Automaticclusteringofcodechanges.InProceedingsofthe [3] [n.d.].CVE-2017-0596. https://nvd.nist.gov/vuln/detail/CVE-2017-0596 13thInternationalConferenceonMiningSoftwareRepositories.61–72. |
[4] [n.d.].CVE-2021-33815. https://nvd.nist.gov/vuln/detail/CVE-2021-33815 [27] TrietHMLe,HuamingChen,andMAliBabar.2022.Asurveyondata-driven [5] [n.d.].FFmpeg’sWebsite. https://ffmpeg.org/ softwarevulnerabilityassessmentandprioritization.Comput.Surveys55,5(2022), [6] [n.d.].LLVM. https://llvm.org/ 1–39. [7] [n.d.].Lua’Website. https://www.lua.org/ [28] XiaozhouLi,SergioMoreschini,ZheyingZhang,FabioPalomba,andDavide [8] [n.d.].PartialfixofCVE-2014-3647. https://github.com/torvalds/linux/commit/ Taibi.2023. Theanatomyofavulnerabilitydatabase:Asystematicmapping 234f3ce485d54017f15cf5e0699cff4100121601 study.JournalofSystemsandSoftware(2023),111679. [9] [n.d.].PartialfixofCVE-2014-3647. https://github.com/torvalds/linux/commit/ [29] ZhenLi,DeqingZou,ShouhuaiXu,HaiJin,YaweiZhu,andZhaoxuanChen.2021. d1442d85cc30ea75f7d399474ca738e0bc96f715 Sysevr:Aframeworkforusingdeeplearningtodetectsoftwarevulnerabilities. [10] [n.d.].QEMU’sWebsite. https://www.qemu.org/ IEEETransactionsonDependableandSecureComputing19,4(2021),2244–2258. [11] [n.d.].Redis’Website. https://redis.io/ [30] ZhenLi,DeqingZou,ShouhuaiXu,XinyuOu,HaiJin,SujuanWang,Zhijun [12] [n.d.].SARD’sWebsite. https://samate.nist.gov/SARD/ Deng,andYuyiZhong.2018.Vuldeepecker:Adeeplearning-basedsystemfor [13] NavneetBhatt,AdarshAnand,VenkataSSarmaYadavalli,andVijayKumar.2017. vulnerabilitydetection.arXivpreprintarXiv:1801.01681(2018). Modelingandcharacterizingsoftwarevulnerabilities.(2017). [31] BingchangLiu,LiangShi,ZhuhuaCai,andMinLi.2012.Softwarevulnerabil- [14] SaikatChakraborty,RahulKrishna,YangruiboDing,andBaishakhiRay.2021. itydiscoverytechniques:Asurvey.In2012fourthinternationalconferenceon Deeplearningbasedvulnerabilitydetection:Arewethereyet.IEEETransactions [32] m Mu atlt iaim sMed aia rti innf eo zr ,m Laa uti ro en ncn eet Dw uo cr hk ii en ng ,a an nd ds Mec au rr ti it ny M.IE onE pE e, r1 r5 u2 s– .21 05 16 3. .Automatically [15] o Xn iaS oo Cft hw ea nr ge ,E Hn ag oin ye ue Wrin ag ng(2 ,J0 i2 a1 y) i. Hua,GuoaiXu,andYuleiSui.2021.Deepwukong: extractinginstancesofcodechangepatternswithastanalysis.In2013IEEE Staticallydetectingsoftwarevulnerabilitiesusingdeepgraphneuralnetwork. internationalconferenceonsoftwaremaintenance.IEEE,388–391. [33] NamHPham,TungThanhNguyen,HoanAnhNguyen,andTienNNguyen.2010. 1A –C 3M 3.TransactionsonSoftwareEngineeringandMethodology(TOSEM)30,3(2021), Detectionofrecurringsoftwarevulnerabilities.InProceedingsoftheIEEE/ACM [16] RolandCroft,MAliBabar,andMehdiKholoosi.2023.DataQualityforSoftware internationalconferenceonAutomatedsoftwareengineering.447–456. [34] FrankPiessens.2002.Ataxonomyofcausesofsoftwarevulnerabilitiesininternet [17] V Rou ll an ne dra Cbi rl oit fy t,D Mat Aas lie Bts a. ba ar rX ,i av np dr Lep ir Li in .t 2a 0r 2X 2i .v A:2 n30 i1 n. v05 e4 st5 i6 ga(2 ti0 o2 n3) i. ntoinconsistency software.InSupplementaryProceedingsofthe13thInternationalSymposiumon ofsoftwarevulnerabilityseverityacrossdatasources.In2022IEEEInternational [35] S Joo aft nw na are CR .e Sli .a Sb ail nit ty osE ,n Ag nin te he or nin yg. PC erit ue mse ae ,r, M47 eh– d52 i. Mirakhorli,MatthiasGalstery, ConferenceonSoftwareAnalysis,EvolutionandReengineering(SANER).IEEE, JairoVelozVidal,andAdrianaSejfia.2017. UnderstandingSoftwareVulner- 338–348. abilitiesRelatedtoArchitecturalSecurityTactics:AnEmpiricalInvestigation [18] RolandCroft,YongzhengXie,andMuhammadAliBabar.2022. Dataprepara- t Ti ro an nsfo ar cts ioo nft sw oa nre Sov fu twln ae rr ea Eb nil git iy nep er re ind gic (t 2io 0n 22: )A . systematicliteraturereview.IEEE [36] o S Aof dfC rtw ih aar no r aem SAi eu r jcm fih ai, ,tP e YcH it xuP urea en ( ZId C hT S aA oh ,)u . an 6 nd 9 de –r N7b 8 ei .r nd ah. dtI tn Mps2 e:0 / d1 / vd7 io dI iE . ooE vrE ig ć/I .1n 20t 0e .1 2r 1n 10 .a 9t Ii / do I eCn na S tAl ifC . y2o i0 nn 1 gf 7e . cr 3e a9n suce alo tn y [19] Jean-RémyFalleri,FloréalMorandat,XavierBlanc,MatiasMartinez,andMartin Monperrus.2014. Fine-grainedandaccuratesourcecodedifferencing.InPro- changesinsoftwarepatches.InProceedingsofthe29thACMJointMeetingon EuropeanSoftwareEngineeringConferenceandSymposiumontheFoundationsof c ee ne gd inin eg ers inof g.th 3e 132 –9 3th 24A .CM/IEEEinternationalconferenceonAutomatedsoftware [37] S Yo of ntw gha ere eE Sn hg inin ,e Aer ni dn rg e. w30 M4– e3 n1 e5 e. ly,LaurieWilliams,andJasonAOsborne.2010. |
[20] JiahaoFan,YiLi,ShaohuaWang,andTienNNguyen.2020. AC/C++code Evaluatingcomplexity,codechurn,anddeveloperactivitymetricsasindicators v thu eln 1e 7r ta hb Ii nli tt ey rnd aa tt ia os ne at lw Ci ot nh fec ro ed ne cech onan Mg ie ns inan gd SoC ftV wE as reum Rem poa sr ii te os r. ieIn s.P 5r 0o 8c –e 5e 1d 2in .gsof 7o 7f 2s –o 7ft 8w 7a .revulnerabilities.IEEEtransactionsonsoftwareengineering37,6(2010), [21] MichaelFuandChakkritTantithamthavorn.2022.LineVul:atransformer-based [38] AjaySSinghandMicahBMasuku.2014.Samplingtechniques&determination [22] l e Bi nn ece re n-l o de nv Ge Ml rov in bu i al nn uge er S ra ,ob Tfi t ol wi bt ay iarp e sr R We ed p aic o llt s oi io t son cr h. iI e en s k. ,P 6 ar 0o n8c d–ee 6 Ed 2 li 0 mn .g as ro Sf tt oh ce k1 e9 r.th 20In 1t 1e .rn Ua nti do en ra sl taC no dn if ner g- o off es ca om np omle is ci sz ,e coin ma mp ep rl ci eed anst da mtis at nic as gr ee mse ea nr tc 2h ,: 1A 1n (2o 0v 1e 4r )v ,i 1e –w 2. 2I .nternationalJournal [39] XiaoxueWu,WeiZheng,XinXia,andDavidLo.2021.Dataqualitymatters:A C htl to pu sd ://C do oim .op ru g/t 1in 0g .11V 0u 9l /n Mer Sa Pb .2il 0it 1i 0e .s 1. 15IEEESecurity&Privacy9,2(2011),50–57. casestudyondatalabelcorrectnessforsecuritybugreportprediction. IEEE [23] DavidHin,AndreyKan,HuamingChen,andMAliBabar.2022. LineVD: TransactionsonSoftwareEngineering48,7(2021),2541–2556. [40] FabianYamaguchi,NicoGolde,DanielArp,andKonradRieck.2014.Modelingand s c 5et 9a e 6t d –e i 6m n 0ge 7sn .ot- fle tv he el 1v 9u thln Ie nr ta eb ri nli at ty iod ne at le Cct oio nn feru es ni cn eg og nra Mp ih nin ne gu Sra ol ftn we at rw eo Rr ek ps o. sI in toP rir eo s- . d onisc So ecv ue rr ii tn yg av nu dln Pe rr iva ab cil yit .i Ie Es Ew Ei ,t 5h 9c 0o –d 6e 04p .ropertygraphs.In2014IEEESymposium [41] WeiZheng,JingYuanCheng,XiaoxueWu,RuiyangSun,XiaolongWang,and [24] MatthieuJimenez,RenaudRwemalika,MikePapadakis,FedericaSarro,Yves XiaobingSun.2022.Domainknowledge-basedsecuritybugreportsprediction. LeTraon,andMarkHarman.2019.Theimportanceofaccountingforreal-world labellingwhenpredictingsoftwarevulnerabilities.InProceedingsofthe201927th [42] K Yan qo iw nle Zd hg oe- uB ,a Ss hed anS gy qst ie nm gs L2 iu41 ,J( i2 n0 g2 k2 a), i1 S0 i8 o2 w9 ,3. XiaoningDu,andYangLiu.2019. ACMJointMeetingonEuropeanSoftwareEngineeringConferenceandSymposium Devign:Effectivevulnerabilityidentificationbylearningcomprehensiveprogram [25] o Dn avth ideF Ko au wn rd ya kti oo wns ao nf dSo Mft aw ra tir ne PEn Rg oin be ile lr ai rn dg .. 26 09 15 1– .7 N05 o. n-essentialchangesinver- semanticsviagraphneuralnetworks.Advancesinneuralinformationprocessing sionhistories.InProceedingsofthe33rdInternationalConferenceonSoftware systems32(2019). |
2403.03897 Fuzzing BusyBox: Leveraging LLM and Crash Reuse for Embedded Bug Unearthing Asmita1,YaroslavOliinyk2,MichaelScott2,RyanTsang1, ChongzhouFang1,HoumanHomayoun1 1UniversityofCalifornia,Davis 2NetRise Abstract acentralroleinIoTsecurity,asvulnerabilitieswithinthem can jeopardize an entire system’s security. Because of the BusyBox,anopen-sourcesoftwarebundlingover300es- roleitplaysingoverningmostaspectsofasystem’sbehav- sential Linux commands into a single executable, is ubiq- ior,firmwareisofparticularimportance.Often,firmwareis uitousinLinux-basedembeddeddevices.Vulnerabilitiesin comprisedofnumerousthird-partysoftwarecomponentsthat BusyBox can have far-reaching consequences, affecting a can be reused across various products,thereby amplifying widearrayofdevices.Thisresearch,drivenbytheextensive concernsregardingtheirvulnerability;asingleflawcouldpo- useofBusyBox,delvedintoitsanalysis.Thestudyrevealed tentiallyaffectmultipledisparatedevicesthatrelyonshared theprevalenceofolderBusyBoxversionsinreal-worldem- components.Consequently,continuousanalysisofthesecom- bedded products,prompting us to conduct fuzz testing on ponentsisimperative. BusyBox.Fuzzing,apivotalsoftwaretestingmethod,aims to induce crashes that are subsequently scrutinized to un- cover vulnerabilities. Within this study, we introduce two 1.1 Motivation techniquestofortifysoftwaretesting.Thefirsttechniqueen- Firmwarecanbebroadlyclassifiedintothreecategories:those hancesfuzzingbyleveragingLargeLanguageModels(LLM) basedonmodifiedgenericoperatingsystems(OS)likeLinux, togeneratetarget-specificinitialseeds.Ourstudyshoweda thosebasedonreal-time(RTOS)orcustomoperatingsystems, substantialincreaseincrasheswhenusingLLM-generated andthosethatdonothaveaformaloperatingsystem(non- initialseeds,highlightingthepotentialofLLMtoefficiently OS or bare-metal). Each of these categories poses distinct tacklethetypicallylabor-intensivetaskofgeneratingtarget- challenges when it comes to security assessment [32] and specificinitialseeds. Thesecondtechniqueinvolvesrepur- oftenrequiredifferentapproaches.Tothatend,wefocusour posing previously acquired crash data from similarfuzzed attention in this work on the largest subclass of OS-based targets before initiating fuzzing on a new target. This ap- firmware:EmbeddedLinux. proachstreamlinesthetime-consumingfuzztestingprocess byprovidingcrashdatadirectlytothenewtargetbeforecom- Embedded Linux-based firmware often utilizes various mencingfuzzing. Wesuccessfullyidentifiedcrashesinthe application-levelsoftwarecomponents,includingBusyBox, latestBusyBoxtargetwithoutconductingtraditionalfuzzing, Lighthttpd,Dropbear,SQLite,OpenSSL,telnetserver,and emphasizingtheeffectivenessofLLMandcrashreusetech- variousfilesystemutilities.Consequently,therearemultiple niquesinenhancingsoftwaretestingandimprovingvulnera- potentialattacksurfaces,warrantingcontinuedexploration bilitydetectioninembeddedsystems.Additionally,manual andresearch.Asacriticalsetofcommonlyusedutilitypro- triagingwasperformedtoidentifythenatureofcrashesinthe gramsinembeddedLinux,BusyBox[47]isacomponentof latestBusyBox. particularinterest.Itprovidesover300commonUnixutilities withinasinglelightweightandcompactexecutable,making it indispensable for resource-constrained Linux-based em- 1 Introduction bedded devices. There are many IoT and OT(Operational Technology)devicesrunningBusyBox,includingremoteter- TheproliferationofIoT(InternetofThings)devicescontin- minalunits(RTUs),human-machineinterfaces(HMIs),and uesunabated,withareported16%growthratepropellingthe manyothersthatarerunningonLinux.However,despiteits globalcountto16.7billion,accordingtoIoTAnalytics[1]. manyadvantages,itcanalsopresentconsiderablerisk,asit ThisremarkableexpansionintheIoTecosystemraisessig- isoftenusedwithelevatedprivilegesandprovidesmultiple nificantcybersecurityconcerns.Embeddeddevicesoccupy utilitiesthathandleuserinput,whichattackershavebeenable 4202 raM 6 ]ES.sc[ 1v79830.3042:viXratoexploit.14vulnerabilitieswerefoundinBusyboxin2021, some of which had the potential of remote code execution or denial of service attacks [6]. Despite this, in our inves- tigationwehaveidentifiedseveralreal-worldproductsthat continuetouseolderversionsofBusyBoxthatcontainknown vulnerabilities. Ourresearchquestionsforthisworkcanbesummarizedas follows: Q1: HowwidespreadarevariantsofBusyBoxandhowcan similarvulnerabilitiesacrossvariantsbeefficientlyiden- tified? Q2: HowcanweleverageLLMstoimprovefuzztestingon Figure1:Proposedworkpipeline embeddedLinuxutilityprogramslikethoseinBusyBox? 1.2 Contributions Wethenusedthecrashresultsaccumulatedfromtheseex- perimentstoevaluatethesecondtechnique,crashreuse,by Fuzzingisawell-recognizedsoftwaretestingtechniquefor testingthemagainstthelatestversionofBusyBox(v1.36.1 uncoveringvulnerabilities,butitseffectivenessvariesdepend- atthetimeofwriting).Sincetheaccumulatedcrashescorre- ingonthechosentarget,eachofwhichcanpresentunique spondedtoolderversionsofBusyBox,anyreusedinputsthat challenges.Inthiswork,weproposeandimplementtwotech- |
stillcausecrashesarelikelyduetothecontinuedpresenceof niques to assistsoftware testing forembeddedlinux. First, thesamevulnerability,whichallowustodiscovercrashesin weleverageLLM-basedseedgeneration,inwhichweuti- thelatestversionwithoutfuzzingitexplicitly.Wealsofuzz lizecommerciallargelanguagemodels(LLMs)togenerate testedthelatestversionandconductedacomparativeanalysis. theinitialinputseedsformutation-based,coverage-guided Theresultsofourvalidationhighlightedtheeffectivenessof fuzzing.Indoingso,wetakeadvantageofLLMs’inherent crashreusewithrespecttotimeandresourceefficiency. capabilitytogeneratehigh-qualitystructuredinputsthatad- Inthecontextofopen-sourcesoftwarecomponents,collect- heretotheinputgrammarofatarget.Second,weemploya ingcrashescanbeenhancedbyinstrumentingthesourcecode crashreusestrategytoidentifycrashesacrossvariantsofa andimprovingcrashidentification.Thesecollectedcrashes softwarecomponentpresentindifferenttargets.Thisstrategy canthenbeappliedtothevariantofthatsoftwarecomponent isbasedontheintuitionthataninputthattriggersacrashing presentindifferenttargets,evenincasesinvolvingblack-box vulnerabilityononevariantofaprogramislikelytotriggera testing.Thisisbecause,inmanyinstances,thevariantofsoft- crashondifferentvariant.Thisallowsustomoreefficiently warecomponentmayreappearindifferenttarget.Therefore, determine if the same vulnerability is present on multiple reusingexistingcrashesfromaparticularsoftwarecomponent program variants without performing fuzzing, thus saving fortestingitsvariantondifferenttargetscanbeadvantageous. significanttime. When we mention a variantofa software Thisapproachstreamlinestheprovisionofcrashdatadirectly component,wearereferringtoidenticalsoftwarecomponents tothetargetbeforethecommencementoffuzzing,resulting with varying version numbers or architectures or compiler insubstantialtimesavings. optimization,oranycustommodificationbydevelopers. Finally,weconductedcrashanalysisforthelatestBusyBox Asaproof-of-concept,wedemonstratethesetechniques version(v1.36.1),compiledfromtheBusyBoxsourcecode. withAFL++onBusyBox.Thisresearchwasdoneincollab- Figure1showstheoverallpipelineoftheproposedtechniques. orationwithNetRise’s[33]firmwaresecuritydivision.We Ourcontributionscanbesummarizedasfollows: sourcedBusyBoxELFsfromreal-worldembeddedproducts collectedfromthecompany’sproprietaryfirmwaredataset, • WeidentifyversionsofBusyBoxstillinuseincommer- whichhadbeenconstructedusingin-houseextractiontools. cialembeddeddevices,emphasizingtheneedtoupdate TheseELFbinarieswerefuzztestedwithoutalteringthetar- them. get’s source code orcompilation process,using AFL++ in QEMUmode. • WeimplementLLM-basedseedgenerationtoenhance Weevaluatedthefirsttechnique,LLM-basedseedgenera- fuzzingbyutilizingLLMfortarget-specificinitialseed tion,bycomparingcontrolrunsthatusedrandomlygenerated generation,leadingtofasterandmoreefficientseedgen- initialseeds,toexperimentalrunsthatusedinitialseedsgen- eration,morecrashes,andmoreoptionsfortriagingto eratedusingOpenAI’sGPT-4LLMAPI[35].Weobserved identify vulnerabilities. We developed an automation asignificantincreaseincrashesobtainedwhenusingLLM- scripttoperformfuzzingonalargebatchofBusyBox generatedseeds,demonstratingthepotentialforimproving targetswithoutmanualintervention,whichwillbemade vulnerabilitydetection. opensource.• Weproposecrashreuseasafirst-passbug-findingstrat- asavariable,buffer,stream,orfileisselectedasthetargetof egy,inwhichwereusecrashinginputsfordifferentpro- thefuzzingprocess.Thefuzzingengine,alsoknownasthe gramvariantstoquicklyfindduplicatevulnerabilities, fuzzer,generatesinputbasedonasetofrulesorstrategies, evenunderblack-boxtestingconditions. typicallyusingsomeelementofrandomness,andfeedsitto theprogram.Theprogramisthenexecutedwiththisinputand • WeidentifycrashesintheawkappletoflatestBusyBox observedforcoverageinformation.Theprocessisrepeated versionandconductmanualcrashtriagingtodetermine withanewlygeneratedinput.Thisprocesscanberepeated whethertheyoriginatedfromBusyBoxordependencies foraslongastheanalystdesires.Duringtheexecutionphase, intheunderlyinglibraries.Welaterappliedthesetech- the program may crash or trigger some other error. If this niquestootherappletsincludingdc,man,andash. occurs,theinputthatcausedtheissueissavedforlaterroot causeanalysis.Thistypeoffuzzingisknownasblack-box 2 Background fuzzing because the fuzzeris unaware ofthe program’s in- ternals.Incontrasttoblack-boxfuzzing,white-boxfuzzing Inthissection,weprovideabriefoverviewofsomeofthe assumescompleteknowledgeoftheprogram’sinternalstruc- toolsandtechniquesrelevanttothispaper. ture.Itallowsinputgenerationstrategiestousetechniques suchastaintanalysisorsymbolicexecution,whichrequire understandingtheprogram’ssyntax.Inbetweenwhiteand 2.1 BusyBox black-boxfuzzingisgrey-boxfuzzing,wherethereisonlypar- tialaccesstoinformationabouttheprogram’sinternalstate. BusyBox[47]isasinglebinaryexecutableforseveralUnix- Inthisapproach,codecoverage,whichreferstothenumber basedutilitiesdesignedmainlyforresource-constrainedem- |
oflinesofcodeorbasicblocksthatareactuallyexecuted,is beddeddevices.Itisopensource,lightweight,compact,and oftenusedtodirectinputgeneration.Programcodemustfirst hasasmallfootprint.Itallowsmanufacturerstoincludees- undergoinstrumentationtogathercoverageinformation,in sential Linux utilities without significantly increasing the whichadditionalcodeisinsertedintotheprogramtoactasa firmware size. Moreover, it is highly customizable. It can markerandcollectruntimedata. beconfiguredtoincludeonlythespecificutilitiesrequiredfor theembeddedsystem’sfunctionality. However,ithasassociatedpotentialsecurityrisks.Busy- Boxoftenrunswithelevatedprivilegesasvarioustasksre- 2.2.1 AFL/AFL++ quirerootaccess,henceapotentialriskofprivilegeescalation. Italso provides a varietyofcommands thatacceptuserin- American fuzzy lop (AFL) is a coverage-guided,grey-box put.Ifthesecommandsarenotproperlysanitized,itcanlead fuzzerthatemployscompile-timeinstrumentationandseveral tocommandinjection[31],bufferoverflow[37],andother differentalgorithmstoefficientlyfuzzprograms[51].Ata vulnerabilities[7].Forinstance,awkappletisusedfortext highlevel,AFLtracksbranchcoveragebetweenbasicblocks processing and data manipulation tasks. It can be used to (edges) for a generated input file, keeping track of all the do privileged read or write outside a restricted file system edgesthattheinputfileyields.Wheneveranewinputfileis asitwritesandreadsdatatoandfromfiles.Similarly,other created,AFLchecksifitleadstopreviouslyunseenedges, applets may possess security risks when not configured or saves the file,and uses it to inform future mutations. AFL usedcorrectly.Moreover,asBusyBoxaimstobesmalland usesdeterministic(suchassequentialbitflipsandsequential lightweight,itmaylacksomeofthesecurityfeatures,orthe additionofsmallandinterestingintegers)andnondeterminis- issuesmightalsooccurbecauseofitsotherexternaldepen- tic(suchasastackedsequenceofrandomizedoperationswith dencies.Givenitscriticalroleinmanyembeddedsystemsand equalprobability)mutationstrategies[11].AFL[51]hasbeen itspotentialsecurityrisks,securingBusyBoxthroughproper extensivelyusedinindustryandacademicresearch.However, configuration,regularupdates,codereviews,andsecurityas- theoriginaldeveloperceasedactivedevelopmentonAFLin sessmentsareessentialtomaintainingtheoverallsecurityand 2017,leadingtothedevelopmentofacommunity-drivensuc- reliabilityofembeddedLinux-basedfirmware. cessor,AFL++,in2019.AFL++featuresnewenhancements, fuzzingstrategies,andperformanceimprovements[11]. AFL++ provides detailed documentation for all its sup- 2.2 Fuzzing portedfeatures.Ifthesourcecodeisavailable,thefirststage Fuzzingisoneofthewidelyusedmethodsforsoftwaretest- involvesmodifyingandcompilingthetargetusingtheAFL++ ing.Itleveragescoveragefeedbackandaimstoidentifyifany compiler. Otherwise,when the source code is unavailable, crashoccurs,whichisthenanalyzedtoidentifythevulnera- AFL++QEMU[3]performsinternalinstrumentationatrun- bilities.Fuzzingcanbedescribedasinputtesting,whichis time.Thenextstageistoprovidetheinitialseedcorpusfor semi-randomizedduetotheimpossibilityofexhaustiveinput fuzzingthetarget,followedbytheactualfuzzingstageand testinginmostcases.Invanillafuzzing,aprograminputsuch crashtriaging.2.3 LLMinFuzzing 3 RelatedWorks 3.1 CommandLineFuzzing Largelanguagemodels(LLMs)areknownfortheirprowess innaturallanguageunderstandingandtextgeneration.Itspri- CLIprogramswerethefirsttobesubjectedtowhatisnowthe maryfocushasbeendevelopingAImodelsandtechnologies, fuzztestingtechniquewithMilleretal.’sstudiesontherelia- such as the GPT (Generative Pre-trained Transformer) se- bilityofUNIXutilityprograms[27–29].Milleretal.recently ries[36],forvariousapplications,includingnaturallanguage repeatedtheclassicfuzztestforanumberofUnixutilities understanding, generation, and automation. While LLM’s onLinux,FreeBSD,andMacOS[30],demonstratingtherele- work may not be directly related to fuzz testing,there are vanceofclassicalfuzztestingforcommandlineutilitieseven potential intersections between AI and security,where AI- now.Theyusedrandominputgenerationtechnique. poweredtoolsandtechniquescouldbeusedtoenhancesecu- Since the original studies,fuzz testing has grown into a ritytestingpractices[20],includingfuzzing.AIcanassistin flourishingareaofresearch,withCLIutilitiescontinuingtobe automatedtestcasegeneration,identifyingpatternsincode amajortarget[5,14,38,51,55,56].Significantimprovements morelikelytocontainvulnerabilities,andanalyzingcodepat- have been made by considering grammars to define input terns,amongothertasks.SomeexistingworkleveragesLLM formattingconstraintsduringseedgeneration[2,4,13,45,46], forfuzzing.InarecentblogbyGoogleopensourcesecurity whichisalsorelevanttofuzzingcommandlineargumentsin team[21],anLLM-aidedfuzzingisproposed.OSS-Fuzz[14] particular. isintegratedwiththeLLMtoassessitspotentialtogenerate Songetal.[42]notedthatmostoff-the-shelffuzzersdonot newfuzztargetseffectively.OSS-Fuzz’sFuzzIntrospector dealwellwithconditionaloptionparametersandintroduced |
toolidentifiesandsendstheunder-fuzzedandhigh-potential CrFuzztomoreefficientlyexploremulti-purposeprogramsby partoftheprojectcodetotheevaluationframework.Aprompt addinginputvaliditypredictiontoexistingfuzzers.Guptaet iscreatedbytheevaluationframework,whichembedsproject- al.[15]tookadifferentapproachtoenablesystematictesting specificinformation.LLMsubsequentlyusesthepromptto ofcommandlineoptionsbydefiningagrammarforvalidse- writeanewfuzztarget.Thenewlygeneratedfuzztargetis quencesofoptionsandargumentsbasedonthegetoptfunc- sharedbackwiththeevaluationframework,whichexecutesit tion.Zhangetal.[53]proposeConfigFuzz,whichtransforms andmonitorsforanychangeinthecodecoverage.Incaseof theprogramundertesttotreatconfigurationparametersas anycompilationfailure,itpromptstheLLMtorevisethefuzz potentialfuzzinginputs.Wangetal.[44]proposeCarpetFuzz targetaddressingthecompilationfailure.Thiscomprehensive toextractcommandlineoptionrelationshipsfromdocumenta- approachshowshowLLMscanbeharnessedtocompletely tionusingNLPtoimprovetheefficiencyoffuzzingdifferent automate the fuzz testing process of OSS-Fuzz, contribut- optioncombinations. ingtoitsefficiencyandefficacy.Otherrelatedworksinclude The introduction of LLMs is already making waves in ChatFuzz[17],anLLM-basedfuzzerthatenhancesthequality the fuzzing community. OSS-fuzz [14,18] has begun ex- offormat-conforminginputsforfuzzing,andFuzz4All[48]. periments to explore fuzzing new targets with LLMs [21]. ThissystemutilizesLLMforinputgenerationandmutation, Huang et al. [18] survey a number of LLM-based fuzzers, producingdiverseandrealisticinputsforvariousprogram- atleast4ofwhichappeartobedirectlyapplicableforCLI minglanguages.Fuzz4Allmainlytargetssystemsthataccept tools[17,25,48,50].OtherworkshaveemployedLLMsfor programminglanguagesasinput.Additionally,FuzzGPT[9] thepurposesofdirectinputgeneration[49,52],mutation[8], uses LLM as a fuzzerto test deep-learning libraries. Simi- andseedgeneration[17,25].LLMshavealsobeenemployed larly,asdiscussedinSection4.2,ourworkleveragesLLMto togenerateinputsthathaveirregularoruniqueinputgram- generateinitialseedsforfuzzingBusyBox. marsandsemantics[23,39].These,however,wereapplied tosoftwaremeantforgeneral-purposesystems,andnoneof However,what sets our approach apart is that we exclu- thesehaveexploredtheapplicationtofuzzinginembedded sivelyemployLLMfortheinitialseedgenerationstagetarget- environmentslikeBusyBox. ingembeddedapplication,unlikeotherworkswhereLLMis integratedintotheentirefuzzingormutationprocess.Aspre- viouslydiscussed,fuzzersrelyoninitialinputseedsforthetar- 3.2 FuzzinginEmbeddedEnvironments get.Whilerandomseedscanbeused,theperformancesignifi- cantlyimproveswhentheinitialseedsalignwiththeexpected Toourknowledgeanduponconductingthoroughresearch, inputs forthe target. Common initialtestcases forvarious we have found no dedicated paper addressing the topic of inputs,suchasimages,videos,PDFs,XML,andHTML,are BusyBoxfuzzing. However,therehavebeenvariousblogs readilyavailable.However,insomecases,generatingthese andarticlesdiscussingthissubject.Forinstance,Clarotyand initialseedscanbechallenging.Insuchsituations,leveraging JFrog[26]identified14vulnerabilitiesinBusyBoxversion LLMallowsustogenerateinitialseedssimplybyproviding 1.34.0.It’sworthnotingthatotherrelatedworksoftenfocus informationaboutthetargettype. on uncovering vulnerabilities in specific targets. However,fuzztestinginLinux-basedembeddedsystemsisanactive tocontinueimprovingfuzzingtechniquesandstrategiesfor areaofresearch. embeddedLinuxtargetsbyutilizingLLMsandcrashreuse. In an early application offuzzing in embeddedsystems, Sim et al. [41] applied black-box fuzzing to the Out-Of- 4 Experiment MemoryKillerprocessonembeddedLinux,whichrevealed a number of failure modes that would cause the kernel to Inthissectionweoutlinethesamplecollectionprocess,our remainintheOut-Of-Memorystateandunresponsive.They implementation of LLM-based seed generation, using the implementedanadaptiverandomapproachtoinputgenera- Awkappletasanexample,andourexperimentalprocedures tionthatreducedthenumberofinputsnecessarytoexpose forcrashreuseandanalysis. failures. Duetal.[10]presentsAFLIoT,anon-devicefuzzingframe- workforLinux-basedIoTfirmware.Itinvolvesbinary-level 4.1 Analyzing BusyBox Versions in Real- instrumentationtechniques.ItleveragesanAFLfuzzer.Ithas WorldProducts twophases,namely,theinstrumentationandfuzzingphase. The implementation involves storing the fuzzerandthe in- As mentioned in Section 1.1, BusyBox is widely used in strumentedprogramonthedevice.AFLfetchestheexecution Linux-basedembeddeddevices.Inordertounderstandthe information of the target binary by shared memory. It sets scopeofimpactthatvulnerabilitiesinBusyBoxvariantsmight upasharedmemorybeforeforkingthetargetprogramand have(RQ1),weconductedabriefinvestigationonthepreva- thenmapsitintoitsmemoryspace.Theinstrumentedcodeis lenceofolderversionsofBusyBoxwithinreal-worldprod- responsibleforkeepingtrackofbasicblocktransition,which ucts. To achieve this,we harnesseda proprietary firmware |
AFLthenanalyzestoassessthevalueofthetestcase.The datasetprovidedbythecompany.Thisdatasetwascurated authors have also implementedtheinputredirection mech- using the company’s platform,which was employed to ex- anism between the fuzzer and the target network daemon tractthecollectedfirmwaresamples.Withintheseextracted program.AFLIoTidentified437uniquecrashes,outofwhich filesystems,weidentifiedBusyBoxELFbinaries.Weiden- 95werenewlyfound.Itwastestedon13binaryprograms. tified293BusyBoxELFbinariesdistributedacrossvarious Theauthorshaveevaluatedbothbenchmarksandreal-world real-world firmware binaries within the smallrealm of the IoTdevices. provideddataset. Withinthescopeofouranalysis,wefocusedonapproxi- Zhengetal.[54]proposedEQUAFL,anefficientgreybox mately80ELFsfromARM_32andx86_64architectureswith fuzzing for Linux-based IoT devices using enhanced user- 30 BusyBox variants across them. Eachofthese BusyBox modeemulation.Itautomaticallysetsuptheexecutionenvi- ELFbinariespossessedauniquefilehashname.Toextract ronmenttoexecuteembeddedapplications.Itfirstexecutes the version information from these binaries,we devised a theapplicationunderfull-systememulationandobservesthe straightforward Python script that scours each ELF for oc- pointswherethetargetmaycrashorstuckduringuser-mode currences of "BusyBox v" using the command: "strings emulation. Then, depending on the observed information, $busybox_file | grep ’BusyBox v’".Additionally,we it migrates the needed environment for user-mode emula- employedaregex-basedversionpattern-matchingtechnique tion. It supports the replay of system calls of network and forextractingtheversioninformation.The80binariesidenti- resourcemanagementbehavior.Theapproachinvolvesusing fiedwereusedasthedatasetforourfuzzingexperimentsand lightweightprograminstrumentationtocollectexecutionfeed- crashreuseanalysis. backoftheprogramundertest(PUT),suchascodecoverage, toguidetheentiretestingprocess.Theauthorsproposetoob- servethedynamicconfigurationfilegenerationandNVRAM 4.2 LeveragingLLMsforInitialSeedGenera- configurations with process awareness, network behaviors tion withstateawareness,andotherinformationsuchaslaunch variablesandprocessresourcelimitsusingseveralheuristics. Wefocusourattentiononfuzzingtheawkappletwithinthe Theauthorsconductedexperimentsonseveralreal-worldIoT identifiedBusyBoximagesasourprimarytargetduetoitspo- devices and demonstrated that their approach outperforms tentialforexploitation.Thisappletislightweightinterpreter existing techniques regarding code coverage,vulnerability fortheawkscriptinglanguage,whichisoftenemployedin discovery,andexecutiontime. embeddedsystemstofacilitatetextprocessingtaskssuchas All the work described above has involved a significant textfiltering,patternmatching,anddatamanipulation.awk efforttodevelopimprovedtechniquesforenhancingthesecu- scriptsmayprocessexternalinputwithoutpropervalidation, rityassessmentofrespectivetargets.Otherworksthatinvolve makingthemsusceptibletoscriptinjectionattacksiftheinput fuzzing embedded Linux have focused on enabling effec- isnotsanitizedeffectively.Vulnerabilitieswithintheseawk tivefuzzingthroughemulationandorrehosting[19,22,43], scripts can leadto unintendeddata manipulation ordisclo- whichisanopenproblemonitsown.Ourworkisintended sure,posingsignificantsecurityrisks.BecauseawktakesasFigure2:AutomationFrameworkWorkflow(N.B:Targeto/pcontainscrashes,queuesalongwithotherstatsrelatedtofuzzing) itsinputanawkscript,whichmustconformtoaparticularlan- guagegrammar,itisanaturalchoiceoftargetforLLM-based seedgeneration,astheLLMcanbeutilizedtoeasilygenerate conformantawkscripts.Whilethebruntofourfocuswason awk,LLM-basedseedgenerationisbynomeanslimitedto thistarget;weconductadditionalexperimentsonothertarget softwarecomponentstodemonstratethisinSection6. 4.2.1 ExecutionEnvironment Binariescompiledforx86wereevaluatedonUbuntux86_64, andARM-basedbinarieswereevaluatedintheQEMUemula- tor.Notably,weencounteredchallengesinaddressingARM- specific dependencies, which were effectively resolved by accessingtherequireddependencyfilesfromthecompany’s database.Thecompany’splatformhadpreviouslyextracted Figure3:InitialseedgenerationusingLLM thecompletefilesystemofthetargetbinary,whichincluded therequisitedependencyfiles.Thisresourceprovedinvalu- workflow within this framework, illustrating the sequence ableinovercomingthechallengesassociatedwithARMtarget of steps from dependency management to fuzzing and re- dependencies. sult collection. The automation script is available at link - Fuzzer parameters are meant to be user-defined and in- https://github.com/asmitaj08/FuzzingBusyBox_LLM clude the initial input corpus, AFL environment variables to be set, and the fuzzer termination criteria. These crite- ria include statistical metrics such as runtime,the number 4.2.2 LLM-basedSeedGenerationPipeline ofcrashes,thenumberofcycles,andotherrelevantfactors. Oncethefuzzerwasconfiguredandinitiated,itcontinuously Figure3visuallyrepresentsourapproachtogeneratinginitial monitoredthespecifiedcriteriafortermination,haltingthe seedsforfuzzingthroughLLM. fuzzingprocessuponreachingthedefinedconditionsorin Thereare2scenariosunderwhichinitialseedsneedtobe |
theeventofcatastrophicerrors(conditionsthatcauseAFL++ generated:whenthetargetinputformatiswell-definedand/or itself to crash). The outcomes of the fuzzing process were standardized,andwhentheinputformatisloosely-definedor storedseparatelyandcategorizedbytheirrespectivetargets, unknown.Whentheinputformatiswell-defined,aswould tofacilitatesubsequentanalysis.Failedtargetswereflagged is the case for well-known programs like some BusyBox forfurtherexaminationanddiagnosis. Additionally,JSON applets,we reason thatLLM shouldnotrequire additional dumpsofthestatisticsfilescorrespondingtoeachtargetwere training,asitalreadypossessesknowledgeoftheexpected collected in a shared directory, enabling easy comparison inputformatthroughitsinitialtrainingontheinternet.This and analysis. Figure 2 provides an overview of the entire canalsobedeterminedempirically.However,whentheinputcheck,wefirstevaluateourhypothesisonoursetoffuzzed targetsbycross-validatingthecrashinginputsofeachtarget oneachothertarget. CrashReuseprovidesseveraladvantagesinsoftwaretest- ing: 1.Efficiency:Initiallytestingthenewtargetagainsttheconsol- idatedcrashdatabaseoffersthepotentialforsignificanttime andresourcesavings.Bycapitalizingonthecrashesidenti- fiedduringpreviousfuzztestingonsimilartargets,wecan leveragingtheresourcespreviouslyexpendedinfuzzingand acceleratethefuzzer’scoverageexplorationbyincludingit infutureseeds.Hence,wecanpotentiallyidentifypreviously discoveredcrashesinthenewvariantwithoutextensivefuzz testing. 2. Black-Box Testing: This technique is highly beneficial whenconductingblack-boxtestingonnewvariantsofaprevi- ouslytestedtarget.Itisparticularlyadvantageousinscenarios Figure4:Testingnewtargetswiththeexistingcrashdatabase. wherethetargetutilizesaccessibleoropen-sourcesoftware components,eveniffurtherdetailsareunavailable.Byfuzzing open-sourcevariants,wecangathercrashinginputstouseas formatofthetargetisill-definedorunknown,aswouldbe high-qualityseedsthatarelikelytoidentifyduplicatevulner- thecaseforcustomcommunicationprotocols,LLMwould abilities.Thisispreferabletoengaginginresource-intensive requirefine-tuning.Inthisscenario,LLMneedstobeinitially binary-onlyblack-boxfuzzing,whichcanbeextremelydiffi- trainedwithknownsamplestodevelopanunderstandingof theexpectedinputformat. InthecaseoftheBusyBoxawk cultdependingonthecomplexityofthesystemundertest. applet,wereasonthatGPT-4shouldalreadybeawareofthe Figure4providesavisualrepresentationofourapproachto inputformatgiventheapplet’spopularity.Hence,wedidnot crashreuse.Weactivelycurateadatabaseofcrashesobtained applyfine-tuning. frompreviouslyfuzzedsoftwarecomponents.Then,whenwe Forseedgeneration,weutilizedOpenAI’sGPTmodel"gpt- encountervariantsofthesesoftwarecomponentsinthefuture, 4-0613",achatcompletionmodelwithatemperaturesetting weleveragethecollectedcrashestoidentifypotentialissues of0.7(chosenempirically),whichweaccessviaqueriesto inthenewvariantundertestwithoutfuzzing.Thisprovides thewebAPI.Weprovidedthefollowingprompttoguidethe uswitharapidinitialassessmentofthenewtarget,whichcan seedgenerationprocessforawk: laterundergomorethoroughfuzzingforin-depthinspection. "role":"system","content":"Youareinitialseedgenerator AsdetailedinSection6,thistechniqueisapplicabletoany forafuzzerthathastofuzzBusyBoxawkapplet.Inresponse targetwhosevarianthasundergonepreviousfuzzing,andfor onlyprovidethelistofawkscripts" whichwepossessacorrespondingcollectionofcrashes. "role":"user","content":f"GenerateinitialseedtofuzzBusy- Boxawkapplet" 4.4 EvaluatingaNewTarget Themodelrespondedwithalistofcommandsrelevantto theBusyBoxawkapplet.Thesecommandswerethentrans- Afterencounteringasubstantialnumberofcrasheswithinthe latedintoindividual.awkscripts,whichweresubsequently collectedversions ofBusyBox during ourresearch,we ap- integrated into the input corpus. This input corpus served pliedourtechniquestothelatestversion(1.36.1);thisserved as the set of initialseeds forthe fuzzing process. We used asanevaluationofourtechniquesforanewtarget,aswehad afl-cmintominimizetheinputcorpusbeforesendingitto collectednosamplesthatcontainedthemostrecentBusyBox thefuzzer,whichfilterstheLLM-generatedinputcorpusto version.WebuiltourtargetbycompilingtheBusyBoxfrom includeonlytheseedsthatareusefulforfuzzing. itssourcecodeforx86_64,followingtheprescribedinstruc- tions.WeoptednottoinjectAFL++instrumentationintothe binary. 4.3 CrashReuse Ourapproach to testing the latest BusyBox version was HavingcompletedourfuzztestingrunsonindividualBusy- executedintwodistinctstagestoleveragebothtechniques Box targets, we turn our attention to triaging crashes and effectively: investigating the potential utility of crash reuse. To recap, Stage1:CrashReuse- Inthisstage,weappliedTechnique2, wehavehypothesizedthatwecanleverageknowncrashing thatis,crashreuse.Thistechniqueinvolvedtestingthelatest inputsforagiventargettoquicklydetermineifvariantsof versionagainstallthepreviouslyobtainedcrashesfromour |
thattargetcontainasimilarvulnerabilityorbug.Asasanity researchwithoutsubjectingittoadditionalfuzzing.Thegoal5.1 BusyBox Versions in Real-World Embed- dedDevices AsdiscussedinSubsection4.1,ourfirstobjectiveistoshed lighton the olderversions ofBusyBox thatare stillin use within real-world embedded products. Table 1 presents an overviewoftheversionsofBusyBoxthatwediscoveredin approximately80embeddedproductsspanningvariouscat- egories,including wireless access points,telecom devices, buildingautomationsystems,routers,printers,powerdistri- butionunits,andothers.Ourfindingsrevealedthatmanyof thesedevicescontinueusingsignificantlyolderBusyBoxver- sions.Notably,thelatestversionofBusyBox,asofthetime Figure5:Crashtriagingprocess. ofwritingthispaper,isv1.36.1.However,Table1illustrates thatmanyolderversionsarestillinuse.Thisdiscoveryiscon- cerning,especiallygiventhewell-documentedvulnerabilities wastodeterminewhethersomeexistingcrashescancrashthe associatedwiththeseolderversions. latestversionofBusyBox,i.e.,increasingthescopeoffinding Itisimportanttoemphasizethatourinvestigationfocused vulnerabilitieswithouthoursoffuzzing. onalimitedsetoffirmwaresamples.Consideringthevastar- Stage2:FuzzTesting-Inthesecondstage,wefuzztestedthe rayofembeddeddevicesthatpopulatethemodernlandscape, targetinAFL-QEMUmodeusinginitialseedsgeneratedby thissituationraisessignificantconcernsthatdemandattention GPT-4withtheaimofuncoveringadditionalpotentialcrashes andremediation.Insummary,theoutcomesunderscorethe andvulnerabilities.Weperformed10hoursoffuzzingonthe pressingneedforincreasedawarenessandactionconcerning latest BusyBox on x86_64 host machine running Ubuntu theusageofoutdatedandvulnerableversionsofBusyBoxin 22.04. real-worldembeddeddevices.Asimilarsituationcouldarise Afterourtestingstages,weanalyzedthecollectedcrashes withothersoftwarecomponents. toidentifyuniqueones,determinetheunderlyingcauses,and ascertain whethersimilarissues hadbeen previouslydocu- mented.Toourknowledgeatthetimeofourresearch,there 5.2 LeveragingLLMsforInitialSeedGenera- was no fully automated tool capable of reliably and com- tion prehensivelyanalyzingfuzzer-inducedcrashes,makingtool- Initially,weexecutedtheAFL++fuzzerfor3hoursoneach assistedmanualanalysisthemostreliablemethodofinvesti- BusyBoxAWKapplettarget,utilizingthedefaultAFL++set- gation.WeperformedouranalysisusingGhidra[34],GDB tingsinQEMUmode.ThismeansthatnoAFL++instrumen- (GNUDebugger)[12],andAFL-Triage[16].Westartedour tationwasappliedduringcompilation.Duringthisphase,we analysiswithAFL-Triage,whichutilizesGDBtotriagecrash- recordedthenumberofcrashesthatoccurredineachtargetas inginputfiles.Itcategorizescrashesbasedontheirtypeand wellasthenumberofedgesidentifiedthroughoutthefuzzing reportsthedebugger’soutput,makingiteasiertoidentifythe process. Then,asdetailedin Subsection 4.2,weemployed causeofthecrash.Italsosupportscrashdeduplication,thus GPT-4togeneratetheinitialseeds.Inthisphase,werepeated assistinginidentifyinguniquecrashes. the3-hourfuzzingprocessforeachtarget.Werepeatedthe Onceweobtainedthelistofuniquecrashes,weanalyzed samemetricsanalysis,countingthenumberofcrashesand theinputthatcausedeachcrashandattemptedtominimizeit. edgesdiscoveredforeachtarget. Moreover,weconductedmanualreverseengineeringusing TheresultsfromsomeoftheARM_32andx86_64-based GhidraandGDBtoidentifytherootcause.Itwasfollowed BusyBoxtargetsarepresentedinTable2.Itillustratesthatsig- bysearchingtheCVE(CommonVulnerabilitiesandExpo- nificantlymorecrasheswereidentifiedduringfuzzingwhen sures)databasetoidentifysimilarbugsandconductingfurther theinitialseedsweregeneratedbyLLMcomparedtotheones analysistodetermineifthebugwasbecauseofBusyBoxor withrandomseeds.Moreover,thesamepatternwasobserved otherlibrariesonwhichitwasdependent.Figure5showsthe inthecaseofthenumberofedgesfoundduringthefuzzing overviewofthetriagingprocess. of each of the targets. To visually represent this, Figure 6 providesagraphdisplayingdatafromfourtargets,contrast- ingthenumberofedgesdiscoveredinthetwoscenarios,i.e., 5 Results initialseedsgeneratedbyLLMversusrandomseeds.Note: Inthetablesandfigures,theterm"without-LLM"signifies This section provides an overview of the results obtained scenarioswhererandominitialseedswereused,while"with- throughtheexplorationoftheaforementionedtechniques. LLM"denotescaseswhereinitialseedsweregeneratedusingTable1:BusyBoxversionsinreal-worldembeddeddevices BusyBox No.of Product BusyBox No.of Product BusyBox No.of Product Version Occurrence Types Version Occurrence Types Version Occurrence Types networkmanagementtool, wirelessaccesspoint, v1.7.2 2 wirelessaccesspoint, v1.19.4 4 v1.27.2 1 powerdistributionunit networkhardware, securitycamera v1.10.2 1 telecomdevice v1.20.2 2 securitycamera, v1.28.3 1 networkmanagementtool drone,ipphone, v1.11.1 1 buildingautomation v1.21.1 5 v1.28.4 1 operatingsystem medicaldevice,bmc wirelessaceesspoint, v1.13.2 1 buildingautomation v1.22.1 7 networkswitch, v1.29.3 1 operatingsystem operatingsystem wirelessaccesspoint, |
v1.15.2 2 wirelessaceesspoint v1.23.0 3 wirelessaccesspoint, v1.30.1 6 buildingautomation, powermanagemnetsystem v1.17.2 1 router v1.23.1 7 bmc,router, v1.33.0 1 powermanagementsystem wirelessaccesspoint, v1.17.3 1 telecomdevice v1.24.1 7 v1.34.0 1 networkcontrollercard networkswitch, drone, buildingautomation, v1.17.4 1 printer v1.25.0 3 v1.34.1 4 networkattachedstorage wirelessaccesspoint v1.18.2 1 wirelessaceesspoint v1.25.1 3 wirelessaccesspoint, v1.35.0 1 router powermanagementsystem, v1.19.2 1 wirelessaceesspoint v1.26.2 6 v1.36.0 1 router buildingautomation, Table2:Comparisonofnumberofcrasheswithandwithout Table3:WorkleveragingLLMforfuzzing LLM Work Target LLMusecase Target Product No.of No.of Target Product No.of No.of Extractamachine-readable Version crashes crashes Version crashes crashes (ARM) Type w/oLLM withLLM (x86_64) Type w/oLLM withLLM ChatAFL Protocols grammarforaprotocol, embedded network [25] generatediversemessages v1.34.1 wireless 3 188 v1.23.1 64 140 controller controller forinitialseeds. medical network Usedatthemutationg v1.29.3 54 82 v1.22.1 management 43 165 device tool ChatFuzz Formatconforming stagetogenerated embedded network [17] targets formatconforming v1.34.1 3 177 v1.30.1 management 147 229 PLC tool mutatedinputs v1.15.3 aub tu oi mld ain tig on 220 404 v1.27.2 o sp ye sra teti mng 0 114 Fuz4All Targetsthatneed Generatecodesnippets storage [48] differentprogramming fordifferentprogramming v1.23.2 camera 50 165 v1.23.1 array 38 178 languagesasinput languages controller v1.18.4 plc 137 224 v1.21.1 firewall 44 99 WhiteFox Optimizationsourcecode v1.30.1 o sp ye sra teti mng 49 106 v1.19.4 n se wtw ito cr hk 49 172 [50] Compiler analyzer,testinput security operating generation v1.26.2 55 70 v1.15.1 166 357 camera system Proposed Embeddedapplications Generatediverseandtarget- power v1.32.0 control 0 70 v1.23.1 network 41 98 Work likeBusyBox specificinitialseeds. controller system network v1.27.2 drone 34 147 v1.35.0 management 2 193 tool riedoutfortheolderversionsofBusyBox,andsuchtriaging wasprimarilyfocusedonthelatestversion.Hence,inthedis- cussedcaseshere,weconductedfuzzing,collectedcrashes, LLM,and‘relative_time‘istherunningtimeofthefuzzerin usedAFL-Triagetocategorizethem,andrecordedtheunique seconds. crashes,notablymoreabundantintheLLM-generatedinitial Furthermore,Figure7presentsaVenndiagramdepicting seedscenarios. thenumberofuniquecrashesfoundineachcaseandthenum- berofcrashescommoninbothcases.Thisgraphicemphasizes theimportanceofdiscoveringamoresignificantnumberof 5.3 CrashReuse crashes. When there are more crashes to work with,there aremoreopportunitiestodiscoverdifferentfailingexecution Afterwehadamassedasubstantialnumberofcrashesfrom paths,thereby increasing the likelihood of uncovering vul- fuzzedBusyBoxtargets,ourtotalcollectionamountedto4540 nerabilities.Figure7underscoresthisbyrevealingthatmore crashesthatlikelymaptoamuchsmallerplaceinthebinary uniquecrasheswereidentifiedwhenutilizingLLM-generated wherethecrashhappens.Subsequently,asoutlinedinSubsec- initialseeds.However,comprehensivetriagingwasnotcar- tion4.3,wesubjectedthelatestBusyBoxversion(v1.36.1)toFigure6:ComparisonofnumberofedgescoveredwithandwithoutusingLLMforinitialseedgeneration.TargetsareBusyBox in(1)Networkcontroller,(2)Networkswitch,(3)Storagearraycontroller,(4)Firewall Figure7:Comparisonofnumberofuniquecrashesfoundwith andwithoutusingLLMforinitialseedgeneration.Targets Figure 8: Comparison of number of unique crashes found areBusyBoxin(1)Networkcontroller,(2)Networkswitch, usingcrashreusetechniquevsfuzzing (3)Storagearraycontroller,(4)Firewalltestingagainstallthesepre-existingcrashes.Thisendeavor discovered 97 crashes in the latest BusyBox, of which 19 wereunique.Later,weconductedtraditionalfuzzingonthe latestBusyBoxusingAFL++QEMUmode,withinitialseeds generatedbyLLMover10hours.Thisapproachyielded20 crashes,ofwhicheightwereunique.Remarkably,fiveofthese Figure9:Segmentationfaultinregcomp eightuniquecrasheswerealsoidentifiedusingthecrashreuse technique.Figure8presentsagraphicalcomparisonofthe CVE-2015-8776, respectively. Although these CVEs were numberofuniquecrashesdiscoveredusingthecrashreuse identified quite some time ago, we encountered them in techniqueversustraditionalfuzzing,aswellasthecommon GLIBC versions 2.35 and 2.38 on a host running Ubuntu crashesbetweenthetwomethods. 22.04,andtheseissueswerealsoreproducibleinDebiandis- Theseresultsunderscorethepotentialutilityofcrashreuse tributions.Ithighlightsthepersistenceofthesevulnerabilities insoftwaretesting.AsdiscussedinSection4.3,itcanreduce acrossmultiplesoftwarecomponentversions,necessitating substantialtimeandresourcedemands,andisavaluabletool renewedattentionandremediationefforts.Wesubsequently forblackboxfuzzingwhenacomprehensivecrashdatabase filed bug report forthese findings; though the bugs appear isavailable. tohavenotbeenconsideredpossiblybecauseitissameas Additionally,itisessentialtonotethatnotallcrashesin- thebugwhoseCVEhasalreadybeenassigned.Inaddition dicatesoftwarebugs.Crashescanoccurforvariousreasons, |
tothecrashinputpatternschosenfortriagingthattriggered including invalid inputs,false positives,unreachable code, crashesinGLIBC,othercrashinputsalsoinducedsegmenta- executionenvironmentfactors,platform-specificissues,and tionfaultswithinBusyBox.Aftermanualtriaging,itbecame othernon-bug-relatedcauses.Reachingconclusivedetermi- apparentthatmanyofthesecrasheswereprimarilyattributed nationsofteninvolvesmeticulousmanualtriaging,whichcan toimpropermemoryaccess.Wecouldnotdiscoveranyread- be time-consuming and intricate. As such, we limited our ilyexploitablebugs.Stead,weidentifiedcrashpatternsthat, scope to identifying crashes,with triaging performed only aftermorein-depthexploration,couldpossiblyrevealvulner- onasubsetofcrashesfoundinthelatestBusyBoxversion. abilities. However,aspreviouslydiscussed,thequantityofcrashesis avitalmetricinfuzzing.Ahighernumberofuniquecrashes 5.4.1 Crashdetails equatestoamoreextensivearrayoftestscenariostoexplore duringtesting.Consequently,thisincreasesthelikelihoodof The analysis of crashes was done manually using GDB identifyingpotentialsoftwarevulnerabilitiesorbugs. and Ghidra.The issue identified in regex was the de- nial of service (DoS) caused by memory exhaustion. The 5.4 CrashAnalysis:LatestBusyBox(v1.36.1) pattern, a long repeated character, triggered deep recur- sion that caused stack exhaustion, leading to a segmenta- Following the collection ofcrashes forthe latestBusyBox tion fault. The crash pattern was /1((((.......12208 (v1.36.1)targetusingLLM-basedseedgenerationandCrash times/1.WepassedthiscrashpatterntoBusybox(v1.36.1) Reuse,weproceededwithmanualcrashtriaging.Duetothis awk and traced via gdb using gdb -args busybox awk process’sintensivetimeandresourcecommitments,welim- -f crash_pattern_file. It caused segmentation fault as itedourtriagingeffortsto15uniquecrashesthatresultedin showninFigure9. segmentationfaults.Crashesobtainedfromfuzzingcanoften Havingidentifiedthesegmentationfault,weinspectedthe appeardisorderedandincomprehensibleduetodatarandom- registervaluesusinggdbcommandsfollowedbydoingback- izationthroughvariousmutationstrategiesduringthefuzzing trace(bt).Theoutcomeofbtshowedtheissueofdeepre- process.Weattemptedtominimizethecrashsizetofacilitate cursion leadingtostackexhaustion asshown in Figure10, thetriagingprocess,makingitmorecomprehensible. which can lead to denial of service (DoS). We further ver- Additionally,itisimportanttonotethatBusyBoxrelieson ified it by installing the latest version of GLIBC from the GLIBC (GNU C),whichprovides standardC libraryfunc- sourcecodeandconfirmingreproducibility.Thisvulnerabil- tionsandsystemcallsforUnix-likeoperatingsystems.During ity is nearly identicalto CVE-2010-4051,whichaccording ourtriagingendeavor,weuncoveredspecificinputpatterns toRedHat[40]isduetoafailuretoconsidercrashofclient thattriggeredcrashesinvariousfunctionswithintheGLIBC application via regcomp. Unfortunately,even on the client library. These patterns were identifiedbytracing the crash sidewhereitisused,theprovidedpatternisnotverified.In causes using GDB. Out of the 15 crashes we triaged, we thisscenario,thepatternbeingsenttoregcomp()doesnot foundcrashesinGLIBCfunctions,includingfree, malloc, getverifiedbeforehand,asshowninFigure11. write, strlen, strdup, regex, and strftime. No- Using a similar approach to the one discussed above, tably,thecrashesinregex, and strftimecloselyresem- we analyzed a number of other crashes. One of the bled the known bugs documented as CVE-2010-4051 and other crashes was found in strftime was also DoS be-ure 14, with some cases showing higher performance and othersexhibitingnegligibledifferences.Furthermore,when consideringthenumberofexecutionsasshowninFigure15, itisevidentthatLLM-basedgeneratedseedsdonotintroduce significantoverheadinmostcases. TheLLM-basedtechniqueforgeneratinginitialseedsplays asupportiveroleinthefuzzingprocess,contributingquality anddiverseseedsthatenhancefuzzingperformance. How- ever,itiscrucialtonotethatthistechniquealoneisnotthe sole factor influencing the overall outcome. Various asso- ciated factors,contingent upon the specific target,must be considered.Theeffectivenessiscontingentuponthetarget type and the extent to which the initially provided diverse inputscontributetocodecoverage. TheprimaryfunctionofLLMinthisproposedtechniqueis toassistinproducinghigh-qualityanddiversifiedinitialseeds, therebypotentiallyenhancingfuzzingperformance.Theseed generation using LLM requires initialmanualintervention Figure10:Deeprecursioninregcomp to validate ifthe generatedseeds align withthe target’s re- quirements.Inthecaseofanewtargetinitiallyunknownto LLM,modeltrainingisessentialforthetarget-specificseed cause of invalid pointer to struct tm. The crash pat- format.However,thisrepresentsaninitial,one-timeeffort; tern sent to BusyBox awk applet was BEGINstrftime("", oncethemodellearnstherequiredseedformat,itexpedites "3333333333333333333"),leadingtoasegmentationfault the generation of diverse seeds suitable as potential initial causedby__strftime_internal(),asshowninFigure12. seedsforfuzzing.Thus,wecanleveragetheknowledgebase |
Similar to the case of regcomp, strftime is being called ofLLMmodels,ortrainthesemodelsaccordingtodifferent withinBusyBox,butthetheinputparametersbeingsentto targetrequirement.Therefore,thistechniqueisnotrestricted it is not being verified beforehand, leading to DoS. Other to the BusyBox and can be adapted for use with different crashesthatwereanalyzedhadresultedfromabnormalpat- targets. ternsinthecrashinputandthereforecouldnotbeconclusively Similarly,thecrashreusetechniqueproposedcan beex- identifiedassoftwarebugs. tendedtovarioussoftwarecomponentsacrossdifferenttar- gets. The technique isn’t limited to a particular target but 6 Applicabilityofproposedtechniques appliesuniversally.Itcanbeemployedinanyscenariowhere wehavepreviouslygatheredcrashdatabyfuzzingatargetand TheinitialproofofconcepttargetedtheBusyBoxawkapplet. aimtotestthevariantofthattargetbyreusingthosecrashes. Thissectionextendstheapplicationoftheproposedtechnique For instance, following the collection of crashes from the tootherBusyBoxappletsfoundinvariousolderversionsused testedsamplesofthedcapplet,akintotheapproachoutlined inreal-worldembeddedproducts,asdetailedinTable1.The inSection4.3fortheawkapplet,wereusedthesecrashesto fuzzing process,conducted over 48 hours. Apart from the testotherBusyBoxsamples.Thesesamplesincludeddifferent numberofcrashes,wealsoexaminedthenumberofcovered versions and architectures. We had a total of 2112 crashes edges(asshownfortheawkappletinFigure6)andthetotal frompreviouslytestedsamplesthatwereARM-basedBusy- numberofexecutions.Thisassessmentinvolvedtestingon Box targets. We reused these crashes to test if they could thedc,man,andashappletsalongwithawk. causecrashesinBusyBoxv1.36.1,whichisx86-based.Out Figure13illustratesvariationsinnumberofcrashdetected of2112crashes,853causedsegmentationfaultsinthisnew acrossdifferenttargets.Notably,usingLLM-generatedinitial target,with313beinguniqueoccurrences.Thus,usingthis seedsledtoasubstantialincreaseincrashesforcertaincases technique,weidentifiedthepossibilityofcrashesinanew likeawk,whilefordcandman,crashesweredecentlyhigher targetevenwithoutperformingactualfuzzingonit.Dueto withLLM-generatedseeds.Fortheashapplet,weconducted limitedtime,wedidn’tdelvedeeplyintothesecrashexplo- fuzzingfor5hoursduetoutilityexecutionconstraints. As ration paths. The primary goal is to convey that the crash aminimizedversionofbash,ashexecutesshellcommands. reusetechniquecouldbebeneficialfortheinitialscreening However,abnormalbehaviorduringfuzzing,triggeredbydi- ofanewvariantofasoftwarecomponentwithoutspending verseshellinputs,ledtothecessationoftheprocess.Conse- hoursonfuzzing.However,thistechniquemaynotuncoverall quently,weoptedforashortertestingduration.Thispattern thevulnerabilitiesrequiringfuzzingforathoroughanalysis. alsoextendstoedgecoverageperformanceasshowninFig- While crash replay has been established for analyzingFigure11:RegcompcalledinsideBusybox employthiscrash-reusetechniqueasaninitialscreeningto testforthepresenceofvulnerabilitiesinthegivenproduct. As illustrated in Figure 1, our work introduces a novel pipeline employing two techniques. In this pipeline,LLM- generated initial seeds (technique1) assists in enhancing fuzzingandacquiringcrashesforthetargetundertest.Subse- quently,theobtainedcrashesarecollectedandreused(tech- nique2)totestanewtargetwithsimilarsoftwarecomponents. 7 Discussion Inourpursuittoenhanceexistingsoftwaretestingmethod- Figure12:Crashinstrftimebecauseofinvalidargssendvia ologies,weemphasizethesignificanceofourproposedtech- BusyBoxawk niques,particularlywithinthecontextofembeddedsystems. Firmwareinembeddedsystemsoftenconsistsofnumerous third-party software components with custom implementa- crashes in previously fuzzed targets,there is limited exist- tionsanduniqueinputtypes,makingitpredominantlyablack- ingresearchoncollectingcrashesandreusingthemtotest boxtestingscenario.Thetechniquesintroducedinthiswork, variantofthesoftwarecomponentspresentindifferenttargets. namelyleveragingLLMforinitialseedgenerationandcrash Forinstance,differentproductsmayincorporatedifferentver- reuse,have exhibited promising outcomes that can signifi- sions of BusyBox. This distinction becomes crucial in the cantlyaidsoftwaretestingefforts.Whilethesetechniquescan context of embedded systems, where common third-party beadaptedforvarioustargetsasdiscussedinSection6,we software components like BusyBox are frequently shared. haveusedthemtoanalyzeBusyBoxfortheproofofconcept. However,thesecomponentsmaydifferinversionnumbers, Toevaluateourresults,weestablishedtheAFL++fuzzer’s architectures,orcompilationoptimizations. output as our baseline and compared outcomes between Thecrashreusebecomesparticularlyadvantageouswhen AFL++ provided with random initial seeds versus LLM- wehaveaccesstotheopen-sourceversionofspecificsoftware generatedinitialseeds.Despiteextensiveresearchleveraging componentsorlibraries.Byconductingfuzzingonthesecom- LargeLanguageModels(LLM)forfuzzing,asdiscussedin ponents,wecangeneratepotentialcrashes.Givenouraccess Section3andexemplifiedbystudieslike[18],wehavenoten- |
tothesourcecode,thelikelihoodofidentifyingthesecrashes counteredpriorworkapplyingLLMtoreal-worldembedded ishigher.Now,let’sconsiderascenariowherethesamesoft- devicesrunningapplicationslikeBusyBox.Table3illustrates warecomponentisinternallyusedinaproductforwhichwe variousstudiesleveragingLLMfordifferenttargets,making onlyhaveaccesstothebinary,notthesourcecode.Although directcomparisonsunfeasible. weareawarethatitinternallyemploysthesoftwarecompo- Similarly,regardingthecrashreusetechnique,wehaven’t nent,thereisapossibilitythatitsversionnumberdiffers,or identifiedanyworkcollectingandreusingcrashestotestsim- ithasbeencustomizedbythedeveloper,orcompiledfora ilarsoftware components on a different target,as depicted differentarchitecture.Insuchcases,wherewehavealready inFigure4.Earliermethodologies,likereFuzz[24],focused collectedcrashesfortheknownsoftwarecomponent,wecan onreusingcrashesandoutputswithinthesametargetduringFigure13:NumberofcrasheswithvswithoutLLMbasedinitialseeds.Thegraphsareforappletawk,dc,man,ashclockwise. differentstages offuzzing. AFL also provides a feature to by training the model for specific targets using previously resumethefuzzer,leveragingpreviouscrashesandqueuein- identifiedcrashes.Weexploredthefeasibilityoffine-tuning formationtoenhancefuzzingoutcomesonthesametarget. LLMbyprovidingsetsofcrashescorrespondingtorespective Crashesaretypicallyemployedforreplayduringtheanaly- targetcategories.WeaimedtoascertainwhetherLLMcould sisprocess.Therefore,forcomparisonpurposes,wesetthe generatetestcasescapableofinducingcrashesinthenewtar- baselineasidentifyingthenumberofcrashesdirectlyusing get.However,thisundertakingintroducedspecificchallenges, fuzzingversustestingthetargetagainstthecrashescollected primarilyrelatedtodataencoding.LLMrequiresdatatobe fromfuzzingthevariantofthattargetpreviously,asillustrated JSON-encoded,andmanagingdatathatcannotbeUTF-8en- inFigure8 codedprovedto be intricate. This challenge is particularly pertinent,assomecrashtestcasesmayinvolvedatatypesthat Nevertheless,itisessentialtoacknowledgecertainlimita- arenotUTF-8encoded. tionsandchallengesassociatedwiththeseapproaches.Utiliz- Insummary,whilethereareparticularchallengesandlim- ingLLMforinitialseedgenerationmaynecessitateasignifi- itations,substantialresearchpotentialexistsforharnessing cantinitialeffort,mainlywhendealingwithdifferenttargets, these techniques to enhance andassistsoftware testing en- especiallyinthecomplexdomainofembeddedsystemswhere deavors.Theseapproachesholdpromiseforimprovingthe awidearrayofhardwareprotocolsandcustominputpatterns efficiencyandeffectivenessoftestingprocedures,particularly areencountered.Furthermore,whilethecrashreusetechnique inthecontextofembeddedsystemsandfirmwareanalysis. representsavaluablefirstpassphase,itmaynotconsistently identifyallbugs,especiallyzero-dayvulnerabilities.Hence, atraditionalfuzzingtechniqueremainsanecessarycomple- 8 FutureWork mentforcomprehensivetesting.Thecrashreusemethodpri- marilyassistsindeterminingwhetherpreviouslyidentified Thisworkopensupopportunitiesforfurtherresearchbyex- crashesareapplicabletoanewtargetbutdoesnotguarantee tendingtheapplicationofLLMandcrash-reusetechniquesto the discovery of all potential bugs. Furthermore,there is a abroaderrangeoftargetswithinembeddedfirmware.Weplan prospectforutilizingLLMtogeneratehigh-qualitycrashes toimplementthesetechniquesonvariousothertargets,encom-Figure14: NumberofedgescoveredwithvswithoutLLMbasedinitialseeds. Thegraphsareforappletawk,dc,man,ash clockwise. passingapplication-leveltargetslikewebservers,network- hancethesoftwaretestingprocess.Ourinitialinvestigation related components,and bare-metal embedded targets that revealedtheprevalenceofolderversionsofBusyBoxinreal- interactwithhardwareandIoTprotocols.TrainingLLMto worldembeddeddevices,promptingustodelvefurtherinto understandtheinputstructuresofprotocolssuchasI2C,SPI, the analysis. This exploration ledto the developing oftwo UART,MQTT,Bluetooth,andotherscouldgreatlyenhance techniquestobolstersoftwaretestingefforts.Firstis,lever- fuzztestingforthesedevices.Securitytestingforembedded aging LLM for initial seed generation. This technique sig- targetspresentsnumerouschallenges[32],andincorporating nificantly improved the outcome of fuzzing by enhancing thesetechniquescouldbeinvaluable. thenumberofidentifiedcrashes,offeringamorecomprehen- Furthermore,manyembeddedtargetslackaccesstosource sive and effective testing approach. Second is,crash reuse code,andinsomecases,internaldetailsareundisclosed.In technique.Weleveragedpreviouslyobtainedcrashesinolder suchscenarios,thecrashreusetechniquecanbeavaluable versionsofBusyBoxtoassesstheirapplicabilitytothenewer resource.Bytestingunknowntargetsagainstexistingcrashes version.Thisapproachprovedsuccessfulwhenappliedtothe andevaluatingwhetheranyinputcancausethetargettocrash, latestversionofBusyBox,savingtimeandresourcesinthe thesetechniquescansignificantlyimprovethestateofsecurity testingprocess. testing for firmware. We are dedicated to exploring these Subsequently, we delved into the analysis, identifying techniquesfurtherandleveragingtheirpotentialtoenhance |
uniquecrashesusingAFLTriageandconductingmanualcrash securitytestingforawiderangeofembeddeddevicesinthe triagingusingGDBandGhidraon15oftheseuniquecrashes. future. Ourtriagingeffortsuncoveredcrashesthattriggeredissues withintheGLIBClibrary,acriticaldependencyforBusyBox. 9 Conclusion Theseissuesborearesemblancetopreviouslydocumented CVEs,underscoringthepersistentnatureofthesevulnerabili- In conclusion,ourexploration into BusyBox,driven by its tiesacrossdifferentversionsofGLIBC.Whiletheexploitabil- extensive presence in Linux-based embedded devices,has ityofthecrashesfoundinBusyBoxcouldnotbeconclusively yielded valuable insights and introduced techniques to en- determinedduetotimeconstraints,ourexplorationofBusy-Figure15:NumberofexecutionswithvswithoutLLMbasedinitialseeds.Thegraphsareforappletawk,dc,man,ashclockwise. Boxhasilluminatedtechniqueswithsignificantpotentialto [3] FabriceBellard.QEMU,afastandportabledynamictranslator. benefitsoftwaretestinginvariousdomains.Thefindingsfrom InProceedingsoftheAnnualConferenceonUSENIXAnnual thisresearchnotonlyshedlightonthesecuritylandscapeof TechnicalConference,ATEC’05,page41,Anaheim,CA,2005. BusyBoxbutalsoopenthedoortofurtherresearchandad- USENIXAssociation. vancementsinsoftwaretestingmethodologies.Moreover,as [4] TimBlazytko,CorneliusAschermann,MoritzSchlögel,Ali discussedinSection6,theproposedtechniquescouldbeap- Abbasi,SergejSchumilo,SimonWörner,andThorstenHolz. pliedtotargetsotherthanBusyBox. GRIMOIRE:SynthesizingStructurewhileFuzzing. In28th USENIX SecuritySymposium (USENIX Security19),pages 1985–2002,SantaClara,CA,August2019.USENIXAssocia- Acknowledgment tion. [5] MarcelBöhme,Van-ThuanPham,andAbhikRoychoudhury. WewouldliketoacknowledgeNetRiseteamforproviding Coverage-BasedGreyboxFuzzingasMarkovChain. IEEE uswithreal-worldembeddedfirmwaredatabaseandcloudre- TransactionsonSoftwareEngineering,45(5):489–506,May sourcetoperformapartoftheseexperiments.Wewouldalso 2019. liketothankNSFCHESTforfundingthisproject(Project# [6] LucianConstantin. BusyBoxflawshighlightneedforconsis- 1916741industryfunding). tentIoTupdates,September2021. [7] CVEdetails. Busybox:Securityvulnerabilities. References [8] YinlinDeng,ChunqiuStevenXia,HaoranPeng,Chenyuan Yang,and Lingming Zhang. Large Language Models Are [1] IoTAnalytics. StateofIoT2023:NumberofconnectedIoT Zero-ShotFuzzers:FuzzingDeep-LearningLibrariesviaLarge devicesgrowing16%to16.7billionglobally. LanguageModels. InProceedingsofthe32ndACMSIGSOFT [2] CorneliusAschermann,TommasoFrassetto,ThorstenHolz, InternationalSymposiumonSoftwareTestingandAnalysis, PatrickJauernig,Ahmad-RezaSadeghi,andDanielTeuchert. ISSTA2023,pages423–435,NewYork,NY,USA,July2023. NAUTILUS:FishingforDeepBugswithGrammars. InPro- AssociationforComputingMachinery. ceedings2019NetworkandDistributedSystemSecuritySym- [9] Yinlin Deng, Chunqiu Steven Xia, Chenyuan Yang, posium,SanDiego,CA,2019.InternetSociety. ShizhuoDylanZhang,ShujingYang,andLingmingZhang.Largelanguagemodelsareedge-casefuzzers:Testingdeep [24] QianLyu,DalinZhang,RihanDa,andHailongZhang.Refuzz: learninglibrariesviafuzzgpt. Aremedyforsaturationincoverage-guidedfuzzing. Electron- ics,10(16),2021. [10] XuechaoDu,AndongChen,BoyuanHe,HaoChen,FanZhang, andYan Chen. AflIot: Fuzzing on linux-basedIoT device [25] RuijieMeng,MartinMirchev,MarcelBöhme,andAbhikRoy- with binary-level instrumentation. Computers & Security, choudhury. LargeLanguageModelguidedProtocolFuzzing. 122:102889,2022. InProceedings2024NetworkandDistributedSystemSecurity Symposium,SanDiego,CA,USA,2024.InternetSociety. [11] AndreaFioraldi,DominikMaier,HeikoEißfeldt,andMarc Heuse. AFL++:Combiningincrementalstepsoffuzzingre- [26] VeraMens,UriKatz,TelKeren,SharonBriznov,andSachar search. In14thUSENIXWorkshoponOffensiveTechnologies Menashe. UnboxingBusyBox–14newvulnerabilitiesuncov- (WOOT20),page12.USENIXAssociation,2020-08,2020. eredbyClarotyandJFrog,September2021. [12] GNU. GDB:TheGNUprojectdebugger. [27] Barton Miller,Gregory Cooksey,and Fredrick Moore. An [13] Patrice Godefroid, Hila Peleg, and Rishabh Singh. empiricalstudyoftherobustnessofMacOSapplicationsusing Learn&Fuzz: Machine learning for input fuzzing. In randomtesting. OperatingSystemsReview,41:78–86,January 201732ndIEEE/ACMInternationalConferenceonAutomated 2007. Software Engineering (ASE), pages 50–59, Urbana, IL, [28] BartonMiller,LarsFredriksen,andBryanSo. AnEmpirical October2017.IEEE. StudyoftheReliabilityofUNIXUtilities. Commun.ACM, [14] Google. OSSfuzz. 33:32–44,December1990. [15] AbhilashGupta,RahulGopinath,andAndreasZeller. CLI- [29] BartonMiller,DavidKoski,CjinLee,VivekanandaMaganty, Fuzzer:Mininggrammarsforcommand-lineinvocations. In RaviMurthy,AjitkumarNatarajan,andJeffSteidl. FuzzRe- Proceedingsofthe30thACMJointEuropeanSoftwareEngi- visited:ARe-ExaminationoftheReliabilityofUNIXUtilities neeringConferenceandSymposiumontheFoundationsofSoft- andServices. January1998. |
wareEngineering,ESEC/FSE2022,pages1667–1671,New [30] BartonP.Miller,MengxiaoZhang,andElisaR.Heymann.The York,NY,USA,November2022.AssociationforComputing RelevanceofClassicFuzzTesting:HaveWeSolvedThisOne? Machinery. IEEETransactionsonSoftwareEngineering,48(6):2028–2039, [16] GrantHernandez. AFLTriage. June2022. [17] Jie Hu,Qian Zhang,andHeng Yin. Augmenting Greybox [31] Mitre. CWE-78:Improperneutralizationofspecialelements FuzzingwithGenerativeAI,June2023. usedinanOScommand. [18] LinghanHuang,PeizhouZhao,HuamingChen,andLeiMa. [32] MariusMuench,JanStijohann,FrankKargl,AurelienFran- LargeLanguageModelsBasedFuzzingTechniques:ASurvey, cillon,andDavideBalzarotti. Whatyoucorruptisnotwhat February2024. youcrash:Challengesinfuzzingembeddeddevices. InPro- ceedings2018NetworkandDistributedSystemSecuritySym- [19] MuhuiJiang,LinMa,YajinZhou,QiangLiu,CenZhang,Zhi posium,SanDiego,CA,2018.InternetSociety. Wang,XiapuLuo,LeiWu,andKuiRen. ECMO:Peripheral TransplantationtoRehostEmbeddedLinuxKernels. InPro- [33] netrise.io. Netrise|firmwaresecurity. ceedingsofthe2021ACMSIGSACConferenceonComputer [34] NSA. Ghidragithubrepository,2019. andCommunicationsSecurity,CCS’21,pages734–748,New York,NY,USA,November2021.AssociationforComputing [35] OpenAI. OpenAIAPI. Machinery. [36] OpenAI.GPT-4technicalreport.ArXiv,abs/2303.08774,2023. [20] RamanpreetKaur,Dušan Gabrijelcˇicˇ,andTomaž Klobucˇar. [37] OWASP. Bufferoverflowattack. Artificialintelligenceforcybersecurity:Literaturereviewand future researchdirections. Information Fusion,97:101804, [38] Van-ThuanPham,MarcelBöhme,AndrewE.Santosa,Alexan- 2023. druRa˘zvanCa˘ciulescu,andAbhikRoychoudhury.SmartGrey- boxFuzzing. IEEETransactionsonSoftwareEngineering, [21] DonggeLiu,JonathanMetzman,OliverChang,andGoogle 47(9):1980–1997,September2021. OpenSourceSecurityTeam. AI-Poweredfuzzing:Breaking thebughuntingbarrier. [39] FengQiu,PuJi,BaojianHua,andYangWang. CHEMFUZZ: LargeLanguageModels-assistedFuzzingforQuantumChem- [22] Qiang Liu,Cen Zhang,Lin Ma,Muhui Jiang,Yajin Zhou, istry Software Bug Detection. In 23rdIEEE International Lei Wu,Wenbo Shen,Xiapu Luo,Yang Liu,and Kui Ren. ConferenceonSoftwareQuality,Reliability,andSecurity.Ac- FirmGuide:BoostingtheCapabilityofRehostingEmbedded company.,ChiangMai,Thailand,October2023.IEEE. LinuxKernelsthroughModel-GuidedKernelExecution. In 202136thIEEE/ACMInternationalConferenceonAutomated [40] {RedHatProductSecurity}. CVE-2010-4051,October2010. SoftwareEngineering(ASE),pages792–804,November2021. [41] K. Y. Sim,F.-C. Kuo,and R. Merkel. Fuzzing the out-of- [23] ZheLiu,ChunyangChen,JunjieWang,MengzhuoChen,Boyu memorykilleronembeddedLinux:Anadaptiverandomap- Wu,XingChe,DandanWang,andQingWang. Testingthe proach. InProceedingsofthe2011ACMSymposiumonAp- Limits:UnusualTextInputsGenerationforMobileAppCrash pliedComputing,SAC’11,pages387–392,NewYork,NY, DetectionwithLargeLanguageModel,October2023. USA,March2011.AssociationforComputingMachinery.[42] SuhwanSong,ChengyuSong,YeongjinJang,andByoungy- pages417–428,NewYork,NY,USA,2022.Associationfor oungLee. CrFuzz:Fuzzingmulti-purposeprogramsthrough ComputingMachinery. inputvalidation.InProceedingsofthe28thACMJointMeeting [55] Xiaogang Zhu and Marcel Böhme. Regression Greybox onEuropeanSoftwareEngineeringConferenceandSympo- Fuzzing.InProceedingsofthe2021ACMSIGSACConference siumontheFoundationsofSoftwareEngineering,ESEC/FSE onComputerandCommunicationsSecurity,CCS’21,pages 2020,pages690–700,NewYork,NY,USA,November2020. 2169–2182,NewYork,NY,USA,November2021.Association AssociationforComputingMachinery. forComputingMachinery. [43] Prashast Srivastava, Hui Peng, Jiahao Li, Hamed Okhravi, [56] Xiaogang Zhu,Xiaotao Feng,Xiaozhu Meng,Sheng Wen, HowardShrobe,andMathiasPayer.FirmFuzz:AutomatedIoT SeyitCamtepe,YangXiang,andKuiRen. CSI-Fuzz: Full- FirmwareIntrospectionandAnalysis. InProceedingsofthe SpeedEdgeTracingUsingCoverageSensitiveInstrumentation. 2ndInternationalACMWorkshoponSecurityandPrivacyfor IEEE Transactions on Dependable and Secure Computing, theInternet-of-Things,IoTS&P’19,pages15–21,New 19(2):912–923,March2022. York,NY,USA,November2019.AssociationforComputing Machinery. [44] DaweiWang,YingLi,ZhiyuZhang,andKaiChen. Carpet- Fuzz:AutomaticProgramOptionConstraintExtractionfrom DocumentationforFuzzing. In32ndUSENIXSecuritySympo- sium(USENIXSecurity23),pages1919–1936,Anaheim,CA, August2023.USENIXAssociation. [45] JunjieWang,BihuanChen,LeiWei,andYangLiu. Skyfire: Data-Driven Seed Generation for Fuzzing. In 2017 IEEE SymposiumonSecurityandPrivacy(SP),pages579–594,May 2017. [46] JunjieWang,BihuanChen,LeiWei,andYangLiu. Superion: Grammar-AwareGreyboxFuzzing. In2019IEEE/ACM41st International Conference on Software Engineering (ICSE), pages724–735,May2019. [47] NicholasWells.BusyBox:Aswissarmyknifeforlinux.Linux J.,2000(78es):10–es,October2000. |
[48] ChunqiuStevenXia,MatteoPaltenghi,JiaLeTian,Michael Pradel,andLingmingZhang. Fuzz4All:UniversalFuzzing withLargeLanguageModels,January2024. [49] LuYan,ZhuoZhang,GuanhongTao,KaiyuanZhang,Xuan Chen,Guangyu Shen,and Xiangyu Zhang. ParaFuzz: An Interpretability-DrivenTechniqueforDetectingPoisonedSam- plesinNLP,October2023. [50] Chenyuan Yang,Yinlin Deng,Runyu Lu,Jiayi Yao,Jiawei Liu,ReyhanehJabbarvand,andLingmingZhang. White-box CompilerFuzzingEmpoweredbyLargeLanguageModels, October2023. [51] MichalZalewski. Americanfuzzylop-asecurity-oriented fuzzer. [52] CenZhang,MingqiangBai,YaowenZheng,YetingLi,Xiaofei Xie,YuekangLi,WeiMa,LiminSun,andYangLiu. Under- standingLargeLanguageModelBasedFuzzDriverGenera- tion,August2023. [53] Zenong Zhang, George Klees, Eric Wang, Michael Hicks, andShiyiWei. FuzzingConfigurationsofProgramOptions. ACMTransactionsonSoftwareEngineeringandMethodology, 32(2):53:1–53:21,March2023. [54] YaowenZheng,YuekangLi,CenZhang,HongsongZhu,Yang Liu,andLiminSun. Efficientgreyboxfuzzingofapplications in linux-basedIoT devices via enhanceduser-mode emula- tion. InProceedingsofthe31stACMSIGSOFTInternational SymposiumonSoftwareTestingandAnalysis,ISSTA2022, |
2403.05986 Integrating Static Code Analysis Toolchains Matthias Kern∗, Ferhat Erata§¶, Markus Iser‡, Carsten Sinz†, Frederic Loiret‡, Stefan Otten∗, and Eric Sax∗, ∗FZI Research Center for Information Technology, Karlsruhe, Germany †Karlsruhe Institute of Technology, Institut fu¨r Theoretische Informatik, Karlsruhe, Germany ‡KTH Royal Institute of Technology, Embedded Control Systems, Stockholm, Sweden §Yale University, Department of Computer Science, New Haven, USA ¶UNIT Information Technologies, Research & Development, Izmir, Turkey ∗{mkern, otten, sax}@fzi.de †{markus.iser, carsten.sinz}@kit.edu ‡floiret@kth.se §ferhat.erata@yale.edu Abstract—Thispaperproposesanapproachforatool-agnostic constrained to a specific set of tools and that support the and heterogeneous static code analysis toolchain in combina- replacement of them, are so-called tool-agnostic toolchains. tion with an exchange format. This approach enhances both Today, it is difficult to reuse configurations and to compare traceability and comparability of analysis results. State of the reports of different static code analysis tools (SCAT) since art toolchains support features for either test execution and buildautomationortraceabilitybetweentests,requirementsand theymostlyuseaproprietarydataformatforboththeanalysis design information. Our approach combines all those features results and the analysis configuration. Furthermore, they have and extends traceability to the source code level, incorporating its own strengths and developers must often aggregate the static code analysis. As part of our approach we introduce the analysis results of different analyzers to form an overall “ASSUME Static Code Analysis tool exchange format” that pictureofprogramquality[5].However,withoutstandardized facilitates the comparability of different static code analysis results.Wedemonstratehowthisapproachenhancestheusability exchange formats, it is not easy to combine their strengths. andefficiencyofstaticcodeanalysisinadevelopmentprocess.On Additionally, it is very common for tool vendors to offer the one hand, our approach enables the exchange of results and linkage between their own products, especially for web-based evaluationsbetweenstaticcodeanalysistools.Ontheotherhand, ones; nevertheless, tools of different vendors are required itenablesacompletetraceabilitybetweenrequirements,designs, within a toolchain. Besides, there are many tools without implementation, and the results of static code analysis. Within our approach we also propose an OSLC specification for static a possibility to link their data easily between each other. code analysis tools and an OSLC communication framework. To overcome aforementioned limitations, we propose a tool- Index Terms—Traceability, Interoperability, Static Analysis, agnostic and heterogeneous toolchain for SCAT. OSLC The rest of the paper begins by presenting the background and related-work of our approach in Section II. In Section III I. INTRODUCTION we give an overview of concepts through an exemplary use- case for “ASSUME Static Code Analysis Tool Exchange Highly automated vehicles with more than hundred electri- Format (ASEF)”, developed within the European ASSUME calcontrolunits(ECUs)andmillionsoflinesofcodearegood ITEA3 Project [1]. In Section IV we introduce technical examples of safety-critical, complex systems [2], [3]. In the conceptsimplementingthetoolchaininwhichanadaptercom- future,withthetechnologicaladvancesinautonomousdriving, munication framework based on OSLC and the ASEF Format the complexity of those highly automated mobility systems are presented, as well as an approach for static code analysis willincreasefurtherinthenumberofsensors,communication automationthatsupportstraceabiltytodesignartifacts.Finally pathways, and functionality. we give a conclusion and future work in Section V. Yet, there are many tools without any linkage to other ones building so-called “islands of information” [4]. This means II. BACKGROUNDANDRELATEDWORK the data produced by such tools has no traceable connection In this section, we present the basic concepts and technolo- between each other. In order to support the development of giesthatarenecessarytounderstandourwork.InSectionII-A, highly automated mobility systems in a safe and secure man- we give a quick introduction into static code analysis with ner, toolchains that give the possibility to trace and exchange three small examples to motivate the necessity of static code all design artifacts over the complete life-cycle are needed. analysis. In Section II-B, we describe the current literature on Suchtoolchainswouldenableadirectexchangeofinformation the traceability research to position our work in this area. In between different tools and thus enhance the traceability section II-C, we present OSLC, which builds technologically between the different sources of information. Standardized the base of our approach and is used to set up our toolchain exchange formats are crucial to the creation of tool adapters that addresses system development. Since one of the main which increase the interoperability among them and enhance contributionsofthisworkistheso-calledASSUMESCAtool the comparability of their outputs. Toolchains that are not exchangeformat(ASEF),inSectionII-D,weexplainaclosely relatedstandard,“StaticAnalysisResultsInterchangeFormat” This work was funded by German Federal Ministry of Education and Research(BMBF)undergrant#01IS15031AaspartofASSUME[1]project. (SARIF) and discuss how our format is complementary to 4202 raM 9 ]ES.sc[ 1v68950.3042:viXrathe SARIF. Finally, in Section II-E, we present common B. Traceability continuous integration (CI) technique that today does not Regarding the industrial tools and technologies on trace- support traceability to design artifacts and comparability of ability, modeling tools such as EMF [6] and SysML [7], different static code analysis tools. |
requirementinterchangestandard(ReqIF[8])andmanagement tools such as RMF1 and IBM Rational DOORS [9] provide A. Static Analysis someautomatedormanualmeanstospecifyandmanagetrace- Static code analysis involves methods and algorithms to ability.However,noneofthemprovidesintegrationwithstatic automatically proof the absence of specific types of unwanted analysis code analysis tools, especially on a heterogeneous behavior in a piece of code. Static analysis tools can calculate development and design environment. a combination of input parameters and an execution trace that leadtoaninvalidstateinaprogram.Suchinvalidstatesmight C. Open services for Lifecycle Collaboration (OSLC) includeundefinedbehavior,theviolationofcustomassertions Open services for Lifecycle Collaboration (OSLC)2 is an or the access of uninitialized memory. open community that defines specifications to link the data of 1) Undefined Behavior: Unspecified semantics where the differenttools,usedintheApplicationLifecycleManagement behavior of a programming language becomes unpredictable (ALM) [10] and Product Lifecycle Management (PLM) [11], are commonly known as undefined behavior. Such states are in order to directly support traceability. The OSLC specifi- unwanted and should not be reachable at all. In the piece cations build on REST [12], the W3C Resource Description of code shown in example 1, the removal of lines 2 and 3 Framework (RDF) and Linked Data3. leadstothereachabilityofanundefinedstate(consideringthe OSLC offers specifications for the requirement- semantics of the C programming language). management, the quality-management (QM) and the architecture-management. With the architecture-management Example 1: Undefined Behavior specification, data from modeling-tools can be mapped 1 int z ←a−b to resources. Data from testing tools can be mapped 2 if z =MIN INT then with the help of the QM specification [13]. However, a 3 handle invalid state() specification for mapping results of static code analysis tools 4 int y ←−z is missing. Therefore, a resource definition based on the QM specification and the ASEF format have been created as part 2) Custom Assertions: Code optimization can lead to ob- of our approach. This specification is shown more in detail fuscatedpiecesofcodethatarehardtocomprehendandverify. in the Section IV-C. Therearescenarios,wherecodeoptimizationisindispensable. Forseveraltools,therearealreadyOSLCadaptersavailable, Example 2 shows how developers can use a custom assertion liketheMatlabSimulinkintegrationfromAxelReichwein4 or to use static analysis to show that an optimized piece of code for Bugzilla, a bug-tracking tool5. still behaves exactly the same as the unoptimized variant. D. Static Analyis Results Interchange Format (SARIF) Example 2: Function Equivalence The Static Analysis Results Interchange Format (SARIF) is 1 int a←foo() astandardizedinterchangeformatthatenablestheaggregation 2 int b←foo optimized() of results of different analysis tools. SARIF was originally 3 static assert(a=b) developed by Microsoft and is currently being standardized by OASIS in the OASIS SARIF Technical Committee. The format addresses a variety of analysis tools that can indicate 3) UninitializedMemory: Workingwitholdorunstructured problems related to program qualities such as correctness, low-level code can be a challenge with respect to memory security, performance, compliance with contractual or legal management. Functional extensions might lead to non-trivial requirements,compliancewithstylisticstandards,understand- bugs which can not easily be discovered. Example 3 is an ability, and maintainability. There are several tools available abstract representation of a common situation. for the programming language C# as SDKs or Converters. Example 3: Access Uninitialized Memory Furthermore, there is a Viewer for Visual Studio extension 6. SARIF enhances the usability by combining and comparing 1 if init-condition then the result in a more easier way than the several competing 2 initialize memory static analysis tools 7. 3 do some processing and access memory 1https://www.eclipse.org/rmf/ While init-condition (see line 1) might hold when- 2http://open-services.net/software/ everneededintheoriginalversionofthesoftwarethisproperty 3http://open-services.net/ 4https://github.com/ld4mbse/oslc-adapter-simulink might get lost during a sequence of extensions and patches. 5http://wiki.eclipse.org/Lyo/BuildOSLC4JBugzilla Static code analysis tools can automatically trace execution 6https://sarifweb.azurewebsites.net/ paths to states where uninitialized memory is accessed. 7https://www.oasis-open.org/committees/tc home.php?wg abbrev=sarifE. Continuous integration with static code analysis tools switched every 333 ms. To make sure that the implementa- Current static code analysis tools like Astre´e8 from AbsInt tion satisfies the requirement, we have added assertions (via or Coverty Scan from Synopsys offer a Jenkins9 plugin that static_assert) to make sure that a switch occurs after between 250 ms and 500 ms and that the time increases in allowsusingthesetoolsbeforethebuildprocessstarts.Jenkins each iteration of the loop. itselfenablesacontinuousintegration.Theintegrationprocess, includingtestingandabuildprocess,isnormallytriggeredby 1 typedef enum { Off, On } state_t; a REST request. This request is normally sent out from a Git- 2 typedef short time_t; 3 repository manager, like GitHub or GitLab, after code was 4 extern time_t getTimer(); pushed to a specific git repository. However, traceability from 5 extern void setIndicatorLamp(state_t s); testing results to requirements or other design artefacts is not 6 7 int timerExpired(time_t start, time_t end, time_t diff) |
supported through Jenkins. Furthermore, Jenkins plugins are 8 { specific for each tool, so there is no standard that enables 9 return end-start > diff; a plugin for different static code analysis tools and offers 10 } 11 comparability between different analysis tools. 12 void process() 13 { III. CONCEPTANDUSE-CASE 14 time_t startTime = getTimer(), currentTime; 15 state_t light = Off; Tomotivateourapproachwepresentanillustrativeexample 16 while (1) { for the development of a functionality for a direction indi- 17 currentTime = getTimer(); cator lamp. This functionality could be run on an electronic 18 static_assert(currentTime - startTime >= 0); 19 if (!timerExpired(startTime, currentTime, 333)){ control unit (ECU). Direction indicator lamps or informally 20 continue; “blinkers” or “flashers” are blinking lamps mounted near 21 } the left and right front of a car and can be activated by 22 if (light == Off) { 23 setIndicatorLamp(light = On); the driver at a time to advertise intent to turn or change 24 } else { lanes towards that side. For direction indicator lamps exist 25 setIndicatorLamp(light = Off); regulations like the E/ECE/324/Rev.1/Add.47/Rev.12 - E/E- 26 } 27 static_assert(currentTime - startTime >= 250); CE/TRANS/505/Rev.1/Add.47/Rev.12 10. To find all necessary 28 static_assert(currentTime - startTime <= 500); regulations and requirements, requirement engineering tools 29 startTime = currentTime; as shown in Figure 2 can be used. In this regulation there is 30 } 31 } a requirement in section 6.5 that says “The light shall be a Listing1. DirectionindicatorlampCCode. flashinglightflashing90±30timesperminute”.Tofulfillthis requirement the functionality of the direction indicator lamp Due to an integer overflow bug, the implementation will is designed with a stateflow chart (cf. Figure 1). The design not work in all cases, in particular on a 32-bit platform. of the functionality could be done with design tools as shown E.g., if startTime = 32700 and currentTime has a in Figure 2. negativevalueduetoanoverflow,thenend-startinfunction timerExpired() will be a large negative value (due to integer promotion no overflow occurs in the subtraction), and it will take a long time (approx. 65 seconds) until a timer expiration is reported. This kind of overflow bug is not only of academic interest, but also of practical importance, as an incident from 2015 shows:EnginesoftheBoeing787Dreamlinercouldfaildueto loss of electric power after 248 days of continues operation11. Fig.1. Directionindicatorlampforacar. The fault was caused by a timer-related integer overflow bug Afterthesystemdesignthecodecanbewrittenorgenerated similar to that of the example above. during the implementation activity. A piece of software code The analysis of the code from Listing 1 belongs to analysis forthefunctionalityofthedirectionindicatorlampcouldlook activities, and many static analysis tools will be able to find like that shown in Listing 1. the bug in the implementation. Output from an analysis tool Here, we assume to have a hardware timer that is increased might look as in Example 4. every millisecond by one, and its value can be read out using Alltheseartifactsofourexampleshouldbetraceablewithin function getTimer(), which returns a signed short. To the proposed toolchain. Therefore we give here an exemplary achieve a blinking frequency of 1.5 Hz, the light should be overview of possible tools which allows us to manage and producethenecessaryresults.Anoverviewofthistoolchainis 8https://www.absint.com/astree/index.htm giveninFigure2.Tomakeaproofofconceptweimplemented 9https://jenkins.io/ 10https://www.unece.org/fileadmin/DAM/trans/main/wp29/wp29regs/2015/ 11See, e.g., https://arstechnica.com/information-technology/2015/05/ R048r12e.pdf boeing-787-dreamliners-contain-a-potentially-catastrophic-software-bug.Example 4: Analysis results. These concepts include the framework of our toolchain, the ASEF exchange format and a specification for static code 1 Assertion in line 18 failed: analysis tools based on the OSLC quality management speci- 2 startTime = 32452 fication. 3 currentTime = -32684 A. The OSLC adapter communication framework In the following section, the framework and its communi- a part of this concept (red shaded box in Figure 2). As a cation is described. Here, only the communication between technologytoimplementthetraceabilitylinksamongartifacts an integrated development environment (IDE) and a static weemployOpenServicesforLifecycleCollaboration(OSLC) code analysis tool is regarded (see red box in Figure 2). (cf. Section II). The requirement analysis activities can be In Figure 3, the communication between the IDE and the static code analysis tool is depicted. The static code analysis tool uses a client that manages the communication. For each communicationparticipantexistsagitrepository.Withinthese git repositories, the data is stored and version managed in a standardized format. In the case of C code the standardized format is the C code itself. In the case of the static code analysis, the analysis report is stored in the tool independent ASEF exchange format. Through the git repository, only checkedinversionsarelinkedwithinthetoolsinthetoolchain. The adapters “Code Adapter P1” and “Analysis Adapter P2” parses the data from the git repositories into the Linked Data format namely “Resource Description Framework” (RDF). Theadaptersaretriggeredeverytimeanewversionispushed into the corresponding git repositories. During parsing, they linkthecorrespondinginformationofthedifferentadapters.In this case, the information of the analysis report is linked with theCcode.Theparticipantscanretrievethelinkedinformation Fig.2. Toolchain viathebothadapters.Theadapterswereimplementedwiththe |
supportedwithIBMRationalDoorsNext12orPTCIntegrity13. help of the model based development tool “Lyo Modeller”. The design activity could be supported with Matlab Simulink from MathWorks14 or Enterprise Architect from SparxSys- tems15. With Matlab Simulink, the behaviour of systems can be modeled and simulated. The architectural description of a system can be described with Enterprise Architect, which supports Unified Modeling Language (UML) and Systems Modeling Language (SysML). For the software implementa- tion we suppose an integrated development environment like Visual Studio from Microsoft or Eclipse from the Eclipse Foundation. For the static code analysis, Astre´e from AbsInt or QPR Refine from QPR Technologies could be used. Both tools use abstract interpretations of C code to detect runtime Fig.3. Communicationframework errors,dataracesorassertionviolationsandincludesaMISRA B. The ASEF Format Cchecker16.Inthebox“Analysis”inFigure2twostaticcode TheASSUMESCAtoolexchangeformat(ASEF)offersan analysis tools can use the ASEF format (cf. Section IV-B) to XMLschemaforatool-agnosticconfigurationformatinstatic produce comparable results. However, only one analysis tool code analysis and for the reporting of analysis results. We is adapted here in our toolchain. developed ASEF Format aiming at tool-interoperability and facilitating well-defined check-semantics. The format is ex- IV. TECHNICALCONCEPTS tensibleandallowstool-dependentconfiguration.Theschemes To show the process behind the scenes of our toolchain the and the documentation are available on the following pages: mostimportanttechnicalconceptsarepresentedinthissection. http://assume-project.github.io/download.html 12https://www.ibm.com/us-en/marketplace/rational-doors 1) ASEF Configuration Format: The ASEF configuration 13https://www.ptc.com/en/products/plm/plm-products/ is split into a global part and a local part, in which the global 14https://www.mathworks.com/products/simulink.html 15https://www.sparxsystems.eu/start/home/ part is intended to contain the main configuration that can 16https://www.misra.org.uk/Activities/MISRAC/tabid/160/Default.aspx be shared across multiple hosts, whereas specific hosts areable to adapt the local part of the configuration to their needs. previously defined targets, they specify which checks should Listing 2 shows a small example of an ASEF configuration. be executed with which hardware and language configuration The configuration allows the definition of source modules, etc. hardware targets, language targets and check targets. Source 2) ASEF Report Format: The analysis reports involve modules define the files to analyze. Hardware targets define source locations, failure traces, and check semantics. hardwarespecificpropertiessuchaspointersizeorendianness. Locations define the row and column where a fault was Language targets define details about the language standard detected and are assigned to the checks via identifiers. It is and system to be checked. alsopossibletoreferfromalocationtoanother.Thisisuseful todescribeso-calledmacrolocations,becausemacroscanuse <asef:Configuration xsi:schemaLocation=”ASC3F.xsd”> <asef:GlobalConfiguration> code from other files or locations. <asef:CommonConfiguration> A check status can be safe, unsafe, undecided, warning, <HardwareTargets> <HardwareTarget xsi:type=”asef:HomogenousHardwareTarget” andsyntacticviolation.Thecheckcategorydescribesthekind name=”generic32” endianness=”big” pointerSize=”32”/> of fault. Table I shows a small excerpt of the hierarchy of </HardwareTargets> <LanguageTargets> ASEFcheckcategoriesandhowthecategoriesmaptothoseof <LanguageTarget xsi:type=”asef:CLanguageTarget” name=” various static analysis tools. ASEF offers well-defined check basicC11” standardRevision=”C11” /> </LanguageTarget> semantics and thus enables comparability of the results of the </LanguageTargets> different static analysis tools. <CheckTargets> <CheckTarget xsi:type=”asef:CCheckTarge” name=”base”> <CorrectnessCheckCategory name=”assert”/> TABLEI <CorrectnessCheckCategory name=”numeric”/> ASEFCHECKSEMANTICSVS.NATIVECATEGORIESOFVARIOUSTOOLS <CorrectnessCheckCategory name=”controlflow”/> (INCLUDINGPOLYSPACE(PS)CHECKCATEGORIES,QPRCHECK <CorrectnessCheckCategory name=”mem”/> CATEGORIESANDASTREE(AS)ALARMCATEGORIES) </CheckTarget> </CheckTargets> ASEFCategory NativeCategories <ExecutionModelTargets> <ExecutionModelTarget xsi:type=” numeric.overflow PS:OVFL, AS:”Overflow in arithmetic”, asef:CSynchronousExecutionModelTarget” name=”sync”> AS:”Initializerrange” <EntryPoints> numeric.overflow.int QPR:arithmetic.overflow,QPR:shift.overflow <EntryPoint>main</EntryPoint> </EntryPoints> numeric.shift PS:SHF </ExecutionModelTarget> numeric.shift.rhs AS:”Wrongrangeofsecondshiftargument” </ExecutionModelTargets> numeric.shift.rhs.amount QPR:shift.by.amount <SourceModules> numeric.shift.rhs.negative QPR:shift.by.negative <SourceModule name=”main” rootUri=”$Repository$”> <SourceFiles> mem PS:COR <SourceFile uri=”example.c” id=”1”/> mem.ptr.deref PS:IDP,QPR:pointer.dereference </SourceFiles> mem.ptr.deref.misaligned AS:”Dereferenceofmis-alignedpointer” </SourceModule> mem.ptr.deref.invalid AS:”Dereferenceofnullorinvalidpointer” </SourceModules> mem.ptr.deref.field AS:”Incorrectfielddereference” <AnalysisTasks> <AnalysisTask name=”analyzeMainSourceModule”> <HardwareTarget>generic32</HardwareTarget> <SourceModule>main</SourceModule> |
<LanguageTarget>basicC11</LanguageTarget> C. ProposalofanOSLCspecificationforstaticcodeanalysis <CheckTarget>base</CheckTarget> data and results exchange <ExecutionModelTarget>sync</ExecutionModelTarget> </AnalysisTask> </AnalysisTasks> Figure 4 shows the resource definition based on both the </asef:CommonConfiguration> OSLC quality management (QM) specification and the ASEF </asef:GlobalConfiguration> <asef:LocalConfiguration> format. This definition was used to create the OSLC adapter <URISubstitutionRules> to link the analysis information with the files and to offer <URISubstitutionRule token=”$Repository$” substitution=” /local/path/to/repositories”> an analysis case that enables the configuration for the static </URISubstitutionRules> code analysis via OSLC. In the following, the proposed </asef:LocalConfiguration> </asef:Configuration> specification is explained in detail. The orange boxes in Figure 4 represent resources that are Listing2. ASEFExampleConfiguration adapted from the OSLC QM specification. The new name of Via check targets, several check categories define which the adapted resources stands in brackets behind the original checks should be executed. One of the key-strength of ASEF name. The grey boxes represent resources based on the ASEF lies in the precise specification of the check semantics. As format. In the following, these resources are explained more differentstaticanalysistoolsofferdifferentstagesofprecision in detail. in various check categories there was a need to define these The Analysis Case is linked with all files that should levelsofprecision.TheyareusedintheASEFReportswhena be analyzed and contains the configuration for the static code flaw was discovered. More details about check semantics can analysis. The Analysis Result bunches all so-called be found in Section IV-B2. Checks of one ASEF analysis report. There can be different The execution of checks is triggered through the definition AnalysisResultsfordifferentversionsofthesourcecodefiles. of analysis tasks. Analysis tasks are a combination of the One Analysis Result refers to a specific Analysis9)GitLabtriggerstheanalysisadapter,aftertheanalysisclient pushed the analysis report into the analysis repository; 10) The analysis adapter parses the information of the analysis reportintoLinkedDataresourcesandlinkstheresourcesofthe Locations with the Files provided by the Code Adapter P1.Afterwardsthedevelopercanuseafront-endtogetaquick overview of the analysis results (cf. Figure 2) V. CONCLUSIONANDFUTUREWORK In this paper we introduced the necessity for improved traceability from the requirements downwards to static code analysis within a heterogeneous and tool-agnostic toolchain. StartingwiththeintegrationofourapproachintotheV-model, the state of the art and an overview about related work, we showthegapsofcommonsolutionsandmotivateourapproach with an use-case of a direction indicator lamp. The approaches to enhance the traceability and the us- ability are presented as well as a technical concept with a new static code analysis exchange format, namely ASEF, a communication framework, and an OSLC specification to implement an adapter for static code analysis tools. Up to now, our implementation create linkages between code and staticanalysisresults.Forfutureworkwearegoingtoaddnew Fig.4. ProposalstaticcodeanalysisOSLC-Specification toolstoprovetheusabilityandtraceabilityofourconcepts.We Case. Checks contain the type of a detected fault at a spe- demonstrated that the ASEF format brings several advantages cificlocationinthecode.Thereisalinktothelocation,where such as the possibility to configure static code analysis tools the fault occurs. A Location gives the line and column in a uniform way. Nevertheless, we aim to show whether our number in the code where a problem or fault was located. approach can work also with the SARIF Standard to reach a The Location is linked with the appropriate file, or with larger community. another Location in the case that the Location is a so- REFERENCES called macro. Through the presented linkage the Analysis [1] ITEA,“ASSUME:AffordableSafe&SecureMobilityEvolution,”https: Cases are traceable from their results up to the source code //itea3.org/project/assume.html,Sep2015. of a specific version. [2] G.Macher,M.Bachinger,andM.Stolz,“Embeddedmulti-coresystem for design of next generation powertrain control units,” in 2017 13th EuropeanDependableComputingConference(EDCC),Sept2017,pp. D. Approach for a static code analysis automation process 66–72. In this section, an approach for an automation process [3] J.Mo¨ssinger,“Softwareinautomotivesystems,”IEEESoftware,vol.27, no.2,pp.92–94,March2010. of the static code analysis within the toolchain is proposed. [4] J.El-khoury,D.Gu¨rdu¨r,andM.Nyberg,“Amodel-drivenengineering This process is oriented at the communication framework (cf. approachtosoftwaretoolinteroperabilitybasedonlinkeddata,”vol.9, Figure 3) and is divided into the ten following steps: 1) A pp.248–259,012016. [5] A.Fatima,S.Bibi,andR.Hanif,“Comparativestudyonstaticcodeanal- developer push files from an IDE into a git repository; 2) ysis tools for c/c++,” in 2018 15th International Bhurban Conference GitLab, that manages this git repository, triggers the analysis onAppliedSciencesandTechnology(IBCAST),Jan2018,pp.465–469. Clientviaaso-calledwebhook;3)TheAnalysisclientrequests [6] D.Steinberg,F.Budinsky,E.Merks,andM.Paternostro,EMF:Eclipse ModelingFramework. PearsonEducation,2008. the new files from the Code Adapter P1, stores them locally [7] M. Soares and J. Vrancken, “Model-driven user requirements specifi- |
and looks which analysis cases are affected through the cation using SysML,” Journal of Software, vol. 3, no. 6, pp. 57–68, changed files of the current commit; 4) The Analysis Client 2008. [8] A.Graf,N.Sasidharan,andO¨.Gu¨rsoy,Requirements,Traceabilityand runsforeachaffectedAnalysis Casetheanalysis;5)The DSLs in Eclipse with the Requirements Interchange Format (ReqIF). Analysis Client reads the configuration from the Analysis Springer Berlin Heidelberg, 2012, pp. 187–199. [Online]. Available: Cases and changes the path for the analysis to the local http://dx.doi.org/10.1007/978-3-642-25203-7 13 [9] IBM,“RationalDOORS:Arequirementsmanagementtoolforsystems stored C language files; 6) The Analysis Client starts the andadvancedITapplications,”2011. static analysis tool via an API; 7) The static code analysis [10] D.Chappell,WhatisApplicationLifecycleManagement? Chappell& toolanalysisthefilesdefinedintheanalysisconfigurationand Associates,2008. [11] M.EignerandR.Stelzer,ProductLifecycleManagement:einLeitfaden produces an analysis report in the ASEF format and sends a fu¨rProductDevelopmentundLifeCycleManagement,2nded. Berlin: ready acknowledgment to the analysis client; 8) The Analysis Springer,2009. Client replaces in the analysis report the local files with the [12] S.Patni,“Prorestfulapis:Design,buildandintegratewithrest,json, xmlandjax-rs,”Berkeley,CA,2017. Unified Resource Identifier (URI) to the files in the Code [13] “Oslc specifications,” http://open-services.net/specifications/, 2018, ac- Adapter P1 and pushes the report into the analysis repository; cessed:2018-08-29. |
2403.08799 AUTOMATING SBOM GENERATION WITH ZERO-SHOT SEMANTIC SIMILARITY DevinPereira,ChristopherMolloy,SudiptaAcharya,StevenH.H.Ding SchoolofComputing Queen’sUniversity Kingston {devin.pereira, chris.molloy, s.acharya, steven.ding}@queensu.ca ABSTRACT Itisbecomingincreasinglyimportantinthesoftwareindustry,especiallywiththegrowingcomplexity ofsoftwareecosystemsandtheemphasisonsecurityandcomplianceformanufacturerstoinventory softwareusedontheirsystems. ASoftware-Bill-of-Materials(SBOM)isacomprehensiveinventory detailingasoftwareapplication’scomponentsanddependencies. Currentapproachesrelyoncase- basedreasoningtoinconsistentlyidentifythesoftwarecomponentsembeddedinbinaryfiles. We proposeadifferentroute,anautomatedmethodforgeneratingSBOMstopreventdisastroussupply- chainattacks. Remainingonthetopicofstaticcodeanalysis,weinterpretthisproblemasasemantic similaritytaskwhereinatransformermodelcanbetrainedtorelateaproductnametocorresponding versionstrings. Ourtestresultsarecompelling,demonstratingthemodel’sstrongperformanceinthe zero-shotclassificationtask,furtherdemonstratingthepotentialforuseinareal-worldcybersecurity context. 1 Introduction Throughoutthepastdecade,majorsecuritybreacheshavebeencausedbymaliciouscodeembeddedinfirmware,atype ofsoftwarethatdirectlyinteractswithhardware. Attacksonfirmwarecanbeparticularlyrevealinganddestructive,as firmwarehashighprivilegesoverotheraspectsofcomputersystems. Recently,thedevastatingeffectsofexploiting firmware vulnerabilities were evidenced by the SolarWinds supply chain attack [1], an attack that compromised thousandsoforganizationsaroundtheworld,includingtheUnitedStatesgovernment. Asupplychainattackconstitutesasecuritybreachwhereamaliciousentityexploitsvulnerabilitieswithinthird-party softwaretogainunauthorizedaccesstothetargetedsystemratherthanattemptingadirectbreachofthetargetsystem itself. Supply chains associated with contemporary software systems are evolving into more intricate structures, contributingtoincreasedopacityandmakingthemsusceptibletosuchattacks. Itfollowsthatithasbecomeextremely difficulttoidentifywhichcomponentsarepresentinaparticularpieceofsoftware[2]. Theproblemfindsitssourcein thesoftwareengineeringpracticeofcodereuse. Sincethiscustomisunlikelytobeabandoned,analternativeapproach topreventsupplychainattacksisrequired. In 2018, the National Telecommunications and Information Administration of the United States Department of Commerce (NTIA) formed a working group that proposed the Software-Bill-of-Materials (SBOM). Concisely, an SBOMprovidesdetailsaboutallthecomponentspresentinagivenpieceofsoftware. SBOMsdetailinformation suchasthesoftwaresupplier,thecomponentnamesandversionspresent,aswellastherelationshipsbetweenthese components. However,itisimportanttonotethatSBOMsdonotguaranteesecuritythroughoutthesupplychain. AnSBOMisnot applicableagainstzero-dayexploits,norcanitbeusedtoflagasecurityflawbeforeitisreportedtoavulnerability database[3]. Nevertheless,thesimplestapproachtoderiveanSBOMistousetherelevantpackagemanagertolista software’sdependencies. Thoughsimpleandhighlyeffective,itrequiresknowledgeofthepackagemanagerusedfor installation. Evidently,thetechniquedoesnotworkforsoftwareinstalledwithoutapackagemanager. 4202 beF 3 ]ES.sc[ 1v99780.3042:viXraAutomatingSBOMGenerationwithZero-ShotSemanticSimilarity ThealternativeprocedureofderivinganSBOMfromasoftware’ssourcecodeisequallyreliable. However,themain limitationofthisapproachisthatsourcecodeisnotguaranteedtobeavailable. Ingeneral,itisnearimpossibletolocate sourcecodeforaspecificbinary,particularlyinthecaseoffirmware,whichoftenispreinstalledonsystems[3]. There isasalientneedforatoolcapableofproducingSBOMsusingonlycompiledbinaries. Suchatoolcouldguaranteethe integrityofvendor-generatedSBOMsandprotectagainsttamperingbyadversaries,i.e.,aman-in-the-middleattackin whichasoftwareismaliciouslymodified,butitsSBOMdeceitfullyremainsthesame. Henceforth,werefertoSBOMgenerationtoolsasutilitiesforderivingSBOMsfrombinaries. Toolsliketheseexistbut havethedrawbackofrelyingoncase-basedreasoning. Infact,manyofthemrequirepredetermineduniquepatternsfor matchingstringstoaspecificsetofsoftwareproducts. Toremedythisissueatscale,weelecttoimplementamachine-learningsolutionformatchingversionstringstosoftware products. Wedemonstratethatthisproblemcanbesolvedusingmodernnaturallanguageprocessingtechniques. Our transformermodelistaskedwithdeterminingthesemanticsimilaritybetweenasoftwareproductnameandtheversion stringsembeddedinsoftwarebinaries. Themostsimilarsoftwareproducttotheversionstringisthenselectedasthe network’sprediction. WeintendthatthesepredictionsbeusedasinputfortheautomatedgenerationofSBOMsandto queryvulnerabilitydatabasesifthereareCVEscorrespondingtothatparticularproduct. Weshowourmodel’sability forzero-shotinferencebytestingitsdetectionaccuracyonmultiplesoftwareversionsnotencounteredintraining. Our contributionscanbesummarizedasfollows: • WeproposethefirsttransformermodeloptimizedfortheSBOMgenerationtask.Asopposedtoanaivepattern- matchingoperation,identifyingsoftwaremodulesisformulatedasasemantic-similarity-basedclassification task. • Bywayofzero-shotinferenceexperiments,wedemonstratethatourmodel,despitebeingtrainedonafew |
classes, can be applied successfully with only a small degradation in performance when compared to a state-of-the-artmodeltrainedonallavailableclasses. Theoutcomeunderscoresourmethodasbeingeffective inpracticalcybersecuritycontexts. The paper’s structure is as follows. The Related Works section highlights a series of studies from which we draw inspiration. TheSimilarityLearningforVersionDetectionsectioncontainsthepreparationofourdataset,adescription of the data employed, and a illustration of our model. In Experimental Setup and Results section, we explain our experimentsanddescribeourinterpretationoftheresults. Finally,thepaperconcludesandprovidespotentialscopesfor futureworksinConclusionandFutureworkssection. 2 RelatedWorks Inthissection,wereviewthecurrenttoolsforgeneratingSBOMs. Weappraisestudieswhereintransformermodels havebeeneffectivelyemployedforpatterndetection. Finally, wepresentapproachestoclassificationtaskswhich involvezero-shotlearning. 2.1 SBOMGenerationTools Intel’s open source CVE-bin-tool is a widely used software analysis program which employs a binary scanner to determine which software versions are embedded in a binary file and subsequently maps these versions to known vulnerabilitiesintheNationalVulnerabilityDatabase[4]. DoanandJungemployCVE-bin-tooltodevelopDAVS–A Dockerfileanalysis-basedvulnerabilityscanningframework[5]. Theirapproachaimstocreateamethodologyforvulnerabilitydetectionthatisnotrestrictedbytheabilityofpackage managerstoextractinformation. Afterdeterminingpotentiallyvulnerablefilesthroughpreliminarydockerfileanalysis, theymakeuseofCVE-bin-tooltodetectsoftwareversions,linkingthemtovulnerabilities. Reinholdetal. comparethe resultsproducedbydifferentversionsofCVE-bin-toolon660binaryfiles[6]. Theyobservethatonly1outofthe660 binaries(excludingnullresults)producesanoutputconsistentacrossthedifferentversionsthetool. Thisoutcomeraises additionaldoubtsaboutthereliabilityofthecase-basedapproachandunderscoresthenecessityforanewparadigm. 2.2 TransformerModels Verylittleresearchaddressestheproblemofdeterminingthesimilaritybetweenpseudo-Englishwords. Suchisthe natureofthetaskincomparingacollectionofversionstringsderivedfrombinaryfilestosoftwarenames. However,the currentstate-of-the-artclassofmodelshasbeenusedextensivelyforclassificationtasks,whichweconsidertobea relatedproblemtypetosemanticsimilarity. Shaheenetal. demonstratetheefficacyofusingtransformermodelsintext 2AutomatingSBOMGenerationwithZero-ShotSemanticSimilarity Generate Strings Filter by Extract ELF Regex conan.io files Data Point oldversion.com + Product: 'pdns' + Package Name: 'pdns-backend-lua2_4.7.3-2_amd64' + File: '/usr/lib/x86_64-linux-gnu/pdns/liblua2backend.so' + Valid Version Strings: ['[lua2backend] This is the lua2 backend version 4.7.3'] debian.org Figure1: Binariesobtainedfromdifferentsourcesarepassedthroughextractionscripts. Next,stringsaregenerated fromtheresultantELFfiles. Finally,thesestringsarefunneledthrougharegular-expressionbasedfilteringscript. The finaldatapointscanbeobservedasatuplewithfourdifferentfields. classification[7]. Toachievestate-of-the-artresultsinLargeMulti-LabelTextClassification(LMTC),theycompare differentmodelsalongsidevariousstrategiessuchasgenerativepretraining,gradualunfreezing,anddiscriminative learningrates. Acrossthedifferentdatasets,BERT(BidirectionalEncoderRepresentationsfromTransformers)variants wereobservedtoyieldthebestresults. Interestingly,theresearchersnotethatmultilingualBERTtrainedonlyinEnglish data yields results on par with the others when presented with texts from other languages. This indicates BERT’s zero-shotlearningcapabilities. BERTisthecurrentstate-of-the-artembeddingmodelfornaturallanguageintroducedbyDevlinetal.[8]. Theirnovel bidirectionalattentionmodelallowsforlearninginformationfromatextbothlefttorightandrighttoleft. Inorderto developadeepbidirectionalrepresentation,theresearchersmasksomepercentageoftheinputtokensatrandomduring trainingandthenpredictthemaskedtokens. Thisprocedureisknownasmaskedlanguagemodeling(MLM).Prior left-to-right-onlyapproachesrestrictedmodelstounidirectionallearning. BERThasshowntobeseminalasitcanbe usedasafoundationforothermodels. Fine-tuningcanbeachievedwithaslittleasoneadditionaloutputlayertocreate state-of-the-artmodelsforspecializednaturallanguagetasks. In the year following the release of BERT, Nils Reimers and Iryna Gurevych proposed a method to increase the efficiencyofBERTinasentencesimilaritytask.[9]. Themotivationbehindtheirimprovementrelatestoashortcoming ofBERT:itscross-encodersetupisunsuitableforavarietyofpairregressiontasksduetotheexcessivenumberof possibleoutputcombinationsitallows. Instead,theresearchersdevelopaSiamesenetworkarchitecturewhichenables thederivationoffixed-sizedvectorsfrominputsentences. Thesefixed-sizevectorscanbeviewedassemantically meaningfulsentenceembeddings. Theyassertthat,inatasktodeterminethesimilaritybetween10,000sentences,the necessarycomputationtimeisreducedfrom65hourswithBERT,toaround5secondswithS-BERT.Inbrief,their improvedmodeldrasticallyreducesthecomputationaloverhead,therebyimprovingthetimetakentodeterminethe mostsemanticallysimilarpairofsentences. Simultaneously,theirmethodalmostperfectlymaintainsthenearstellar accuracyofBERT. 2.3 Zero-shotLearning |
Theformalizationofzero-shotlearningisattributedtoPalatuccietal. Theseresearchersintroduceaso-calledsemantic output code classifier, which infers a knowledge base of semantic properties from samples in a training set. They demonstratethattheirclassifiercanaccuratelypredictoutputsfromnovelclasses,emphasizingtherelevanceofthetask whenoutputshavethepotentialtotakeonalargenumberofdifferentvalues,aswellaswhenthecostofobtaining labeleddataishigh. Themodelusedintheirexperimentsismadetopredictwordsusingfunctionalmagneticresonance imagesfromhumanparticipants. Theyjustifythenecessityoftheirnovelprocedurebystatingthatdeterminingneural trainingimagesforeveryEnglishwordinexistenceisintractable. Overtwosemanticknowledgebases,human218 andcorpus5000,theirmethodobtainsmeanaccuraciesof80.9%and69.7%,respectively. Theseresultswereshown 3AutomatingSBOMGenerationwithZero-ShotSemanticSimilarity tobepowerful,despiteoriginatingfromthebrainwavesofonlynineparticipants. Fromitsinception,theconceptof zero-shotlearningwaslinkedtoclassificationtaskswithasemanticcharacter.[10] ZimingZhangandVenkateshSaligramadescribethezero-shotlearningproblemfromanalternativeperspective. They viewtargetdatainstancesasarisingfromobservedinstances,attemptingtoexpresssourceandtargetdataasamixture ofobservedclassproportions. Theirideais,ifthemixtureproportionfromthetargetdomainissimilartothatfrom thesourcedomain,thetargetandsourcenecessarilyoriginatefromthesameclass. Consequently,theyformulatethe problemaslearningsourceandtargetdomainembeddingfunctionsusingobservedclassdata. Thesefunctionsare designedtomaparbitrarysourceandtargetdomaindataintomixtureproportionsofobservedclasses. Theirmethod involvingsemanticsimilarityembeddingfunctionsimprovesthestate-of-the-artaccuracyCIFAR-10to88.3%amongst otherbenchmarks.[11] 3 SimilarityLearningforVersionDetection 3.1 DataPreparation Werequireadatasetofvaryingsoftwareproductsandversionstringsfortrainingournetwork. Wecollectproductand versioninformationfromPortableExecutable(PE)andExecutableandLinkableFormat(ELF)filetypebinaries. The PEformatusedbyWindowsspecifiesthestructureofexecutablefiles(.exe)andDynamicLinkLibraries(DLLs),which arelinkablesoftwarepackages. ThoughtherearemanyotherfiletypeswhichfallunderthePEumbrella,wecollect onlythesetwoinourdataset. Notethatthesearedesignedformanyarchitecturese.g. x86,arm,amd64,etc. Analogous toPEbutconceivedforUnixsystems,theELFformatiscommonlyusedforexecutables,objectcode,sharedlibraries, andmore. Weobtainourfilesfromtwosources: conan.ioanddebian.org. Inthecaseofconan.io,wequerytheconan-centerto downloadfilesfromover1500differentlibraries. WeselectonlythePEandELFfilesfromthedownloadeddirectory. Thislistoffilesiscomparedtothereferencefilepathsinthecachetoavoidduplication,renamed,andfinallyplacedin thedataset. Theprocedureisnearlyidenticalforthedebianpackages. OncetheEFLfilesoriginatingfromallsourcesaregathered,theyaretransformedintostrings,simplyusingtheUnix stringscommand. Withinthesestrings,weconsideronlythestringsthatmatchageneralregularexpressionorversion stringpattern. Fromthemetadataintherepository,weobtainapackagenamethatcontainstheversionofthesoftware. Thisversionnumberisusedasagroundtruthtolabeleachversionstring. Theproductissimplythenamefromthe conanordebianpackagecatalogue. 3.2 DataDescription ThoughSBOMscontainmanyotherfields,wedeemmostoftheseirrelevanttoourresearch. TheSPDXformat,the standardstructureforSBOMs,wasoriginallyconceivedtomanageproductlicensinginformation[12]. Hence,manyof thesefieldsarenotpertinenttovulnerabilityanalysiswhichweconsidertobetheprimarypurposeofSBOMsinour study. Forexample,relationshipsbetweencomponentsarenotrecorded,ourmethodonlyidentifiesthecomponents whicharepresentinthepieceofsoftware. There are other fields which our approach does not directly cover. Manufacturers can be easily extrapolated from theproductname. Asmentionedabove,versionnumbers,whicharefirmlyrequiredforSBOMgenerationandCVE identification,areusedtolabeltheversionstringsandthusarenotsubsequentlydeterminedbythemachinelearning solution. In summary, each data point in our final processed dataset, illustrated in Figure 1, contains a product, a package nameandalistofvalidversionstrings. Finally,havingalreadycorrelatedeachvalidversionstringtotheproduct,we decorrelatethoseversionstringswiththeotherunrelatedproductstooptimizefutureclassification. 3.3 Model InBERTandS-BERT,inputsareparsedaccordingtotheWordPiecetokenizationalgorithm. Wewillnowdescribethe WordPiecetokenizationalgorithm[13]. Asaninitialstep,aWordPiecemodelmustbegeneratedthroughthetraining procedure. Itcanbeexplainedasfollows: themodelisinitializedwithwordpiecesaswordunitsorsimplecharacters. Givenatrainingcorpuswithstopwordsfiltered, themodeldoesapairwisecombinationofwordpiecestoincrease thelikelihoodofthembeingpresentinthetrainingcorpus. Thisprocessiscontinueduntiltheminimumnumberof wordpiecesforthecorpusisconstructed. Alternatively,trainingmaybemadetostoponceapredefinednumberof wordpiecesisattained,inwhichcasetheremainderwillbeout-of-vocabulary. 4AutomatingSBOMGenerationwithZero-ShotSemanticSimilarity Product Version String "context\ngnu go 12.2.0 -mi" |
haskell-stack "nterpret\nstack-2.7.5-efk" "s'ckage\n%nxstack-2.7.5-4d8p8" BERT BERT pooling pooling u v cosine-sim(u, v) 0.05483 0 0.90975 1 0.28341 0 Figure2: TheproductandoneversionstringfromthelististakenasadatapointwhichservesasinputtotheS-BERT model. S-BERTproducesembeddingswhicharepooledintotwovectors,uandv. Thecosinesimilarityiscalculated withthesetwovectorsandcontrastedwiththepredefinedcorrelationlabeltoobtainthefinalclassification Table1: All20classespresentinthetrainingset. Thetrainingsetcontains4,000samplesfromeach. agda ghc gcc-xtensa-lx106 fricas gcc-13 grass haskell-opengl haxml gcc-12-cross-mipsen grub2 pandoc haskell-gtk haskell-graphviz gcc-riscv64-unknown-elf haskell-gtk3 darcs metaeuk uuagc gcc-10-cross propellor Prior to training, word separators are added such that the original sequence of words can be recovered from the wordpiecesequenceproducedbythemodel. BERTusestwospecialtokensinitsversionoftheWordPiecealgorithm. Thespecialclassificationtoken[CLS],whosefinalhiddenstateisusedastheaggregatesequencerepresentationinthe classificationtask,andthe[SEP],whichdelineatesthetwoinputs. Aswell,manyrarecharactersarenotrepresented tominimizeinefficiencies. Instead,thesearereplacedbyanunknownplaceholdercharacter([UNK]).Anadditional constraintisthatinputsentenceslongerthan256wordpiecesaretruncated. Notably,thisapproachremainsunaffected bywordorsentencesemantics. Inthecontextofourmodel,theWordPiecetokenizercanbedescribedasamappingfromZU∗l → ZW∗l whereU isthenumberofunicoderepresentations, l = 256isthemaximuminputsequencelengthandW = 30,000isthe numberofwordpieces. Thesevectorizedwordpiecesarethencombinedwithpositionalembeddingsandbinarysegment embeddingstoindicateprovenancefromthefirstorsecondsentence. TheprocedurecanbeobservedasZW∗l →RH∗l where H = 768 is the hidden size or the size of the embeddings for each wordpiece. Subsequently, these BERT embeddingsaretransformedaccordingtothemean-poolingoperationRH∗l →Re wheree=384isadensevector spacerepresentingthefixed-sizeoftheS-BERTembeddingvectorwhichcapturestheentireinputsequence. These embeddingsareusedasinputstoanobjectivefunctionS(x)fromRe →0<R<1. Theresultingrealnumberisthe probabilitythatagivenproductnamecorrespondstothequeriedversionstring. Tocomputethesentencesimilarityscorefromtwoinputs,weemployanS-BERTimplementationfromtheSentence Transformerspackage,specificallytheall-MiniLM-L6-v2model. Itisstructuredwiththreecomponentsashighlighted 5AutomatingSBOMGenerationwithZero-ShotSemanticSimilarity Table2: Anextractoftheclassesinthetestingset. ClassName NSamples Density systemd 86 0.430% libreoffice 72 0.360% espresso 39 0.195% medusa 13 0.065% js-of-ocaml 3 0.015% scrypt 1 0.005% xmppc 1 0.005% Table3: Theperformanceofthemodelwhencomparingtwodifferentsimilaritymetricsinthezero-shotexperiment. SimilarityMetric Accuracy Precision Recall Cosine 0.9290 0.9447 0.9126 DotProduct 0.9267 0.9452 0.90687 above: 1)theBERTmodel,2)thepoolinglayer,3)thesimilarityfunction. OurmodelemploysBERTBASE,whichhas 12standardmulti-layerbidirectionalTransformerlayers,12self-attentionheads,andahiddensizeof768comprising 110Mtotalparameters. Withupto256outputsofhiddensizeemanatingfromthisnetwork,themean-poolinglayer condensestheinformationintoafixed-sizeembeddingvector. Wecalculatesimilarityscoresusingtheseembeddingsas input. Finally,thecross-entropylossiscomputedonthecosine-similarityscoreandthepredictedlabel. u·v cosine_sim(u,v)= (1) ∥u∥·∥v∥ Inadeployedsetting,weexpectthistooltobeusedbyastakeholderwhoislikelytobeasecurityanalystorasystems administrator. Inthefirstphase,theusermustgatherasmanysoftwarebinariesasisavailabletotheirorganization. They must then process the files in their repository following our pipeline to obtain products and a corresponding listofversionstrings. Importantly,productnamesmustbemadeconsistentforoptimalperformance. Followingour methodology,themodelcanbetrainedandtested. Atthispoint,itisreadyforpracticaluse. Onesimpleusecase involvesanorganizationwantingtoinstallnewsoftwareinitssystem. Thistoolcanbereliedupontodecidewhether thesoftwarecanbewhitelisted. If,afteranalysis,themodeldeterminesthatnoneoftheversionstringsinthesoftware filecorrespondtoaproductlinkedwithCVEs,thenthesoftwareissafetoinstall. Optionally,thefilecanbeaddedto thedatasetforfuturetraining. 4 ExperimentalSetupandResults Weobtaintherawdata,acollectionofover100GBofbinaries,fromvariousonlinerepositories. Fromtherawdata,we curatedadatasetof400,000versionpatternsamplessourcedfromawiderangeofsoftwarebinaries. 4.1 Experiments To validate the proposed methodology, we conducted three experiments. The first experiment serves to verify the usefulnessofsemanticsimilarityformakingpredictionsaboutourdata. Also,itisdesignedtoguideourselectionof thesimilaritymetrictouseforlaterexperiments. Thesecondexperimentcomparesthemodel’sefficacyacrosstwo differentdatasamplingtechniques. Itcontrastsaperfectsimulationruninthelabwithademonstrationofhowthe toolmightbeemployedinpractice. Weuseatrainingsetwithsignificantlylesssamplediversitytoaccountforthe |
lownumberofmalwaresamplesavailabletotheaverageuserincomparisontotheabundanceofsoftwareecosystems. Throughthethirdexperiment,wedeterminetheoptimaltraininglengthforourmodelwhenusedinapracticalsetting. Welimitthesizeoftheexperimentaldatasetto100,000samplesinallexperiments. Wedeemthisnumbertopromote both sufficient sample diversity and training efficiency while maintaining the quality of the results, which can be achievedontheentiredataset. Followingasimilarlineofthinking,weconsistentlysplitthedataintotraining(80%) andtesting(20%)sets. Inthefirstexperiment,werandomlyselectandassignsamplesfromallclassestothetwosubsets,withthepossibility ofbothsetscontainingsamplesfromthesameclass. Thenasdescribedabove,ourS-BERTvariantprocessesthisdata 6AutomatingSBOMGenerationwithZero-ShotSemanticSimilarity Table4: Theresultscomparedbyinferencetype. Fullytrainedinthecaseofexperimentonewherethemodelistrained onallclasses. Inthezero-shotexperiment,ourmodelistrainedononly20classes. InferenceType Accuracy AUC Precision Recall F-1Score Fully-Trained 0.9290 0.9810 0.9447 0.9126 0.9284 Zero-Shot 0.8518 0.9016 0.9512 0.7410 0.8330 Table5: Thezero-shotresultsindifferenttrainingrunsoverincreasingepochsdemonstrateoverfitting. Epoch Accuracy AUC Precision Recall F-1Score 1 0.8518 0.9016 0.9512 0.7410 0.8330 2 0.8225 0.8783 0.9967 0.6463 0.7841 5 0.7383 0.7733 0.9777 0.4866 0.6498 10 0.5579 0.6267 0.6901 0.2068 0.3182 withabatchsizeof512,mouldingembeddingsaspartofthetrainingprocess. Theseembeddingsarecombinedusing eithercosineordotproductsimilarity,producingasemanticsimilarityscore,formingthebasisforourcomparison metricsdisplayedinTable3. Thesecondexperimentmakesuseoftwodifferentdataselectionprocedures. Inthefully-trainedapproach,thedatais splitwithsamplesrandomlyselectedfromallclassesinthesamewayasthefirstexperiment. Thezero-shotmethod beginsbygroupingallsamplesbyclassorlibrary. Theseclassesaresortedbythenumberofsamplesindescending ordertofacilitatethefillingofthetrainingset. Tomatchthepredeterminedsizeofthetrainingset,4,000samplesfromeachofthe20largestclassesaredrawnand exhibitedinTable1. Tothetestingset,werandomlyallocatesamplesfromtheremainingclassesintheinitialdataset. AsubsetoftheconstituentstothetestingsetcanbeobservedinTable2. Againthemodelproducessimilarityscores, butthistimeonlyusingdotproductsimilarity. Weamalgamatethesescorestocomputeavarietyofmetricsqualifying theeffectivenessofourzero-shotmethod. ThesemetricscanbeseeninTable4. In the third experiment, following the same zero-shot procedure as in the second experiment, we conducted four zero-shottrialsoveranincreasingnumberofepochs. TheresultscanbeobservedinTable5. Thefirstexperimentdemonstratesthatresultsarelargelyinsensitivetothechoiceofsimilaritymetric. However,as expected, thecosinesimilaritymetricusedtotrainthemodelperformsbestintesting. Itoutperformsdotproduct similarityinbothaccuracyand,notably,recall. Duetominorvariationsindataselection,itcouldbeobservedina similarexperimentthattheaccuracyofdotproductsimilarityslightlyoutperformsthatofcosinesimilarity. Inthis contextofcybersecurity,wherepreventionisparamount,wewouldstilladvocatechoosingcosinesimilarityifitcaptures morepositivesamples,therebygivingrisetoahigherrecallscore. n=384 (cid:88) u ·v =u ·v +u ·v +...+u ·v (2) i i 0 0 1 1 n−1 n−1 i=0 u·v =|u|·|v|·cos(α) (3) Resultsfromthesecondexperimentindicatethatthefully-trainedmodelperformswell,asisourexpectationwhen resentedwithtrainingandtestingdatasampledfromthesameclasses.Butimportantly,wefindthemodel’sperformance inthezero-shotexperimenttoberemarkable. Despitetrainingononly20classesinthezero-shottask,themodel’s accuracy differs by a little over 7% in comparison to the first experiment. Evidently, the recall score suffers from thepovertyinsamplediversity,leadingtothemodel’sinabilitytorecognizeasmanypositivesamples. Uponcloser inspection,thereseemstobeaparticularmaximumnumberofsamplesperclassoraspecificnumberofclassesthatis optimalforthezero-shotperformance. Wedeterminedalocalmaximumforperformanceat4,000samplesand20 classes. Theoutcomeofthethirdexperimentconcerningthenumberofepochsusedfortrainingisquitesimple. Theoriginal S-BERTmodel,itselfafine-tunedversionofBERT,wastrainedoverasingleepoch. Hence,itislogicalthatthebest resultswouldbeobtainedbyfine-tuningS-BERToveroneepoch. Inthisinstance,anythingmorecausesadegradation inperformanceduetooverfitting. 7AutomatingSBOMGenerationwithZero-ShotSemanticSimilarity Wedemonstratethroughourexperimentsthatourapproachisasolutiontotheproblemofinconsistentresultshighlighted byReinholdetal. Providedthatdataisprocessedwithcare,anynumberofdifferentversionstringswhencorrectly classified,willconsistentlymatchtothesameproduct. Furthermore,existingtools,suchascve-bin-toolandEMBER, onlysupportaround300packages,whereaswewereabletoapplythemodeltothewholedebianrepository,which containsover40,000packages. Fromapracticalperspective,thispaperdescribesamethodfordeterminingsoftware |
products. Thoughitusesversionnumbers,itdoesnotdirectlyaddresstheproblemofidentifyingthemwithinthese products. Nonetheless,versionnumbersareanimportantaspectofSBOMs. Infact,theyarecriticalforidentifying vulnerablecomponents,asvulnerabilitydatabasesrequireversionnumberstoaccuratelyrelateasoftwarecomponent toavulnerability. Bethatasitmay,wedeemtheproblemofversionnumberidentificationtobeatrivialoperation involvingregularexpressions. Thereforewehavenotconsideredthatprobleminthispaper. Reflectingfurtheruponthesecondexperiment,someofthetrainingclassesmayappeartohaveversionstringswith similar structures, for example, haskell-gtk and haskell-gtk3. The relationship between the semantic similarity of versionstringsfromdifferentproductsinthetrainingset,andzero-shottestperformanceshouldbeaprimaryfocusof futureinvestigation. Atfirstglance,thesolutiontotheproblemmightbeformulatedasafullyconnectedgraph,where theverticesareasubsetoftheproductsavailable,curatedforthetrainingsetsuchthattheedgesarethesimilarity scoresproducingaminimumsumforthedataset. Suchanalysismightbesupplementedwithacloserlookattestresults whichnaturallyrevealdifferencesinperformancebyclass. Observingthestructureofversionstringsintheclasses whichyieldlowrecallscoresmayalsoguidetheselectionofclassesinforminganoptimaltrainingset. 5 ConclusionandFutureWorks Thepurposeofthisstudyistoaddressthecriticalissueofsupply-chainattacks,whosenotorietywascementedby the Solarwinds supply-chain attack. Recognizing the critical nature of SBOMs in ensuring supply chain security, webroughtforwardanovelsolutionthatleveragesmachinelearning,specificallythetransformermodelS-BERT,to automatethegenerationofSBOMsfromcompiledbinaries. ExistingSBOMgenerationtools,whicharegenerally reliant on case-based reasoning, have demonstrated limitations in dealing with the diverse and dynamic nature of modernsoftwareproductions. Inanefforttoaddressthesechallenges,weintroducedamethodwhichemploysS-BERTtomatchdifferentversion stringspresentinbinariestotheappropriatesoftwareproduct. Threeexperimentswereconducted. Thefirstguidedour choiceofsimilaritymetric. Thesecondcontrastedaninstanceofourmodeltrainedonallclassestoonetrainedona reducedsettosimulatereal-worldscenarioswithzero-shotlearning. Thethirdaddressedtheimpactofthenumberof epochsonthemodel’sperformance,emphasizingtheriskofoverfitting. Resultsshowcasedthemodel’simpressivezero-shotinferencecapabilitiesasitachievedstrongresults. Though,our findings highlight the importance of sample diversity, raising the question of how class selection should occur for formingtrainingsets. Asanopenproblemforsubsequentresearch,weleaveoptimizingclassselectionfortrainingset composition. Foramorecomprehensiveapproachtosupplychainsecurity,theidentificationofversionnumberswithin softwareproductsisasimpleyetimportantendeavortoundertakeinthefuture. Wenotethatthiscomponentistheonly otherdatapointrequiredtogenerateareducedSBOMsufficientforCVEdetection. Inconclusion,ourresearchhasthe potentialtoprotectlargescalesoftwaresupplychainsusingverylittledata,therebymakingitanextremelyvaluable toolforprotectingorganizationsandindividualsfrommaliciousactors. References [1] LaviLazarovitz. Deconstructingthesolarwindsbreach. ComputerFraud&Security,2021(6):17–19,2021. [2] ÉamonnÓMuirí. Framingsoftwarecomponenttransparency: Establishingacommonsoftwarebillofmaterial (sbom). NTIA,Nov,12,2019. [3] AmasPhillips,CarstenMaple,FlorianLukavsky,IanPearson,MichaelRichardson,NigelHanson,PaulKearney, andRobertDobson. Softwarebillsofmaterialsforiotandotdevices. IoTSecurityFoundation,2023. [4] HaroldBooth,DougRike,andGregoryWitte. Thenationalvulnerabilitydatabase(nvd): Overview,2013-12-18 2013. [5] Thien-Phuc Doan and Souhwan Jung. Davs: Dockerfile analysis for container image vulnerability scanning. Computers,Materials&Continua,72(1),2022. [6] AnnMarieReinhold,TravisWeber,ColleenLemak,DerekReimanis,andClementeIzurieta. Newversion,new answer: Investigatingcybersecuritystatic-analysistoolfindings. In2023IEEEInternationalConferenceonCyber SecurityandResilience(CSR),pages28–35.IEEE,2023. 8AutomatingSBOMGenerationwithZero-ShotSemanticSimilarity [7] ZeinShaheen,GerhardWohlgenannt,andErwinFiltz. Largescalelegaltextclassificationusingtransformer models. arXivpreprintarXiv:2010.12871,2020. [8] JacobDevlin,Ming-WeiChang,KentonLee,andKristinaToutanova. Bert: Pre-trainingofdeepbidirectional transformersforlanguageunderstanding. arXivpreprintarXiv:1810.04805,2018. [9] NilsReimersandIrynaGurevych. Sentence-bert: Sentenceembeddingsusingsiamesebert-networks. arXiv preprintarXiv:1908.10084,2019. [10] MarkPalatucci,DeanPomerleau,GeoffreyEHinton,andTomMMitchell. Zero-shotlearningwithsemantic outputcodes. Advancesinneuralinformationprocessingsystems,22,2009. [11] ZimingZhangandVenkateshSaligrama. Zero-shotlearningviasemanticsimilarityembedding. InProceedings oftheIEEEinternationalconferenceoncomputervision,pages4166–4174,2015. [12] NTIA,2021. [13] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim |
Krikun,YuanCao,QinGao,KlausMacherey,etal. Google’sneuralmachinetranslationsystem: Bridgingthegap betweenhumanandmachinetranslation. arXivpreprintarXiv:1609.08144,2016. 9 |
2403.10646 111 A Survey of Source Code Representations for Machine Learning-Based Cybersecurity Tasks BEATRICE CASEY, JOANNA C. S. SANTOS, and GEORGE PERRY, University of Notre Dame, USA Machinelearningtechniquesforcybersecurity-relatedsoftwareengineeringtasksarebecomingincreasinglypopular.The representationofsourcecodeisakeyportionofthetechniquethatcanimpactthewaythemodelisabletolearnthefeatures ofthesourcecode.Withanincreasingnumberofthesetechniquesbeingdeveloped,itisvaluabletoseethecurrentstateof theeldtobetterunderstandwhatexistsandwhat’snotthereyet.ThispaperpresentsastudyoftheseexistingML-based approachesanddemonstrateswhattypeofrepresentationswereusedfordierentcybersecuritytasksandprogramming languages.Additionally,westudywhattypesofmodelsareusedwithdierentrepresentations.Wehavefoundthatgraph- basedrepresentationsarethemostpopularcategoryofrepresentation,andTokenizersandAbstractSyntaxTrees(ASTs) arethetwomostpopularrepresentationsoverall.Wealsofoundthatthemostpopularcybersecuritytaskisvulnerability detection,andthelanguagethatiscoveredbythemosttechniquesisC.Finally,wefoundthatsequence-basedmodelsarethe mostpopularcategoryofmodels,andSupportVectorMachines(SVMs)arethemostpopularmodeloverall. CCSConcepts:•Generalandreference Surveysandoverviews. ! ACMReferenceFormat: Beatrice Casey, Joanna C. S. Santos, and George Perry. 2024. A Survey of Source Code Representations for Machine Learning-BasedCybersecurityTasks.ACMComput.Surv.37,4,Article111(March2024),35pages.https://doi.org/XXXXXXX. XXXXXXX 1 INTRODUCTION Software vulnerabilities are defects that aect a software system’s intended security properties [1] which allow attackers to perform malicious actions. As our lives become more attached to technology, software vendorsareincreasinglypressuredintoengineeringsecuresoftwaresystems,i.e.,takingproactivemeasuresof preventing/repairingvulnerabilitiespriortodeployingthesystemsintoproduction.Thereareseveralpractices toaddresssecurityconcernsbeforesoftwarereleaseineachphaseofthesoftwaredevelopmentlifecycle.Inthe requirementsphase,misuse/abusecases[2,3]andthreatmodeling[4]areusefultobetterunderstandthesecurity requirementsbyidentifyingthepotentialthreatstothesystemandpossiblewaystomitigatethem.Duringthe designphase,architecturalriskanalysis[5]canbeusedtoassessthelikelihoodofexploitationofanassetand securitytacticsandpatterns[6]canbeappliedinthedesignofthesoftwareasaprovensolutionthatworksunder acontext.Attheimplementationphase,securecodereviews canbeperformedtosystematicallyexaminethe Author’saddress:BeatriceCasey,JoannaC.S.Santos,andGeorgePerry,UniversityofNotreDame,NotreDame,IN,USA,{bcasey6,joannacss, gperry}@nd.edu. Permissiontomakedigitalorhardcopiesofallorpartofthisworkforpersonalorclassroomuseisgrantedwithoutfeeprovidedthat copiesarenotmadeordistributedforprotorcommercialadvantageandthatcopiesbearthisnoticeandthefullcitationontherst page.CopyrightsforcomponentsofthisworkownedbyothersthanACMmustbehonored.Abstractingwithcreditispermitted.Tocopy otherwise,orrepublish,topostonserversortoredistributetolists,requirespriorspecicpermissionand/orafee.Requestpermissionsfrom permissions@acm.org. ©2024AssociationforComputingMachinery. 0360-0300/2024/3-ART111$15.00 https://doi.org/XXXXXXX.XXXXXXX ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:2 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry sourcecodewiththegoalofidentifyingandxingvulnerabilities[7].Inthetestingphase,penetrationtestingaims toexercisethesoftwareinmanywaysinanattempttobreakitanddiscovervulnerabilities[8]andstatic/dynamic analysistoolscanbeusedtoidentifypotentialvulnerabilitiesinthesourcecode[9,10]. Althoughthesepracticescanhelpimproveasoftwaresystem’ssecurity,itcanbeerror-proneandtime-consuming forengineerstoperformthem.Forexample,ndingvulnerabilitiesincodecanbedicultforengineers,especially whentheydonotknowwhattolookfor[7].Withtheadvancesofmachinelearning(ML),priorworkshave appliedMLtechniquestoseveralofthesecybersecuritytasks,suchasvulnerabilitydetection[11–16],malware detection[17–26]andmaliciousbehaviordetection[27].Thesetechniquesarevaluablebecausetheycanhelp improvethesecurityofcodethatisreleasedandspeedupotherwiseerror-proneandtime-consumingtasks.For example,amodelthatisabletodetectvulnerabilitiespriortodeploymentwouldsavetime,money,andincrease thesecurityofthesystemasawhole,particularlysincedevelopersareoftentimesunawarewhenavulnerability existsincodeuntilitisexploitedorfoundbysecurityanalysts[28]. Machinelearningmodelsareunabletounderstandrawsourcecode;thesourcecodeneedstoberepresented inawaythateectivelyconveysthestructuralandsemanticinformationinthecode.Therearemanywaysin whichsourcecodecanberepresented,e.g.,asanAbstractSyntaxTree(AST)[12,16,29–33],ControlFlowGraph (CFG)[12,13,34–36],tokenized[11,15,37–39],etc.Sourcecoderepresentationisacrucialpartduringthe developmentofML-basedtechniquesbecausedierentrepresentationswilloerdierentinformationthatthe modellearnsfromtoperformtheirtask[40]. Althoughpriorworks[41–48]haveintroducednovelsourcecoderepresentationsfordierentcybersecurity tasks,thereisnocurrentunderstandingofwhatrepresentationsexistandarecommonlyused,aswellasthe cybersecuritytasksthemodelisbeingusedfor.Furthermore,manyoftheseML-basedtechniquesareonlytested onormadeforaparticularprogramminglanguage,andthereisnocurrentunderstandingofthelanguagesthat arecoveredbythesetechniques.Understandingthesourcecoderepresentationsthatareavailableandwhatthey oerwillallowresearcherstoidentifywhatrepresentationtheymaywanttousebasedonwhattasktheyaimto complete.Additionally,understandingtherelationshipbetweencybersecuritytasksandrepresentationswill allowresearcherstoeitherchoosearepresentationthathaspreviouslybeenusedforaparticulartask,ortotest ifadierentrepresentationwouldbemoresuitable. Inthispaper,weconductaSystematicLiteratureReview(SLR)byfollowingtheguidelinesbyKitchenhamand Charters[49]tounderstandthecurrentstateoftheartofsourcecoderepresentationforML-basedtechniques |
forcybersecuritytasks.Weinvestigatethepopularityofcertainrepresentationsandcybersecuritytasks,the programminglanguagescoveredbyexistingtechniques,andthecommontypesofmachinelearningmodels usedwithdierentrepresentations.Wealsoinvestigaterelationshipsbetweenrepresentationsandcybersecurity tasks.Thegoalofthestudyistoallowresearcherstounderstandthegapsinthisdomain,particularlyifthereare certaincybersecuritytasks,orlanguagesthatareneglectedbyexistingtechniques.Additionally,westudyand contrastexistingrepresentations. 1.1 Contributions Thecontributionsofthismanuscriptare:(1)anexaminationofthestate-of-the-artofML-basedcybersecurity tasks;(2)aninvestigationofsourcecoderepresentations,andtheirrelationshipstocybersecuritytasksand models;(3)theidenticationoftheprogramminglanguagesthatarecovered/notcoveredbyexistingML-based techniques;(4)acomparisonofthedierentsourcecoderepresentations. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:3 1.2 OpenScience Thepaper’sartifacts,includingdatasets,code,andadditionalresources,areavailableonGitHubathttps://github. com/s2e-lab/source-code-representation-survey. 1.3 ManuscriptOrganization The rest of this manuscript is organized as follows: Section 2 provides the denition of terms that relevant forunderstandingourwork.Section3describesrelatedwork.Section4explainsthemethodologyofthisSLR. Sections5–9sharestheresultsofthiswork.Section10explainsthreatstovalidity,andSection11providesa discussionandconclusionourndings. 2 BACKGROUND Thissectiondiscussescoreterminologysuchthatthemanuscriptcanbeunderstoodbyabroaderaudience. 2.1 MachineLearningforSecureSowareEngineering Alongwithdevelopingnewcodeofgoodquality,softwareengineersareresponsiblefordiscoveringandresolving bugs,defects,vulnerabilitiesandanyotherissuesthatcouldariseinsourcecode.Thesetaskscanbedicult, error-prone,time-consuming,andtedious[7].FollowingKemmerer’s[50]denition,acybersecuritytaskisa taskthatisaimedatthwartingwould-beintruders.Thus,thecybersecuritytaskssoftwareengineersworkon todayinvolveresolvingandidentifyingcodethatcouldallowanattackertotakeadvantageofasystem. Withtherecentadvancesofmachinelearning,severalpriorworksidentiedwaysinwhichMLcouldassist softwareengineersinthesecybersecuritytasks[51].Inparticular,givenhownegativelyvulnerabilitiesandother security-relatedissuesimpactcompanies,researchersstartedlookingintohowmachinelearningcanhelpto mitigatetheseissuesandoverallimprovethequalityofsourcecodethatisputouttothepublic. 2.2 SourceCodeRepresentationsandCodeEmbeddings MLmodelscannotacceptrawsourcecodeasinput.Thus,asourcecoderepresentationisneededtocapture thesourcecode’ssyntaxandsemanticssuchthatthemodelisabletolearnthekeyfeatures.Therearemanyways thatapieceofsourcecodecanberepresented.Forexample,giventhestructurednatureofsourcecode,prior workscapturedthisstructurebyrepresentingitasagraph[52].Otherworks[37,53,54]usedNaturalLanguage Processing(NLP)techniquesonsourcecodeinordertoleveragetechnologyandknowledgethatalreadyexists. Theserepresentationsoerdierentinformationaboutthesourcecodeandthusimpactwhatthemodelcanlearn aboutit.Forexample,NLPtechniquesdonotoerstructuralinformation,buttheyprovidesemanticinformation. Therefore,themodelwilllearnthesemanticrelationships,butnotthestructuralrelationshipsinthecode. MLmodelslearnfromvectorembeddings,whichisalowdimensionalwaytorepresenthighdimensionaldata. Inthecaseoflearningsourcecode,theembeddingsarecreatedfromthesourcecoderepresentation.The sourcecoderepresentationistherst levelofabstractionfortheoriginalsourcecode.Thisiswhatisconsidered asthefeatureextractionphase.Inthisphase,theoriginalhigh-dimensionaldataaretransformedintolower dimensionaldata,whichrepresentsthekeyfeaturesofthedata.Thefeatureextractionisaimedatpreserving as much of the information about the original data as possible [55]. The vector embeddings are the second levelofabstractionandarewhatallowsustoperformmachinelearningtechniquesontherepresentationsby transformingtherepresentationtothenumericalformthatmachinesareabletounderstand[56]. Thereareamultitudeoftechniquestocreatetheseembeddings.FromtherealmofNLPwork,theembeddings areusuallycreatedbyusingthe2model[57],whichtakestokensandconvertsthemtonumerical ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:4 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry vectors.Inspiredbythismethodology,researchershavefoundawaytotakeagraphandcreatethesevector embeddings(2[58]).Thistechniqueiswhatistypicallyusedtogenerateembeddingsfromthetreeor graphstructuresgeneratedbythesesourcecoderepresentations.G2implementsideasfrom2 and2,andtreatsawholegraphasadocumentandthesubgraphsaswords[58].Additionally,other workshavealsolookedathowtocreateembeddingsstraightfromsourcecodeandcreatedtechniquessuchas 2[59]andGC2V[60]. 3 RELATEDWORK To the best of our knowledge, this is the rst-of-its-kind SLR that focuses on the representations of source codeusedinmachinelearning-basedtechniquesforcybersecuritytasks.Thereareanumberofpapers[61–69] thatperformeitherasystematicmappingstudy,orasurveyoftheliteratureinmachinelearningforsoftware engineering,withsomepapersfocusingonvulnerabilitydetection,analysis,orassessment.Allofthesepapers primarily focus on the machine learning models used for these problems, but few mention or give detailed descriptionsoftherepresentationsusedintheseeorts.Additionally,someofthepapersfocusonlyondeep learningtechniques[64–66].Unlikethesepriorworks,oursurveypaperhasitsprimaryfocusonthetopicof representationsusedformachinelearningforsecurityrelatedtasks. |
Ghaarian and Shahriari [70] surveyed techniques used for vulnerability analysis and outlined four main categoriesthattheapproachesofthesetechniquesfallunder:softwaremetrics,anomalydetection,vulnerablecode patternrecognitionandmiscellaneous.Similarly,Nazimetal.[63]analyzeddeeplearningmodelsforvulnerable codedetection.Theirstudyexaminethedierentdatasettypesusedtotraindeeplearningmodels(e.g.,,synthetic, semi-synthetic, real data, etc), the evaluation metrics used to assess the models’ performance as well as the dierentsourcecoderepresentationsused.Unlikethesepriorworks,welookbeyondvulnerabilityanalysis anddetection,andinsteadlookatallsecurity-relatedsoftwareengineeringtasks.Wealsohaveabroaderscope becausewelookatalltypesofmachinelearningmodels,notjustdeeplearningmodels. Wu[71]performedaliteraturereviewonNLPtechniquesforvulnerabilitydetection.Whilethispaperdoesgivea briefoverviewondierenttypesofrepresentations,itsfocusisonNLPtechniques,particularlyNLPmodelsthat arefocusedforcodeintelligencesuchasCodeBERTandCodeXGlueintheinstanceofvulnerabilitydetection. ChenandMonperrus[72]performasimilarliteraturereview,investigatingwordembeddingtechniqueson programs.Inthissurvey,theauthorsexploredierentgranularitiesofembeddingsfromdierentpapersand showvisualizationsofthedierentembeddings.Wefocusonawidearrayofsecurityrelatedtasks,aswellas manyrepresentationsandhowtheycanimpactthemodel’sabilitytolearnvulnerabilities. Kottietal.[73]performedatertiarystudyonmachinelearningforsoftwareengineering.Thispaperevaluated83 reviews,orsurveys,ontheeldofmachinelearningforsoftwareengineering.Whileourpaperfocusesonsecurity related softwareengineeringtasks,Kottietal. investigatedallmachinelearningbasedsoftwareengineering tasks.Additionally,whilethispaperisabroaderanalysisofthesoftwareengineeringtasksthatMLcovers,our paperfocusesprimarilyontherepresentationsofsourcecodeusedtoperformasecuritytask. Twopaperscreateataxonomyforsoftwareengineeringtasksandmachinelearning,withonepaperfocusing broadlyonsoftwareengineeringchallengesformachinelearningsystems[74],andtheotherfocusingonsoftware vulnerabilitydetectionandmachinelearningapproaches[75].Neitherofthesepapersdelveintosourcecode representationeortsandwhatinformationtheyoer.However,Hanifetal.[75]domentiontheimportanceofthe representationinthemachinelearningpipeline.Unlikethesestudies,ourpapersfocusesontherepresentations used,ratherthanjustthemodels,andfocusesonawidearrayofsecuritytasks. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:5 Usmanetal.[76]performedasurveyonrepresentationlearningeortsincybersecurity.However,thispaper does not focus on the representation of source code, but rather dierent machine learning algorithms used forcybersecurityissues,aswellasdatasetsandhowindustryutilizesthesedierenteortstoimprovetheir cybersecurity.Similarly,Macasetal.[77]createdasurveyondeeplearningtechniquesforcybersecurity.This paperfocusesondeeplearningtechniquestoanalyzeinternettrac.Itprovidesinsightsandfuturedirectionsin thisareaofdeeplearningtoanalyzeinternettracforcybersecurity. 4 METHODOLOGY WefollowedtheguidelinesoutlinedbyKitchenhamandCharters[49]toconductourSLR,whichinvolvesthree majoractivities:planning,conducting,andreportingthereview.Duringtheplanningphase,wedenedthisstudy’s researchquestionsandthesearchqueryusedtondpapers.Duringtheconductingphase,wesearchedthree librarysourcesanddownloadedallthepaperswefoundintoCSVles.Wethenappliedourinclusionandexclusion criteriainthreephasestoeliminatepapersuntilwegottothenalgroupofpapersthatareincludedinthisstudy. Tworeviewersindependentlyreadeachpaperandperformedananalysis,extractingtheinformationthatis relevanttotheresearchquestionswedevelopedintheplanningphase.Wereviewedandresolveddiscrepancies togetthenalanalyses.WecalculatedtheCohen’sKappatoevaluatethereliabilityofourevaluation.Ourscore of0.97indicatesthatwehadanearperfectagreementinouranalysisFinally,duringthereporting phase,we analyzedourdataandorganizeditsothatwecouldanswertheresearchquestionsweposed. 4.1 Researchestions ThroughthisSLR,weaimtoanswerveresearchquestions. RQ1:Whatarethemostcommonlyusedsourcecoderepresentations? Inthisrstquestion,weinvestigatethesourcecoderepresentationsthatwereusedforsolvingsecurityproblems. Weaimtounderstandwhatsourcecoderepresentationsaremorepopularandcomparetheirtrade-os. RQ2:Docertaincybersecuritytasksonlyormostlyuseonetypeofsourcecoderepresentation? Inthisquestion,weinvestigatewhatsourcecoderepresentationsarebeingusedforeachcybersecuritytask. Withthisquestionweexaminewhetheraspecicrepresentationisusedmostfrequentlyforaparticulartask overanyother.Alongwiththis,wewanttoinvestigatewhyitwouldbethecasethataparticularrepresentation ispreferredforatask. RQ3:Whatcybersecuritytasksarecoveredbythetechniquesthathavebeencreated? Weinvestigatehowthesetaskstintothesoftwaredevelopmentlifecycletoidentifyhowthesetechniques wouldbeusedduringsoftwaredevelopment.Furthermore,wedescribeandndeverycybersecurity-relatedtask sothatweprovideaclearerpictureofthetaskanditsimportanceintherealmofsoftwaresecurity. RQ4:Whatprogramminglanguagesarecoveredbyexistingapproaches? Giventhevastnumberofprogramminglanguagesusedinpractice,weinvestigatewhatlanguagesarecovered bythetechniquesfoundfromoursearch.Thisinformationallowsustoseegapsinthesetechniquesregarding whatlanguagesarecovered. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:6 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry RQ5:Whatmodelsarecommonlyusedwithdierentrepresentations? Westudywhatsourcecoderepresentationsareusedfordierentmodeltypes. 4.2 SearchMethod Weperformedanautomaticsearch,usingthefollowingsearchstringtondallprimarystudiesrelatedtothe representation(s)ofsourcecodeforML-basedcybersecuritytasks:(“machine learning” OR “deep learning” OR “artificial intelligence”) AND (“security” OR “vulnerability”) AND (“code”).Whilethisisaverygeneral searchstring,whichresultedinatotalof64,803papers,wedecidedthatratherthanhavingaspecicstring thatmaymissacategoryofsoftwaresecuritytasksorrepresentations,wewouldmakeageneralstringand manuallyeliminateanypapersthatdonotmeetourinclusioncriteria,ortourexclusioncriteria.Wesearched threedatabasestondrelevantpapers:theACMdigitallibrary1,IEEEXplore2,andSpringerLink3. |
Table1. InclusionandExclusioncriteria InclusionCriteria ExclusionCriteria E1Duplicatedstudies I1Writtenbetween2012-May2023 E2Books,referenceworkentries,referenceworks I2Afullpaper E3Positionpapers,shortpapers,tooldemopapers,keynotes,reviews,tutorials,and I3FocusedonMLforcybersecuritytasks paneldiscussions. I4Containsinformationregardingthesource E4StudiesnotinEnglish code’srepresentation E5:Survey/comparativestudies. 4.3 InclusionandExclusionCriteria Table1liststheinclusion/exclusioncriteriaappliedtothepapersinmultiplestagesinordertoeliminatepapers irrelevantforthisstudy.Asshowninthistable,welimitedoursearchtopaperspublishedinthelastdecade(i.e., betweenJanuary2012toMay2023).Ourinclusioncriteriaaimedtoincludeonlythepapersthatfocusedon developingML-basedtechniquesforhelpingcybersecuritytasksandthatfocusedonormentionedtheuseor creationofarepresentationofsourcecodeasapartoftheirwork.Weeliminatedduplicatedstudies,worksnot inEnglish,andanypapersthatwerenotfullpapers,e.g.,books,shortpapers(i.e.,paperswithlessthanvefull pagesoftext,notincludingreferences),tutorials,etc).Wealsodisregardedanypapersthatdidnotrepresentthe sourcecodeitself(e.g.,papersthatdealtwithbinaryles,extractingfromtheAndroidManifest,etc),asweare interestedinonlyunderstandingtherepresentationofrawsourcecode. (cid:36)(cid:38)(cid:48)(cid:3)(cid:39)(cid:76)(cid:74)(cid:76)(cid:87)(cid:68)(cid:79)(cid:3)(cid:47)(cid:76)(cid:69)(cid:85)(cid:68)(cid:85)(cid:92) (cid:20)(cid:24)(cid:15)(cid:19)(cid:27)(cid:28) (cid:36)(cid:83)(cid:83)(cid:79)(cid:92)(cid:3)(cid:76)(cid:81)(cid:70)(cid:79)(cid:88)(cid:86)(cid:76)(cid:82)(cid:81)(cid:3)(cid:68)(cid:81)(cid:71)(cid:3)(cid:72)(cid:91)(cid:70)(cid:79)(cid:88)(cid:86)(cid:76)(cid:82)(cid:81) (cid:36)(cid:83)(cid:83)(cid:79)(cid:92)(cid:3)(cid:76)(cid:81)(cid:70)(cid:79)(cid:88)(cid:86)(cid:76)(cid:82)(cid:81)(cid:3)(cid:68)(cid:81)(cid:71) (cid:36)(cid:83)(cid:83)(cid:79)(cid:92)(cid:3)(cid:44)(cid:20)(cid:3)(cid:68)(cid:81)(cid:71) (cid:44)(cid:40)(cid:40)(cid:40)(cid:3)(cid:59)(cid:83)(cid:79)(cid:82)(cid:85)(cid:72) (cid:20)(cid:15)(cid:26)(cid:27)(cid:28) (cid:14) (cid:24)(cid:19)(cid:15)(cid:20)(cid:22)(cid:22) (cid:70)(cid:85)(cid:76)(cid:87)(cid:72)(cid:85)(cid:76)(cid:68)(cid:3)(cid:69)(cid:92)(cid:3)(cid:85)(cid:72)(cid:68)(cid:71)(cid:76)(cid:81)(cid:74)(cid:3)(cid:87)(cid:75)(cid:72)(cid:3)(cid:83)(cid:68)(cid:83)(cid:72)(cid:85)(cid:10)(cid:86)(cid:23)(cid:23)(cid:21) (cid:72)(cid:91)(cid:70)(cid:79)(cid:88)(cid:86)(cid:76)(cid:82)(cid:81)(cid:3)(cid:70)(cid:85)(cid:76)(cid:87)(cid:72)(cid:85)(cid:76)(cid:68)(cid:3)(cid:69)(cid:92) (cid:20)(cid:23)(cid:19) (cid:40)(cid:20)(cid:3)(cid:70)(cid:85)(cid:76)(cid:87)(cid:72)(cid:85)(cid:76)(cid:68) (cid:87)(cid:76)(cid:87)(cid:79)(cid:72)(cid:15)(cid:3)(cid:78)(cid:72)(cid:92)(cid:90)(cid:82)(cid:85)(cid:71)(cid:86)(cid:15)(cid:3)(cid:68)(cid:81)(cid:71)(cid:3)(cid:68)(cid:69)(cid:86)(cid:87)(cid:85)(cid:68)(cid:70)(cid:87)(cid:17) (cid:85)(cid:72)(cid:68)(cid:71)(cid:76)(cid:81)(cid:74)(cid:3)(cid:87)(cid:75)(cid:72)(cid:3)(cid:73)(cid:88)(cid:79)(cid:79)(cid:3)(cid:83)(cid:68)(cid:83)(cid:72)(cid:85) |
(cid:54)(cid:83)(cid:85)(cid:76)(cid:81)(cid:74)(cid:72)(cid:85)(cid:3)(cid:47)(cid:76)(cid:81)(cid:78) (cid:23)(cid:26)(cid:15)(cid:28)(cid:21)(cid:24) (cid:25)(cid:23)(cid:15)(cid:27)(cid:19)(cid:22) Fig.1. ThreeStagesoftheSearchProcess 1https://dl.acm.org 2https://ieeexplore.ieee.org 3https://link.springer.com ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:7 4.4 PaperSelection Figure1showsthenumberofpapersthatmadeitthrougheachstageoftheselectionprocess.Westartedout with64,803totalprimarystudies.Wersteliminatedduplicatestudiesandstudiesthatwereoutsidetheyear rangeof2012-May2023(criterionI1),aswellasnon-fullpapers(criterionE1).Thisresultedin50,133papers. Subsequently,weinspectedeachpaper’stitle,keywords,andabstracttoinclude/excludepapersbasedonwhether theytourcriteria.Afterthissearch,wewereleftwith442papers.Wethenappliedthesamecriteriaonthese442 papers,thistimebyreadingthefullpaper.Thisleftuswiththe140papersthatareincludedinthissurvey. 4.5 DataExtraction Aswewentthroughthepapers,weextractedthekeyinformationwewerelookingfortoanswerourresearch questions: the representation used in the paper, the cybersecurity task it was completing, the programming languagesthetechniquewasdesignedforortestedon,andthemodeltypeusedinthework.Whileconducting thisstudyweusedParsifal[78],whichisaweb-basedapplicationdesignedtohelpresearchersincollaborating ontheexecutionofanSLR.Thenextsectionspresentthendingsfromourstudy. 5 RQ1RESULTS:WHATARETHECOMMONLYUSEDSOURCECODEREPRESENTATIONS? Table 2 summarizes the source code representations used/described by the surveyed papers organized into fourcategories:graph-based,tree-based,lexical,andmiscellaneous.Mostofthesourcecoderepresentationsare graph-based representations,andcontrolflowgraphs(CFGs)arethemostpopularrepresentationinthis category.Wealsoobservedthatthethreemostusedcommonsourcecoderepresentationsareatokenizer,an abstractsyntaxtree(AST)andcodemetrics.Wealsofoundtwopapers[51,178]thatusedaslightlymodied ASTversiontorepresentsourcecode(wedenotedthemasAST+inTable2).Althoughmorerare,somepapers [21,88,93]representedcodeasanimageanalysis,andperformedanimageanalysisofsourcecodetoidentify patternsthatareassociatedwithvulnerabilitiesormalware.Thefollowingsubsectionsgiveadetailedexplanation ofwhateachrepresentationisandtheinformationitcarriesouttotheembeddings. 5.1 Tree-BasedSourceCodeRepresentations Tree-basedrepresentationsarethosethatdemonstratethehierarchicalnatureofsourcecode. 5.1.1 AbstractSyntaxTree(AST). AnASTisatreerepresentationofsourcecodethatprovidesinformationabout codeelements(e.g.,variables)andtheirstructuralrelationship[63,181].ASTwasthemostpopularrepresentation anditwasusedby32papers.Althoughonepaper[176]used2[182]asawaytogeneratetheembeddings straightfromsourcecode,thebasisoftheirmodelisanAST;thesourcecodeisrepresentedasanASTbeforethe vectorsaregenerated.Fig.2hasanexampleofanASTforaPythoncode.EachnodeinthisASTrepresentsa codeelement(e.g.,x)whiletheedgesdemonstratehowtheseelementshierarchicallyconnecttooneanother (e.g.,xisanargumentfromfunc). UsingtheinformationfromanAST,modelscancapturegeneralstructuralcodepatterns,sinceASTsabstract awaythelow-levelsyntaxdetailsoftheunderlyingprogramminglanguageofthecode[12].Thisreduceslearning eortandallowsforASTstobeusedformultipletasks[59].EmbeddingsforASTscanbegeneratedindierent ways.Typically,thenodeandpatharewhatformtheembedding,sothattherelationshipbetweentwonodescan beeectivelycapturedbytheembedding[59]. 5.1.2 ParseTree. Aparsetreerepresentsthehierarchyoftokens,i.e.,theprogram’sterminalandnon-terminal symbols.Thisdatastructureisgeneratedbythelanguage’sparser[183].Thus,thenodesrepresentthederivation ofthegrammarthatyieldstheinputstrings.ThisrepresentationhasbeenusedbyCeccatoetal.[180]torepresent SQLqueriesinordertotrainamodelthatdetectsSQLinjectionvulnerabilities. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:8 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry Table2. Sourcecoderepresentations,theircategories,andfrequencyofuseinthesurveyedpapers. Representation Papers # Representation Papers # ControlFlowGraph(CFG) [12,13,34– 14 ComponentDependencyGraph(CDG) [27] 1 36,79–87] ProgramDependenceGraph(PDG) [12,88–94] 8 ContextualICFG(CICFG) [26] 1 DataFlowGraph(DFG) [13,36,79,81,85, 7 ContextualPermissionDependencyGraph [26] 1 95,96] (CPDG) Callgraph [20,22,25,34,80, 6 Contextual Source and Sink Dependency [26] 1 97] Graph(CSSDG) CodePropertyGraph(CPG) [12,98–101] 5 CrucialDataFlowGraph(CDFG) [102] 1 InterproceduralControlFlowGraph(ICFG) [18,19,26] 3 ProgramGraph [103] 1 ContextualAPIDependencyGraph(CADG) [19,26] 2 PropagationChain [104] 1 ContractGraph [46,105] 2 PropertyGraph [45] 1 SystemDependenceGraph(SDG) [106,107] 2 SemanticGraph [108] 1 SimpliedCPG [109,110] 2 SlicePropertyGraph(SPG) [111] 1 |
ProgramSlices [14,112] 2 BG ValueFlowGraph(VFG) [44] 1 TokenGraph [113,114] 2 Tokenizer [11,15,17,37– 43 39,53,54,83,87– 91,104,115–142] BG CodeAggregateGraph(CAG) [143] 1 intermediatecodeandSemantics-basedVul- [48,144,145] 3 nerabilityCandidate(iSeVC) ComponentBehaviorGraph(CBG) [27] 1 sourcecodeandSyntaxbasedVulnerability [48,144] 2 Candidate(sSyVC) Codemetrics [97,116,131,132,16 BPESubwordTokenization [43] 1 146–157] Codegadgets [14,41,107,158– 7 codeBERT [162] 1 161] Image [21,88,93] 3 ContractSnippet [47] 1 APICalls [24] 1 L doc2vec [163] 1 ApplicationInformation [23] 1 AbstractSyntaxTree(AST) [12,16,29–33,36,32 79,81,86,89– 91,109,140,142, 157,161,164– 175,175,176] OpcodeSequences [177] 1 AST+ [51,178] 2 M RegularExpression [179] 1 T ParseTree [180] 1 (cid:49)(cid:99)(cid:115)(cid:111)(cid:71)(cid:75)(cid:2)(cid:12)(cid:99)(cid:73)(cid:75) (cid:3)(cid:70)(cid:112)(cid:114)(cid:111)(cid:62)(cid:71)(cid:114)(cid:2)(cid:49)(cid:123)(cid:96)(cid:114)(cid:62)(cid:122)(cid:2)(cid:50)(cid:111)(cid:75)(cid:75)(cid:2)(cid:207)(cid:3)(cid:49)(cid:50)(cid:208) (cid:45)(cid:62)(cid:111)(cid:112)(cid:75)(cid:2)(cid:50)(cid:111)(cid:75)(cid:75) (cid:134)(cid:135)(cid:136)(cid:3)(cid:136)(cid:151)(cid:144)(cid:133)(cid:383)(cid:154)(cid:345)(cid:3)(cid:155)(cid:384)(cid:347) (cid:80)(cid:115)(cid:96)(cid:71) (cid:127)(cid:93)(cid:75)(cid:198)(cid:83)(cid:96)(cid:108)(cid:115)(cid:114) (cid:31)(cid:45)(cid:3)(cid:48) (cid:207) (cid:114)(cid:80)(cid:108)(cid:73)(cid:75)(cid:80) (cid:34)(cid:3)(cid:33)(cid:16) (cid:91) (cid:3) (cid:3)(cid:3) (cid:3)(cid:139) (cid:140)(cid:3) (cid:3)(cid:688) (cid:688)(cid:3) (cid:3)(cid:154) (cid:154)(cid:3) (cid:3)(cid:683) (cid:350)(cid:3) (cid:3)(cid:155) (cid:155) (cid:62)(cid:111)(cid:81)(cid:115)(cid:95)(cid:75)(cid:96)(cid:114)(cid:112) (cid:249) (cid:249) (cid:83)(cid:80) (cid:112)(cid:114)(cid:95)(cid:114) (cid:16)(cid:34)(cid:14)(cid:33)(cid:3)(cid:48)(cid:30)(cid:16)(cid:48) (cid:108)(cid:62)(cid:111)(cid:62)(cid:95)(cid:75)(cid:114)(cid:75)(cid:111)(cid:112) (cid:48)(cid:114)(cid:123) (cid:45)(cid:108) (cid:3)(cid:75) (cid:48)(cid:73)(cid:62)(cid:111)(cid:81)(cid:112)(cid:93)(cid:83) (cid:12)(cid:112)(cid:114) (cid:114)(cid:12) (cid:80)(cid:108)(cid:36) (cid:73)(cid:33) (cid:75)(cid:33) (cid:80)(cid:3) (cid:34)(cid:3)(cid:33)(cid:15) (cid:16) (cid:92) (cid:122) (cid:123) (cid:83) (cid:245) (cid:90) (cid:211) (cid:249)(cid:249) (cid:111)(cid:75)(cid:114)(cid:115)(cid:111)(cid:96) (cid:71)(cid:99)(cid:95)(cid:108)(cid:99)(cid:115)(cid:96)(cid:73)(cid:198)(cid:112)(cid:114)(cid:95)(cid:114) (cid:80)(cid:115)(cid:96)(cid:71)(cid:73)(cid:75)(cid:80) (cid:12)(cid:36)(cid:31)(cid:36)(cid:34) (cid:29) (cid:34)(cid:16)(cid:57)(cid:31)(cid:24)(cid:34)(cid:16) (cid:63)(cid:81) |
(cid:3) (cid:3)(cid:3) (cid:3)(cid:3)(cid:139) (cid:3)(cid:136) (cid:148)(cid:3) (cid:135)(cid:383) (cid:150)(cid:139) (cid:151)(cid:3) (cid:148)(cid:688) (cid:144)(cid:688) (cid:3)(cid:3) (cid:139)(cid:140)(cid:384)(cid:347)(cid:3) (cid:122) (cid:123) (cid:122) (cid:123) (cid:83) (cid:90) (cid:83) (cid:34) (cid:134)(cid:3) (cid:135)(cid:33) (cid:136)(cid:16) (cid:34) (cid:136)(cid:3) (cid:151)(cid:33) (cid:144)(cid:133)(cid:16) (cid:112)(cid:115)(cid:83)(cid:114)(cid:75) (cid:112)(cid:114)(cid:24) (cid:95)(cid:34)(cid:14) (cid:114)(cid:16)(cid:34)(cid:50) (cid:17)(cid:17)(cid:17) (cid:85)(cid:72)(cid:63) (cid:80)(cid:87) (cid:68)(cid:76)(cid:81)(cid:76)(cid:81)(cid:74)(cid:3)(cid:81)(cid:82)(cid:71)(cid:72)(cid:86)(cid:3)(cid:75)(cid:76)(cid:71)(cid:71)(cid:72)(cid:81)(cid:3)(cid:71)(cid:88)(cid:72)(cid:3)(cid:87)(cid:82)(cid:3)(cid:86)(cid:83)(cid:68)(cid:70)(cid:72)(cid:3)(cid:70)(cid:82)(cid:81)(cid:86)(cid:87)(cid:85)(cid:68)(cid:76)(cid:81)(cid:87)(cid:86) Fig.2. ExamplesoftreerepresentationsforthesamePythonsourcecode AlthoughparsetreesandASTsbothrepresentsourcecodeinatreestructure,theirkeydierenceisthatASTs aremuchsimpler thanparsetrees,astheyabstractawaygrammar-relatednodeswhileparsetreesretainthese tokensandtheirmeaningswithrespecttotheirgrammar.Fig.2demonstrateshowthesetwotreerepresentations (ASTandparsetrees)dierforthesamePythoncode.Noticehowtheparsetreeretainedeverysymbolinthe ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:9 code(e.g.,newlines,andindentation)whiletheASTabstractedthoseaway.Sinceparsetreesaremoreverbose thanASTs,thework[180]thatusedithadapreprocessingstepthatremovedfromthetreenodesthatwere irrelevanttodetectattacks(e.g.,specicuserids). 5.1.3 AST+. Onepaper[178]usedarepresentationthatisanenhancedversionofanAST(whichwedenotein ourmanuscriptasAST+).Thatworkusesaconvention[184]thatdescribesASTnodesinthreetypes:placeholder, API, and syntax nodes. The ASTs are serialized and traversed using depth rst traversal, and each node and elementismappedtoavector.Xiaetal.[51]donotspecifythemodicationsmadetotheAST,howeverthe paperstatesthatadditionaledgesareaddedtotheASTtocapturemoresemanticandstreaminformation.This representationwasusedforvulnerabilitydetection[51,178]. 5.2 Graph-BasedRepresentations Graph-basedrepresentationsarethosethattransformsourcecodeintosomesortofgraphform,withnodes andedgesrepresentingcertaincharacteristicsandrelationships,respectively,betweeneachcodeelement.Graph- basedrepresentationscanbeembeddedusingG2[58],asitisanoptimizedmethodtotransformthe graphsintothelowdimensionalnumericalvectorsthatthemodelswilllearnfrom. 5.2.1 ControlFlowGraph(CFG). ACFG[185]wasthemostpopulargraphrepresentationusedin14papers [12,13,34–36,79–87].ACFGisadirectedgraph6= +,⇢ withnodesE + andedges4 ⇢ where⇢ + +. ( ) 2 2 ✓ ⇥ Thesetofnodes+ representsthebasicblocksofaprogram’sprocedure(i.e.,afunction/method),whiletheedge set⇢ represents the control ow between the basic blocks. A basic block is a group of instructions that are executedinorder,oneaftertheother.ACFG’sedge4 =E E denotesthattheprogram’sexecutioncan BA2 3BC ! owfromE BA2 toE 3BC.Forexample,Fig.3showstheCFGforthefunctionfunc(x,y).Ithasanentryandanexit basicblock,todenotethestartandendofthefunctionexecution,respectively.Theentryblockisconnectedtoa basicblockthathasthreeinstructions(i.e.,i=x+y,j=x-y,andif i==j).Thisbasicblockhastwooutgoingedges: onerepresentstheowwhentheifconditionevaluatestotrue,andtheotherdenotestheowwhenitevaluates tofalse.Afterexecutingoneofthebranches,theexecutionowsintotheexit block. (cid:134)(cid:135)(cid:136)(cid:3)(cid:136)(cid:151)(cid:144)(cid:133)(cid:383)(cid:154)(cid:345)(cid:3)(cid:155)(cid:384)(cid:347) (cid:12)(cid:62)(cid:93)(cid:93)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82) |
(cid:3)(cid:3)(cid:139)(cid:3)(cid:688)(cid:3)(cid:154)(cid:3)(cid:683)(cid:3)(cid:155) (cid:3) (cid:3)(cid:3) (cid:3)(cid:140) (cid:139)(cid:3) (cid:136)(cid:688) (cid:3)(cid:3) (cid:383)(cid:154) (cid:139)(cid:3) (cid:3)(cid:350) (cid:688)(cid:3) (cid:688)(cid:155) (cid:3)(cid:140)(cid:384)(cid:347)(cid:3) (cid:95)(cid:62)(cid:83)(cid:96) (cid:3)(cid:3)(cid:3)(cid:3)(cid:148)(cid:135)(cid:150)(cid:151)(cid:148)(cid:144)(cid:3)(cid:139) (cid:3) (cid:134)(cid:135)(cid:136)(cid:3)(cid:143)(cid:131)(cid:139)(cid:144)(cid:383)(cid:384)(cid:347) (cid:3) (cid:143)(cid:3) (cid:131)(cid:136) (cid:139)(cid:151) (cid:144)(cid:144) (cid:383)(cid:133) (cid:384)(cid:383)(cid:617)(cid:345)(cid:618)(cid:384) (cid:80)(cid:115)(cid:96)(cid:71) (cid:75)(cid:73)(cid:99)(cid:12)(cid:2)(cid:75)(cid:71)(cid:111)(cid:115)(cid:99)(cid:49) (cid:12)(cid:21)(cid:22)(cid:2)(cid:80)(cid:99)(cid:111)(cid:2)(cid:80)(cid:115)(cid:96)(cid:71)(cid:207)(cid:122)(cid:185)(cid:123)(cid:208) (cid:24)(cid:12)(cid:21)(cid:22) (cid:14)(cid:21)(cid:22)(cid:2)(cid:80)(cid:99)(cid:111)(cid:2)(cid:80)(cid:115)(cid:96)(cid:71)(cid:207)(cid:122)(cid:185)(cid:123)(cid:208) (cid:45)(cid:14)(cid:22)(cid:2)(cid:80)(cid:99)(cid:111)(cid:2)(cid:80)(cid:115)(cid:96)(cid:71)(cid:207)(cid:122)(cid:185)(cid:123)(cid:208) (cid:111)(cid:75)(cid:114)(cid:115)(cid:111)(cid:96)(cid:2)(cid:83) (cid:83)(cid:2)(cid:249)(cid:2)(cid:122)(cid:2)(cid:245)(cid:2)(cid:123) (cid:114)(cid:111)(cid:115)(cid:75) (cid:111)(cid:75)(cid:114)(cid:115)(cid:111)(cid:96)(cid:2)(cid:83) (cid:45)(cid:3)(cid:48)(cid:3)(cid:33)(cid:2)(cid:24)(cid:34)(cid:184)(cid:2)(cid:123) (cid:83)(cid:2)(cid:249)(cid:2)(cid:122)(cid:2)(cid:245)(cid:2)(cid:123) (cid:16)(cid:34)(cid:50)(cid:48)(cid:59) (cid:83) (cid:90)(cid:2) (cid:2)(cid:249) (cid:249)(cid:2) (cid:2)(cid:122) (cid:122)(cid:2) (cid:2)(cid:245) (cid:211)(cid:2)(cid:2) (cid:123)(cid:123) (cid:114)(cid:111)(cid:115)(cid:75) (cid:16)(cid:34)(cid:50)(cid:48)(cid:59) (cid:90) (cid:83)(cid:2) (cid:80)(cid:249) (cid:2)(cid:83)(cid:2) (cid:2)(cid:122) (cid:249)(cid:2) (cid:249)(cid:211) (cid:2)(cid:2) (cid:90)(cid:123) (cid:184) (cid:80)(cid:62)(cid:93)(cid:112)(cid:75) (cid:16)(cid:58)(cid:24)(cid:50) (cid:90)(cid:2)(cid:249)(cid:2)(cid:122)(cid:2)(cid:211)(cid:2)(cid:123) (cid:83)(cid:80)(cid:2)(cid:207)(cid:83)(cid:2)(cid:249)(cid:249)(cid:2)(cid:90)(cid:208) (cid:111)(cid:75)(cid:114)(cid:115)(cid:111)(cid:96)(cid:2)(cid:83) (cid:16)(cid:34)(cid:50)(cid:48)(cid:59)(cid:184)(cid:2)(cid:80)(cid:115)(cid:96)(cid:71)(cid:207)(cid:122)(cid:185)(cid:123)(cid:208) (cid:83)(cid:80)(cid:2)(cid:83)(cid:2)(cid:249)(cid:249)(cid:2)(cid:90)(cid:184) (cid:111)(cid:75)(cid:114)(cid:115)(cid:111)(cid:96)(cid:2)(cid:83) |
(cid:83)(cid:80)(cid:2)(cid:83)(cid:2)(cid:249)(cid:249)(cid:2)(cid:90)(cid:184) (cid:80)(cid:62)(cid:93)(cid:112)(cid:75) (cid:16)(cid:58)(cid:24)(cid:50) (cid:16)(cid:34)(cid:50)(cid:48)(cid:59) (cid:80)(cid:115)(cid:96)(cid:71)(cid:62) (cid:71)(cid:207)(cid:93)(cid:93) (cid:134)(cid:184) (cid:185)(cid:135)(cid:208) (cid:80)(cid:115)(cid:111)(cid:75) (cid:96)(cid:114) (cid:71)(cid:115) (cid:207)(cid:111) (cid:134)(cid:96) (cid:185)(cid:135)(cid:184) (cid:208) (cid:16)(cid:58)(cid:24)(cid:50) (cid:83)(cid:2)(cid:249)(cid:2)(cid:122)(cid:2)(cid:245)(cid:2)(cid:123) (cid:45)(cid:3)(cid:48)(cid:3)(cid:33)(cid:2)(cid:24)(cid:34)(cid:184)(cid:2)(cid:122) (cid:90)(cid:2)(cid:249)(cid:2)(cid:122)(cid:2)(cid:211)(cid:2)(cid:123) (cid:71) (cid:73)(cid:99) (cid:62)(cid:96) (cid:114)(cid:114) (cid:62)(cid:111) (cid:2)(cid:99) (cid:73)(cid:93) (cid:75)(cid:2)(cid:73) (cid:108)(cid:75) (cid:75)(cid:108) (cid:96)(cid:75) (cid:73)(cid:96) (cid:75)(cid:73) (cid:96)(cid:75) (cid:71)(cid:96) (cid:123)(cid:71)(cid:123) (cid:208)(cid:123)(cid:185)(cid:122)(cid:207)(cid:71)(cid:96)(cid:115)(cid:80) (cid:208)(cid:207)(cid:96)(cid:83)(cid:62)(cid:95) (cid:616)(cid:348) (cid:617)(cid:348) (cid:618)(cid:348) (cid:619)(cid:348) (cid:620)(cid:348) (cid:621)(cid:348) (cid:622)(cid:348) (cid:623)(cid:348) (cid:624)(cid:348) Fig.3. Examplesofgraph-basedrepresentations(CFG,ICFG,DFG,PDG,andcallgraph)onthesamePythoncode. 5.2.2 InterproceduralControlFlowGraph(ICFG). AnICFGisavariationoftheCFGthatdescribesnotonly intra-proceduralowsamongthebasicblocks,butalsointer-proceduralones[19].AnICFGconnectsindividual CFGsatthecallsitesinordertorepresentcontrolowsacrossprocedures.Thus,theICFGallowsthemodelto understandthecontrolowofthewholeprogram,whereastheCFGallowsthemodeltounderstandthecontrol owofaspecicprocedure[186].Forexample,Fig.3showstheICFGfortheentireprogram,includingfunc(x,y) andmain().Ithastwoentry blocks,oneformain,wheretheprogramstarts,andanotherforfunc.Italsohas twoexit blockswhichindicatetheendoffunctionexecutionforbothmainandfunc.Theentryblockformainis connectedtothebasicblockthatcallsfunc,which,inturn,isconnectedtothecallee’sentryblock.Tocapture theowfromtheinvokedfunction(i.e.,func(x,y))backtoitscaller(i.e.,main()),thisrepresentationincludesan edgefromthecallee’sexit blocktothecaller’sreturncallsiteblock. 5.2.3 DataFlowGraph(DFG). SevenpapersusedaDataFlowGraph(DFG)whichisagraph⌧ = +,⇢ , ( ) wherethenodesE + arestatementsinthesourcecode,andtheedgeset4 ⇢ arethedatadependencies 2 2 ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:10 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry betweenthenodes.Thatis,anedge4 =E E indicatesthatthenodeE usesdatathathasbeendened BA2 3BC 3BC ! byE .Forexample,Fig.3showstheDFGforaPythonfunction.Therearetwooutgoingedgesi=x+ytotwo BA2 statementsthatusethevariablei.Similarly,thereisanedgefromj=x-ytoif i==jbecausetheexpressionis usingthevariablej. 5.2.4 ProgramDependenceGraph(PDG). PDGswerethesecondmostpopulargraph-basedrepresentation,being used by 8 papers. A Program Dependence Graph (PDG) [187] is a directed graph6 = +,⇢ that shows ( ) thedataandcontrol dependenciesforeachstatementinaprogram’sprocedure.Thesetofnodes+ inaPDG is partitioned into two types: statement nodes+ BC<C and predicate expression nodes+ ?A43. A statement node E BC<C + BC<C representssimplestatementsinaprogramthatareactionstobecarriedoutbyaprogram(e.g.,x = 2 2;).ApredicatenodeE ?A43 + ?A43 denotesstatementsthatevaluatetotrueorfalse(e.g.,x != 2).Theedgeset⇢ 2 inaPDGhastwopartitions:controldependencyedges⇢ 2 anddatadependencyedges⇢ 3.Acontroldependency edge4 =E E indicatesthatE onlyexecutesifthepredicateexpressioninE evaluatestotrue.Adata 2 BA2 3BC 3BC BA2 ! dependencyedge4 =E E denotesthatE usesdatathathasbeendenedbyE . 3 BA2 3BC 3BC BA2 ! Fig.3hasanexampleofaPDGforaPythonfunction(func(x,y)),wherethedashedandstraightlinesrepresent controldependenciesanddatadependencies,respectively.ThePDGstartswithanentrynodeforthisprocedure. Ithastwoparaminnodestorepresentthefunction’sparameters(xandy).Forthestatementsinlines2-4to |
execute,thefunction’sentrymusthaveexecuted.Assuch,thereisacontroldependencyedgefromtheentry tothenodesrepresentingtheselinesofcode:i=x+y,j=x-y,andif i == j.Sincethestatementsinlines2and3 denevariablesthatareusedintheifcondition,thereisdatadependencyedgefromthesevariableassignments statementstotheifcondition.Thereisalsoadatadependencyedgefromthe i=x+y tothereturnstatement, sincethisreturnnodeusesthevariablei.Giventhatthereturnstatementonlyexecuteswhentheifcondition evaluatestotrue,thereiscontroldependencybetweentheifnodeandthereturnnode. 5.2.5 CallGraph. Acallgraphisadirectedgraph6= +,⇢ inwhichthenodesarethefunctions/methodsina ( ) program,whereastheedgesrepresentscaller-calleerelationshipsamongprogram’sprocedures[188].Anedge 4 =E BA2 E 3BC denotesthatE BA2 invokesE 3BC.Thesegraphscanbeoftwotypes:staticanddynamiccallgraphs. ! Dynamiccallgraphsgiveinformationregardingtheprocedurecallsofaprogramwhileitisbeingexecuted. Itshowsthesequenceoffunction/methodcalls,andtheparametersthatarepassedtoeachprocedureinthe sequence.Staticcallgraphsonlygiveinformationaboutthepotential executionpathsaprogramcanhave basedoninformationavailableatcompiletime.Thus,astaticcallgraphisnotasaccurateinreectingtheactual callsinaprogram,particularlyiftheprogramiscomplex[188].The6papersincludedinthissurveyusedstatic callgraphs[20,22,25,34,80,97].Fig.3showsthecallgraphforthePythoncodesnippetprovidedinit. 5.2.6 SystemDependencyGraph(SDG). TwopapersrepresentedsourcecodeusingSDGs[106,107].AnSDGis agraphwithmultiplePDGsconnectedviathecaller-calleerelationgivenbyacallgraph.SDGsextendPDGs bydescribingtheinter-procedural relationshipsbetweentheprogram’sentrypoints4 andtheproceduresthey call[106].ToconnectthePDGs,thereareadditionalnodesandedgeswhichdictatetheactualinputparameters andactualoutputvaluesofaprocedure.Everypassedargumenthasanactualinnode0 8,andaformal-innode 5 whichareconnectedbytheparameter-inedge0 5.Everymodiedparameterandreturnedvaluehas 8 8 8 ! anactual-outnode0 andaformal-outnode5 ,whichareconnectedbytheparameter-outedge5 0 .The > > > > ! formal-inand-outnodesarecontroldependentontheentrynode4 andactual-inand-outnodesarecontrol dependentonthecallnode2.Thisparameterpassingmodelensuresthatinterproceduraleventsofaprocedure arepropagatedbythecallsites. 4Entrypointsarethefunctions/methodsthatstartstheprogramexecution,e.g.,themain()functioninC. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:11 Forexample,Fig.4showstheSDGfortheentireprogram.TheSDGstartswiththeentrynodeformain(),which istheentrypointfunctioninthecallgraph.Therstentrynodefrommainhasacontrolowedgetofunc.Two actualinnodeshavedataowedges,asthedataisinitializedfrommainandowstofunc.Therearealsotwo actualinnodes,whichdenetheparametersenteringtheprocedurefunc(x,y).Theentry nodeinfunchasa controlowedgetothestatementnodeswhichdenethevariablesiandj,andthetwoparaminnodeshave adataowedgetothosesametwonodes;i=x+yandj=x-y.Thesestatementnodesthenbothhaveadataow tothepredicatenodeif i == j.Theentrynodehasacontroldependencyedgetothisnodeandtheformalin nodes.Finally,thispredicatenodehasacontrolowedgetothereturn iblock,alongwithi=x+ynode,except thisnodehasadatadependencyedge.Thedashedlineinthisguredepictcontroldependenciesandthesolid linedepictsdatadependencies. (cid:134)(cid:135)(cid:136)(cid:3)(cid:136)(cid:151)(cid:144)(cid:133)(cid:383)(cid:154)(cid:345)(cid:3)(cid:155)(cid:384)(cid:347) (cid:3)(cid:3)(cid:139)(cid:3)(cid:688)(cid:3)(cid:154)(cid:3)(cid:683)(cid:3)(cid:155) (cid:3)(cid:3)(cid:140)(cid:3)(cid:688)(cid:3)(cid:154)(cid:3)(cid:350)(cid:3)(cid:155) (cid:3)(cid:3)(cid:139)(cid:136)(cid:3)(cid:383)(cid:139)(cid:3)(cid:688)(cid:688)(cid:3)(cid:140)(cid:384)(cid:347)(cid:3) (cid:3)(cid:3)(cid:3)(cid:3)(cid:148)(cid:135)(cid:150)(cid:151)(cid:148)(cid:144)(cid:3)(cid:139) (cid:3) (cid:134)(cid:135)(cid:136)(cid:3)(cid:143)(cid:131)(cid:139)(cid:144)(cid:383)(cid:384)(cid:347) (cid:3)(cid:3)(cid:156)(cid:688)(cid:136)(cid:151)(cid:144)(cid:133)(cid:383)(cid:617)(cid:345)(cid:618)(cid:384) (cid:143)(cid:131)(cid:139)(cid:144)(cid:383)(cid:384) (cid:75)(cid:73)(cid:99)(cid:12)(cid:2)(cid:75)(cid:71)(cid:111)(cid:115)(cid:99)(cid:49) |
(cid:616)(cid:348) (cid:49)(cid:14)(cid:22) (cid:207)(cid:11)(cid:62)(cid:71)(cid:92)(cid:121)(cid:62)(cid:111)(cid:73)(cid:208)(cid:2)(cid:45)(cid:111)(cid:99)(cid:81)(cid:111)(cid:62)(cid:95)(cid:2)(cid:49)(cid:93)(cid:83)(cid:71)(cid:75) (cid:12)(cid:14)(cid:21)(cid:22)(cid:2)(cid:80)(cid:99)(cid:111)(cid:2)(cid:80)(cid:115)(cid:96)(cid:71)(cid:207)(cid:122)(cid:185)(cid:123)(cid:208) |
Fig.4. Examplesofgraphrepresentations(SDG,BackwardProgramSlices&CDFG) 5.2.7 ProgramSlices. Aprogramslice[189]isasubgraphofaPDGorSDGthatincludesonlythenodesthatare relevanttoacomputationataspecicpointintheprogram.Thissubgraphiscomputedusingaslicingcriterion E,? whichdenotesavariableofinterestE ataprogrampoint?.Theseslicescanbecomputedinabackward or h i forward fashion.AbackwardsliceincludesallthenodesthatmayaectthevalueofE attheprogrampoint?. AforwardsliceincludesallnodesthatareaectedbythevariableE attheprogrampoint?.Programslices wereusedby2papers[14,112]todetectvulnerabilities.Theslicingcriterionisdeterminedbystatementsinthe codethatareconsideredasvulnerable.Thestatementscouldalsobepointswherevaluesarechanged,which couldthenleadtoanAPIcallbeingvulnerable.Chengetal.[112]useaPDGandperformforwardandbackward slicingfromthenodeofinterest.Itisnotspeciedin[14]whetheraPDGorSDGisused,butthesamecriterion forbackwardsandforwardsslicingareused(i.e.,forwardslicesincludestatementsthatareaectedbythenode ofinterest,andbackwardslicesincludestatementsthataectthenodeofinterest).Fig.4showsanexampleof abackwardprogramsliceovertheSDGwiththeslicecriterion 9,;8=4 3 .Thenodesthathavecontrolordata h i dependenciestothenodeofinterest(i.e.,j = x - y)arepartoftheresultingprogramslice. 5.2.8 CrucialDataFlowGraph(CDFG). ACDFG,introducedbyWuetal.[102]isasubgraphofaDFGgraph thatcontainsonlythecrucialinformationfromtheDFGthatcouldtriggerareentrancyvulnerabilityinSmart contracts.Thecrucialnodesarevariablescontainingsensitiveorcriticalinformation,andthathaveadirectdata owtoanothercrucialnode.ACDFGisdenedas⇠⇡ ⌧ = +,⇢ ,whereE + arethecrucialnodesandthe ( ) 2 edges4 ⇢representthedataowrelationship.Forexample,4 =E E indicatesthatE andE areboth BA2 3BC BA2 3BC 2 ! crucialnodes,andthatthereisadataowbetweenthetwovariables.InFigure4,ourcrucialnodesaretheones shown:anynodesthathavetodealwithmsg,sender,balances,and_am.Thesenodesreceiveorcomputedata, andcanberesponsibleforareentrancyvulnerability. 5.2.9 ProgramGraph. Wangetal.[103]introducedtheconceptof programgraphs,whichisadirectedgraph 6= +,⇢ inwhichthenodesE + canbestatements,identiers(e.g.,functiondeclarationsorvariables),orvalues. ( ) 2 Thisgraphhaseighttypesofedges:control-owedges,dataowedges,guardedbyedges,computedfromedges, nexttokenedges,lastuseedges,andlastlexicaluseedges.Acontrolowedge4 2CA =E BA2 E 3BC indicatesthatE 3BC ! canexecuteafterE BA2.Adataowedge4 30C0 =E BA2 E 3BC indicatesthatE 3BC usesavariablethathasbeendened ! byE BA2.Aguardedby edge4 6 =E BA2 E 3BC indicatesthatE 3BC onlyexecutesiftheexpressioninE BA2 evaluates ! ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:12 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry totrue(whichisusefultoidentifyoperationsthatmaybeinthewrongorder).Ajumpedge4 9 =E BA2 E 3BC ! indicatesthatE 3BC hasacontroldependencyfromE BA2.AComputedFromedge4 2><? A>< =E BA2 E 3BC indicates ! thatE BA2 isorcontainsavariableusedinanexpressioninE 3BC.ANextTokenedge4 =4GC =E BA2 E 3BC indicatesthat ! E 3BC isasuccessorof(i.e.,follows)E BA2,whereE 3BC andE BA2 areterminalnodesortokensfromtheAST.ALastUse edge4 ;0BC = E BA2 E 3BC indicatesthatE 3BC usesthesamevariablethatisusedinE BA2.ALastLexicalUse edge ! 4 =E E indicatesthatE usesthesamevariablethatisusedinE ifE isanifstatement. ;0BC!4G BA2 3BC 3BC BA2 BA2 ! 5.2.10 Code Property Graph (CPG). Used by 5 papers [12, 98–101], a Code Property Graph (CPG) is a combinationofASTs,CFGsandPDGs[52].ItwasrstintroducedbyYamaguchietal.[52]specicallyasa waytodetectvulnerabilitiesinC/C++programsusingstaticanalysis.ThewayaCPGisgeneratedisbytaking the AST, CFG and PDG of a program, modeling them as property graphs, and then these models are jointly combinedbyconnectingstatementandpredicatenodes.ACPGisformallydenedas6= +,⇢,_,` ,whichisa ( ) directed,labelled,attributedmultigraph,withnodesE +,edges4 ⇢,edgelabelingfunction_andaproperty 2 2 mappingfunction`.Thesetofnodes+ inaCPGarethenodesfromanAST.Theedgeset⇢ inaCPGhasthree partitions:controlowedges⇢ 25 + +,programdependencyedges⇢ ?3 + +,andabstractsyntaxtreeedges ✓ ⇥ ✓ ⇥ ⇢ 0BC + +.Acontrolowdependency4 25 =E BA2 E 3BC indicatesthatE BA2 canowtoE 3BC inthenextstepofthe ✓ ⇥ ! program.Aprogramdependencyedge4 ?3 =E BA2 E 3BC indicatesthatE 3BC hasaprogramdependenceedgefrom ! E BA2.Anabstractsyntaxtreeedge4 0BC =E BA2 E 3BC indicatesthatE 3BC issyntacticallyrelatedtoE BA2.Theedge ! labelingfunction_ :⇢ ⌃assignsalabelfromthealphabet⌃toeachedgein⇢.Thefunction` : + ⇢ ( ! ( [ )⇥ ! appliespropertiestonodesandedges,where isthesetofpropertykeysand( isthesetofpropertyvalues. SinceaCPGisacombinationofsomanyrepresentations,itprovidesaveryrobustunderstandingofcode.Other implementationsofaCPGenhanceitbyaddinginformationfromaDataFlowGraph(DFG)[63]. Figure5demonstratestheCPGforfunc().Wehavetheentrynodeatthestart,demonstratingtheentranceinto thefunction.Fromtheentrynode,wehaveacontrolowedgetothedeclarationnode,whichthenbranchesto showtheAST nodesandedgesfortheline i=x+y.Wethenhaveanothercontrolowedgefromthedeclaration nodetoanotherdeclarationnode.ThisnodebranchesdowntoshowtheASTnodesandedgesfortheline j=x-y. Fromthisnode,wehaveacontrolowedgetoapredicatenode.WealsohavePDGedgesfromtherstandsecond declarationnodetothispredicatenode,asthepredicatenodedependsonthedatafromthetwodeclaration nodes.ThepredicatenodealsohasASTnodesandedgestoshowtheline i==j.Fromhere,wehaveacontrol owedgetoareturnstatement.WealsohaveaPDGedgetothisnodefromthepredicatenode,asthereturn |
statementdependsontheresultfromthepredicateedge.Wenallyhaveacontrolowedgetotheexit node fromthereturn.Theexitnodealsohasacontrolowedgefromthepredicatenodebecauseifthepredicate evaluatestofalse,theprogramterminates. (cid:134)(cid:135)(cid:136)(cid:3)(cid:136)(cid:151)(cid:144)(cid:133)(cid:383)(cid:154)(cid:345)(cid:3)(cid:155)(cid:384)(cid:347) (cid:3)(cid:3)(cid:139)(cid:3)(cid:688)(cid:3)(cid:154)(cid:3)(cid:683)(cid:3)(cid:155) (cid:3)(cid:3)(cid:140)(cid:3)(cid:688)(cid:3)(cid:154)(cid:3)(cid:350)(cid:3)(cid:155) (cid:3)(cid:3)(cid:139)(cid:136)(cid:3)(cid:383)(cid:139)(cid:3)(cid:688)(cid:688)(cid:3)(cid:140)(cid:384)(cid:347)(cid:3) (cid:3)(cid:3)(cid:3)(cid:3)(cid:148)(cid:135)(cid:150)(cid:151)(cid:148)(cid:144)(cid:3)(cid:139) (cid:3) (cid:134)(cid:135)(cid:136)(cid:3)(cid:143)(cid:131)(cid:139)(cid:144)(cid:383)(cid:384)(cid:347) (cid:3)(cid:3)(cid:136)(cid:151)(cid:144)(cid:133)(cid:383)(cid:617)(cid:345)(cid:618)(cid:384) (cid:143)(cid:131)(cid:139)(cid:144)(cid:383)(cid:384) (cid:75)(cid:73)(cid:99)(cid:12)(cid:2)(cid:75)(cid:71)(cid:111)(cid:115)(cid:99)(cid:49) (cid:616)(cid:348) (cid:617)(cid:348) (cid:618)(cid:348) (cid:134)(cid:135)(cid:136)(cid:3)(cid:143)(cid:151)(cid:142)(cid:150)(cid:139)(cid:146)(cid:142)(cid:155)(cid:383)(cid:154)(cid:345)(cid:3)(cid:155)(cid:384)(cid:347) (cid:619)(cid:348) (cid:3)(cid:3)(cid:156)(cid:3)(cid:688)(cid:3)(cid:154)(cid:3)(cid:395)(cid:3)(cid:155)(cid:3) (cid:620)(cid:348) (cid:3)(cid:3)(cid:148)(cid:135)(cid:150)(cid:151)(cid:148)(cid:144)(cid:3)(cid:156) (cid:621)(cid:348) (cid:134)(cid:135)(cid:136)(cid:3)(cid:136)(cid:145)(cid:145)(cid:383)(cid:384)(cid:347) (cid:68)(cid:3)(cid:91)(cid:3)(cid:69) (cid:622)(cid:348) (cid:3)(cid:3)(cid:131)(cid:3)(cid:688)(cid:3)(cid:620) (cid:623)(cid:348) (cid:3)(cid:3)(cid:132)(cid:3)(cid:688)(cid:3)(cid:616)(cid:613) (cid:624)(cid:348) (cid:3)(cid:3)(cid:133)(cid:3)(cid:688)(cid:3)(cid:143)(cid:151)(cid:142)(cid:150)(cid:139)(cid:146)(cid:142)(cid:155)(cid:383)(cid:131)(cid:345)(cid:132)(cid:384) Fig.5. Examplesofgraphrepresentations(CPG,CAG,andVFG)onthesamecodesnippet 5.2.11 SimplifiedCodePropertyGraph(SCPG). Whilecodepropertygraphsareabletocapturerichsemantic andsyntacticinformation,itisalsoverycomplextocreate.GeneratingaPDGalonehasacomplexityofO(n2). Thesizeofthegraphsarealsoratherlarge,oneexamplehaving52millionnodesand87millionedges[52].To solvethisissue,twopapersimplementedaSimplifiedCPG(SCPG)[109,110].AsimpliedCPGonlyuses edgesfromanASTandaCFG,asdatadependencecanbeapproximatedfromthesetwographs.Thenodesinthe ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:13 SCPGhavetwovalues:thecodetokens,andthenodetype.RemovingtheneedtogenerateaPDGgreatlyreduces thecostofgeneratingthisrepresentation,asonewouldonlyneedtogeneratetheASTandCFG. 5.2.12 PropertyGraph. Apropertygraph[45]isvariantofaCPG,denedas6= +,⇢, ⇤,⌃,`,_,f .Here,the ( ) edgesandnodesarethesameastheCPG.Theadjacencyfunction` :⇢ + + mapsanyedgetoanordered ! ⇥ pair of its source and destination vertices. The function_ : + ⇤ maps any given vertex to its respective ! attributes⇤,andf : ⇢ ⌃istheattributefunctionforedges,which,justas_,mapsanygivenedgestoits ! respectiveattributes⌃. 5.2.13 CodeAggregateGraph(CAG). ACodeAggregateGraph(CAG)isbuiltfromacombinationofanAST, CFG,PDG,dominatortree(DT)andpost-dominatortree(PDT).ACAGisformallydenedas6= +,⇢ ,which ( ) isadirectedlabelled,attributedmultigraph,withnodesE + andedges4 ⇢where⇢ + +.Thesetofnodes 2 2 ✓ ⇥ + inaCodeAggregateGrapharethenodesfromanAST.Theedgeset⇢ inaCodeAggregateGraphhasve partitions:controlowedges⇢ 25 + +,programdependencyedges⇢ ?3 + +,abstractsyntaxtreeedges ✓ ⇥ ✓ ⇥ ⇢ 0BC + +,dominatortreeedges⇢ 3C + +,post-dominatortreeedges⇢ ?3C + +.Acontrolowdependency ✓ ⇥ ✓ ⇥ ✓ ⇥ 4 25 = E BA2 E 3BC indicatesthatE |
BA2 canowtoE 3BC inthenextstepoftheprogram.Aprogramdependency ! edge4 ?3 = E BA2 E 3BC indicates thatE 3BC has aprogramdependence edge fromE BA2. An abstract syntaxtree ! edge4 0BC =E BA2 E 3BC indicatesthatE 3BC issyntacticallyrelatedtoE BA2.Adominatortreeedge4 3C =E BA2 E 3BC ! ! indicatesthattheoperationE 3BC isdominatedbyE BA2 andallofE BA2 dominators(i.e.,allpathsfromtheentry nodetoE 3BC rstpassthroughE BA2).Apost-dominatortreeedge4 ?3C =E BA2 E 3BC indicatesthattheoperation ! E ispost-dominatedbyE ,meaningthatallpathsfromE totheendnodemustpassthroughE .Using 3BC BA2 3BC BA2 adominatortreeandpostdominatortreeallowsthisrepresentationtobettercapturesemanticinformationin sourcecode.This,inturn,allowsmodelstoperformbetterinthetaskofvulnerabilitydetection.Nguyenet al.[143]pointsoutcertaininformationthataCFGandanASTinparticularfailtocapture,andhowaDTanda PDTcanbetterdescribetheseattributes. Fig.5demonstratesanexampleofaCAGforthefunctionfunc().Westartwiththeentry node,whichhasa dominatortreeedgetotheDECLnode.TheDECLnodethenhasAST nodesandedgesrepresentingtheline i=x+y. FromtheDECLnode,wehaveadominatortreeandpostdominatortreeedgetoanotherDECLnode.Onceagain, theDECLnodehasAST nodesandedgesrepresentingtheline j=x-y.Next,wehaveadominatortreeandpost dominatortreeedgetothePREDnodefromtheDECLnode.Moreover,wehaveadatadependenceedgefromthe DECLnodedeningiandtheDECLnodedeningjnodes,astheifstatementneedsthedatafrombothofthese nodestoexecute.ThePREDnodehasadominatortree andpostdominatortree edgetotheRETURNnode.The RETURNnodehasadatadependenceedgefromtheDECLnodethatdenesi,sincethereturnstatementdepends onthatnode’sdata.Finally,wehaveadominatortreeedgetotheEXITnode. 5.2.14 ValueFlowGraph(VFG). AValueFlowGraph(VFG)issimilartoaprogramdependencegraphinthat isshowstheinterproceduralprogramdependence.Theedges,justlikeinaPDG,describethecontrolowand datadependencyoftheprogram[190].AVFG6= +,⇢ isadirectedlabelledgraph,withnodesE + andedges ( ) 2 4 ⇢.Thesetofnodes+ areapair W ,W inwhichW isanodefromthepre-directedacyclicgraph(DAG)and 1 2 1 2 ( ) W isanodefromthepost-DAG.BothW andW representthesamevalue.Theedgeset⇢ inaVFGareapair 2 1 2 E,E suchthat# E ,thenodeowgraphofE,isthepredecessorof# E ,thenodeowgraphofE ,andvalues 0 0 0 ( ) ( ) ( ) aremaintainedalongtheconnectingedge[191]. Thepaper[44]thatusedaVFGusesaspecialprocessthatselectsandpreservesfeasiblevalue-owpathsto reducetheamountofdataneededfortrainingmodelsforpath-basedvulnerabilitydetection.Thismakestheir methodmorelightweightthanatypicalValueFlowGraphwouldbe.Fig.5showstheVFGforthecodesnippet provided.Westartwiththenodesaandb.Thesetwonodeshaveanedgeintothemultiply(x,y)node,as ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:14 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry thevaluesfromaandbarepassedintothisfunction.Wethenhaveanedgetonodez,whichrepresentsthe multiplicationoperationonaandb.Finally,zhasanedgeconnectingittoc,whichstoresthevaluefromthe multiplicationoperation. 5.2.15 ComponentDependencyGraph(CDG). AComponentDependencyGraph(CDG)[27]representsthe relationshipsbetweenthedierentcomponentsinagraphandwascreatedtocaptureAndroidappprogram logic.Thecomponentdependencygraphisformallydenedas6= +,⇢ ,whichisadirectedlabelledgraphwith ( ) nodesE + andedges4 ⇢.Thesetofnodes+ inacomponentdependencygraphrepresentthecomponents 2 2 oftheAndroidapp(i.e.,Activity,Service,orBroadcastReceiver).Theedgeset⇢ inacomponentdependency graphrepresenttheactivationrelationshipbetweenthecomponents.Anedge4 = E E indicatesthat BA2 3BC ! thecomponentE couldactivatethestartoflifecycleofthecomponentE .Fig.6showsanexampleofthe BA2 3BC CDGwhichstartsatthecomponent node.Wethenhavethreeedges:oneforstartActivity(),whichleadstoa webpagenode,onefortriggerTasks()whichleadstothebackgroundtasksnode,andnallyasendMessage() edgewhichleadstoamessagehandler node. (cid:3)(cid:3)(cid:134)(cid:135)(cid:136)(cid:3)(cid:151)(cid:146)(cid:134)(cid:131)(cid:150)(cid:135)(cid:24)(cid:149)(cid:135)(cid:148)(cid:19)(cid:148)(cid:145)(cid:136)(cid:139)(cid:142)(cid:135)(cid:383)(cid:151)(cid:149)(cid:135)(cid:148)(cid:12)(cid:7)(cid:345)(cid:3)(cid:146)(cid:148)(cid:145)(cid:136)(cid:139)(cid:142)(cid:135)(cid:7)(cid:131)(cid:150)(cid:131)(cid:384)(cid:347) (cid:3)(cid:3)(cid:3)(cid:3)(cid:139)(cid:136)(cid:3)(cid:383)(cid:133)(cid:138)(cid:135)(cid:133)(cid:141)(cid:24)(cid:149)(cid:135)(cid:148)(cid:19)(cid:135)(cid:148)(cid:143)(cid:139)(cid:149)(cid:149)(cid:139)(cid:145)(cid:144)(cid:383)(cid:151)(cid:149)(cid:135)(cid:148)(cid:12)(cid:7)(cid:384)(cid:384)(cid:347) |
(cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:139)(cid:136)(cid:3)(cid:383)(cid:152)(cid:131)(cid:142)(cid:139)(cid:134)(cid:131)(cid:150)(cid:135)(cid:19)(cid:148)(cid:145)(cid:136)(cid:139)(cid:142)(cid:135)(cid:7)(cid:131)(cid:150)(cid:131)(cid:383)(cid:146)(cid:148)(cid:145)(cid:136)(cid:139)(cid:142)(cid:135)(cid:7)(cid:131)(cid:150)(cid:131)(cid:384)(cid:384)(cid:347)(cid:3) (cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:151)(cid:146)(cid:134)(cid:131)(cid:150)(cid:135)(cid:19)(cid:148)(cid:145)(cid:136)(cid:139)(cid:142)(cid:135)(cid:12)(cid:144)(cid:7)(cid:5)(cid:383)(cid:151)(cid:149)(cid:135)(cid:148)(cid:12)(cid:7)(cid:345)(cid:3)(cid:146)(cid:148)(cid:145)(cid:136)(cid:139)(cid:142)(cid:135)(cid:7)(cid:131)(cid:150)(cid:131)(cid:384)(cid:346) (cid:136)(cid:151)(cid:144)(cid:133)(cid:150)(cid:139)(cid:145)(cid:144)(cid:3)(cid:153)(cid:139)(cid:150)(cid:138)(cid:134)(cid:148)(cid:131)(cid:153)(cid:383)(cid:151)(cid:139)(cid:144)(cid:150)(cid:3)(cid:131)(cid:143)(cid:145)(cid:151)(cid:144)(cid:150)(cid:384)(cid:3)(cid:146)(cid:151)(cid:132)(cid:142)(cid:139)(cid:133)(cid:3)(cid:391) (cid:3)(cid:3)(cid:3)(cid:139)(cid:136)(cid:3)(cid:383)(cid:5)(cid:131)(cid:142)(cid:131)(cid:144)(cid:133)(cid:135)(cid:387)(cid:143)(cid:149)(cid:137)(cid:348)(cid:149)(cid:135)(cid:144)(cid:134)(cid:135)(cid:148)(cid:388)(cid:3)(cid:691)(cid:3)(cid:131)(cid:143)(cid:145)(cid:151)(cid:144)(cid:150)(cid:384)(cid:3)(cid:391) (cid:3)(cid:3)(cid:3)(cid:3)(cid:150)(cid:138)(cid:148)(cid:145)(cid:153)(cid:346) (cid:3)(cid:3)(cid:3)(cid:392)(cid:3) (cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:3)(cid:148)(cid:3)(cid:135)(cid:3)(cid:147)(cid:3)(cid:151)(cid:3)(cid:139)(cid:3)(cid:148)(cid:3)(cid:135)(cid:3)(cid:383)(cid:3)(cid:143)(cid:3)(cid:149)(cid:3)(cid:137)(cid:3)(cid:348)(cid:3)(cid:149)(cid:348)(cid:135)(cid:152)(cid:144)(cid:131)(cid:134)(cid:142)(cid:135)(cid:151)(cid:148)(cid:135)(cid:348)(cid:383)(cid:133)(cid:131)(cid:131)(cid:143)(cid:142)(cid:145)(cid:142)(cid:151)(cid:144)(cid:150)(cid:384)(cid:383)(cid:384)(cid:384)(cid:346)(cid:3) (cid:3)(cid:3)(cid:3)(cid:5)(cid:131)(cid:142)(cid:131)(cid:144)(cid:133)(cid:135)(cid:387)(cid:143)(cid:149)(cid:137)(cid:348)(cid:149)(cid:135)(cid:144)(cid:134)(cid:135)(cid:148)(cid:388)(cid:3)(cid:350)(cid:688)(cid:3)(cid:131)(cid:143)(cid:145)(cid:151)(cid:144)(cid:150)(cid:346) (cid:392) |
(cid:70)(cid:82)(cid:85)(cid:72)(cid:3)(cid:81)(cid:82)(cid:71)(cid:72) (cid:81)(cid:82)(cid:85)(cid:80)(cid:68)(cid:79)(cid:3)(cid:81)(cid:82)(cid:71)(cid:72) (cid:70)(cid:82)(cid:81)(cid:87)(cid:85)(cid:82)(cid:79)(cid:3)(cid:73)(cid:79)(cid:82)(cid:90)(cid:3)(cid:72)(cid:71)(cid:74)(cid:72) (cid:73)(cid:68)(cid:79)(cid:79)(cid:69)(cid:68)(cid:70)(cid:78)(cid:3)(cid:72)(cid:71)(cid:74)(cid:72) (cid:71)(cid:68)(cid:87)(cid:68)(cid:3)(cid:73)(cid:79)(cid:82)(cid:90)(cid:3)(cid:72)(cid:71)(cid:74)(cid:72) Fig.6. ExamplesofCDG,CBGandCADG. 5.2.16 ComponentBehaviorGraph(CBG). AComponentBehaviorGraph(CBG)[27]representsthelifetime orcontrol-owlogicofthepermission-relatedAPIfunctionsinaJavaorAndroidprogram,aswellasthefunctions performedonaparticularresourceforeachcomponent.ThisisthesecondhalfofthetheComponentDependency Graph,wherebothoftheserepresentationscometogethertofullydescribetheAndroidapp.Therearefourtypes ofnodes,eachindicatingthetypeofcomponentatthatportionofthegraph.TheedgesconnectingtheCBG demonstratethecontrolowlogicbetweentheAPIfunctionsandsensitiveresources. Thecomponentbehaviorgraph6= +,⇢ isadirectedlabelledgraphwithnodesE + andedges4 ⇢.Theset ( ) 2 2 ofnodes+ inacomponentbehaviorgraphispartitionedintofourtypes:rootnode+ ,lifecyclefunctionnodes A>>C + ;854,permission-relatedAPIfunctionnodes+ ?A0?8,andsensitiveresourcenodes+ 5.AstartnodeE A>>C + A>>C 2 representsthecomponentitself.AlifecyclefunctionnodeE ;854 + ;854 representtheruntimeprogramminglogic. 2 Eachpermission-relatedAPIfunctionsnodeE ?A0?8 + ?A0?8 denotesapermission-relatedAPIfunction,forexample 2 Android’sAPIsendTextMessage().AsensitiveresourcenodeE 5 + 5 indicatessensitivedatathatisaccessedby 2 acomponent.Theedgeset⇢ inacomponentbehaviorgraphrepresentthecontrolowlogicoftheframework APIfunctionsandsensitiveresources.Acomponentdependencygraphedge4 =E E indicateseither 216 BA2 3BC ! that,ifE andE areinthesamecontrol-owblock,thenE isexecutedrightafterE withnoexecutionsin BA2 3BC 3BC BA2 between,orifE andE areintwocontinuouscontrol-owblocks(named⌫ and⌫ respectively),then BA2 3BC 3BC 3BC E isthelastfunctionnodein⌫ andE istherstnodein⌫ . BA2 BA2 3BC 3BC Fig.6demonstratesanexampleoftheCBG,asacontinuationofthelargerWebApplicationBehaviorGraph.The webpagenodefromtheCDGleadstotwodierentnodesintheCBG:onLoad()andonRender().Bothofthese ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:15 nodesleadtoAPI nodes,whichcanrepresentanyoftheaforementionednodetypes.Thispatterncontinues:the backgroundtasksnodefromtheCDGleadstothebeginTask()nodeandcomplexTask()node,whichthenlead toAPI nodesrepresentingthefurtheractivitiesoftheAPIsintheprogram.Finally,themessagehandler node fromtheCDGleadstoonMessageReceive()nodeintheCBG,whichleadstootherAPInodesthatrepresent theirfunctionalitywithintheprogram. 5.2.17 ContextualInterproceduralControlFlowGraph(CICFG). TheContextualInterproceduralControl FlowGraph(CICFG)isanextensionoftheICFGanditdescribesthecompletecontrolowacrossallinstructions, includingcontext[19].Acontextdenestheinformationneededforanoperationtooccur.TheCICFGisformally denedas⌧ = +,⇢,b .ThenodesE + arebasicblocks,andtheedges4 ⇢ areeitherintraproceduralcontrol ( ) 2 2 ows,orcallingrelationshipsfromanodeE toE .Lastly,b isasetofcontextsthroughwhicheverynode BA2 3BC E + couldbereached[19].TheprimarydierencebetweentheCICFGandtheICFGisthattheCICFGgivesa 2 moredetailedanalysisofaprogrambecausethecontextallowstodierentiatebetweendierentinstancesor pathsthatafunctionmaybecalled.Twoexamplesofacontextareuser-awareanduser-unaware,whichindicates whethertheuserisawareofwhatoperationsorresourcesanapplicationorpieceofcodeisusing.Forexample, ifanappisusingtheuser’slocation,inauser-awarecontext,theuserknowsthattheappisusingtheirlocation, whereasinauser-unawarecontext,theuserwouldnotknowabouttheappusingtheuser’slocation[26]. 5.2.18 ContextualAPIDependencyGraph. TheContextualAPIDependencyGraph(CADG)isbuiltfrom aCICFG.NotallofthenodesoftheCICFGaresecurity-relatedorinvokesasensitiveAPI.TheCADGisan abstractionoftheCICFGthatonlyfocusesonthesecuritysensitiveAPIinvocations[19].ACADG6= +,⇢,U ( ) isadirectedlabelledgraph,withnodesE +,edges4 ⇢,andlabellingfunctionU.Thesetofnodes+ ina 2 2 CADGrepresentthebasicblocksoftheprogram.Theedgeset⇢ inaCADGrepresentthedataowbetweenthe basicblocks.ACADGedge4 =E E indicatesthatE usesdatathathasbeendenedbythebasic 2036 BA2 3BC 3BC ! blockE .ThelabelingfunctionU :+ ⌃associatesnodeswiththelabelsofcorrespondingcontextualAPI BA2 ! operations.EachlabelconsistsofAPIprototype,entrypointandconstantparameter[192]. Figure6givesanexampleoftheCADGforthecodesnippetshown.WestartwiththefunctionupdateUserProfile, andhaveacontrolowedgetothesecurityrelatednodecheckUserPermissionwiththecontextuseraware. Fromhere,weowtoanothersecurityrelatednode,validateProfileDatawiththesamecontext:useraware. Finally,weowtoupdateProfileDBwiththesameuserawarecontext. 5.2.19 Contract/SemanticGraph. AContractGraph[105](oraSemanticGraph[108])isarepresentation createdspecicallyforvulnerabilitydetectioninsmartcontracts.Thesetofnodes+ inacontract/semantic |
graphispartitionedintothreetypes:corenode+ 2>A4,normalnodes+ =>A<,andfallbacknodes+ 5.Acorenode E + representsthekeyinvocationsandvariablesthatplayacrucialroleindetectingvulnerabilities. 2>A4 2>A4 2 AnormalnodeE =>A< + =>A< representsinvocationsandvariablesthatcanassistindetectingvulnerabilities, 2 althoughtheydonothavethesamesignicanceascorenodes.AfallbacknodeE 5 + 5 simulatesthefallback 2 functionthatisincurredonacontractattack. Theedgeset⇢ inacontract/semanticgraphhasthreepartitions:controlow edges⇢ 25 + 2>A4 + =>A< ✓( ⇥ )[ + =>A< + 5 + 5 + 5 ,dataowedges⇢ 3 + 2>A4 + =>A< + =>A< + 5 + 5 + 5 ,andfallbackedges ( ⇥ )[( ⇥ ) ✓( ⇥ )[( ⇥ )[( ⇥ ) ⇢ 50;; + 5 + 5.Acontrolow edge4 25 = E BA2 E 3BC indicatesthatE BA2 canowtoE 3BC inthenextstepof ✓ ⇥ ! the program. A data ow edge4 = E E indicates thatE receives data fromE . A fallback edge 3 BA2 3BC 3BC BA2 ! 4 = E E indicates thatE is the fallback node andE is the call.value invocation, which is the 50;; BA2 3BC 3BC BA2 ! invocationinasmartcontractthatcancauseareentrancyvulnerability,ifthecodeisvulnerable[108].Itcanalso meanthatE isthefunctionundertest,andE isthefallbacknode.Generally,thisedgeindicatesinteractions 3BC BA2 withthefallbackfunction[46]. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:16 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry Fig.6showsaContract/Semanticgraphfortheprovidedcodesnippet.Thewithdrawandbalancearecorenodes, andthecall.valuevariableisacorenodebecausetheycouldbethecauseforavulnerability.Theamount variableisanormalnode,becauseitdoesnotdirectlycontributetoasecurityissue.Thewithdrawinvocationhas controlowedgestothebalanceinvocation,andtheamountvariable.Thebalancenodeasadataowedgeto itselfsinceitisaccessingdatafromitself,andreceivesordependsondatafromthevariableamount.call.value alsoreceivesdatafromamountandthusthereisadataowedgefromamounttocall.value.Therearecontrol owedgesfromwithdrawtobalanceandamountbecauseitinvokesthesetwonodes.Afteramountiscalled, thencall.valueisinvoked,thusresultinginacontrolowedgefromamounttocall.value.Finally,thereis fallbackedgefromcall.valuetothefallbacknode,andfromthefallbacknodebacktowithdraw. 5.2.20 ContextualPermissionDependencyGraph. TheContextualPermissionDependencyGraph(CPDG) [26]isalsobuiltfromaContextualInterproceduralControlFlowGraph(CICFG).TheCPDGisanabstractionof theCICFGthatonlyfocusesonfunctionalityrelatedtoAndroidpermissions[26].ACPDG6= +,⇢,_ ,b isa ? ( ) directedlabelledgraph,withnodesE +,andedges4 ⇢.NodesinaCPDGrepresenttheprogram’sbasicblocks 2 2 whosefunctionalitypertainstousingAndroidpermissions.EdgesinaCPDGrepresentthedataowbetween thebasicblocks.ACPDGedge4 =E BA2 E 3BC indicatesthatthereisapathfromE BA2 toE 3BC intheCICFG,and ! thatbothnodesareinthesamefunction._ isthesetoflabelsrepresentingtheconcernedpermissions.b isaset ? ofcontextsthroughwhicheverynodeistheCPDGcouldbereached[26]. 5.2.21 ContextualSourceandSinkDependencyGraph. TheContextualSourceandSinkDependencyGraph (CSSDG) [26], is also built from a Contextual Interprocedural Control Flow Graph (CICFG). The CSSDG is anabstractionoftheCICFGthatconsidersonlythenodeswhosefunctionalityisrelatedtousingsourcesand sinks.[26].Sourcesarewheresensitivedataentersaprogramandsinksarewheretheyperformsecuritycritical operations.Thissensitivedataowcouldbeapointofavulnerabilityifthedataisnothandledproperly[97]. Thus,aCSSDG6= +,⇢,_ ,b isadirectedlabelledgraph,withnodesE + andedges4 ⇢.NodesinaCSSDG B ( ) 2 2 representthebasicblocksoftheprogramwhosefunctionalityisrelatedtousingsourcesandsinkswhereasthe edgesrepresentthedataowbetweenthebasicblocks._ isthesetoflabelsrepresentingtheconcernedsources B andsinks.b isasetofcontextsthroughwhicheverynodeistheCSSDGcouldbereached[26]. 5.2.22 SlicePropertyGraph. SlicepropertygraphswereproposedbyZhengetal.[111]andaimtopreserve thesemanticsandstructuralinformationthatisrelevanttovulnerabilities.Italsoaimstoeliminateirrelevant informationtoreducethecomplexityofthegraphs.ThegraphusesSyVCs(Syntax-basedVulnerabilityCandidates) as slicing criterion to extract the slice nodes that are relevant to vulnerabilities. Then, edges from the Code PropertyGraphareusedasedgesbetweenthenodesintheSPG. 5.2.23 TokenGraph. Tokengraphs[113]arebuiltfromtokens,connectingthemviaindex-focusedconstruction. Atokengraph6= +,⇢ isadirectedgraph,withnodesE + andedges4 ⇢where⇢ + +.Thesetofnodes ( ) 2 2 ✓ ⇥ + inatokengraphareindividualtokensfromthesourcecode.Forexample,asetofnodescanbe85,G, ==,~.The edgeset⇢ inatokengraphdeneaco-occurencerelationshipbetweentokens.Theco-occurrencesdescribethe relationshipsbetweentokensthatoccurwithinaxed-sizeslidingwindow[193]. 5.2.24 PropagationChain. APropagationChain[104]existswhenthereisacodesequenceamonganumberof speciedcodesnippets.Thesequencehasdirectorindirectdataandcontroldependenciesbetweenadjacentcode snippets.Thepropagationchainset%⇠ 0,1 denotesthesetofpropagationchainsbetweentwocodesnippetsa ( ) andb.Eachprogramsnippetwillhavepropagationchainsthataectitandpropagationchainsthatareaected byit.Intermsofvulnerabilitydetection,avulnerable,ordefective,propagationchaindenotesacodesequence fromthevulnerablecodetotheprogram’svulnerableoutput.Thesetofdefectpropagationchain,calledthe defectpropagationchainset,isdenotedas⇢%⇠ 3,5 andisasubsetofthepropagationchainset%⇠ 3,5 froma ( ) ( ) |
ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:17 codesnippetdtotheprogramfailurecodef.Propagationchainscanbeconstructedbydataoworcontrolow relationships.Zhangetal.[104]usedataowrelationshipstocreatethepropagationchainsforsmartcontracts. Inthisinstance,thedataowgraphisdenedasasetofnodesandedges6 = +,⇢ ,wherethenodesE + ( ) 2 representvariablesinasmartcontractandtheedgeset⇢ denotethedependencyrelationshipsbetweenthem. Forexample,4 =E E denotesthatE hasadatarelationshipordependencetoE . BA2 3BC 3BC BA2 ! 5.3 LexicalRepresentations Lexicalrepresentationsdescriberepresentationsthatarefocusedonwordsandvocabularies.Theserepresentations donotshowrelationshipsbetweennodes,astheydoingraphrepresentations.Lexicalrepresentationsarealso primarilybaseduponNLPwork. 5.3.1 Tokenizer. Atokenizer,whichcanalsobereferredtoasalexed representation,takessourcecodeand createsindividualtokensforeverywordorsymbol[63].ThisislargelybasedoofexistingNLPtechniques. SomepapersusedcodeBERTtocreatetherepresentationandembeddinggiventothemodel.Whilewestill showtheseasseparaterepresentations,thebasisofallBERTmachinesisatokenizer.AsimilarmethodisByte PairEncoding(BPE)SubwordTokenization,whichisamethodthatbreaksupwholewordsintosmaller parts,inaneorttocompressthetokenizeddata.Frequentwordsarerepresentedasindividualtokens,but infrequentwordsaresplitintomultiplesubwordtokens.Forexample,ifthepairoftokens“a”and“b”happen frequently,thentheywillbecombinedandbecomethesingletoken“ab”[194]. Tokenizersthatusestrongembeddingalgorithmssuchasword2vec[57]areabletocapturethesemanticmeaning ofthecode.Whenthevectorembeddingsarecreatedfromthetokenizer,thesenumbersarelargelybasedo thesemanticrelationshipwithanotherword.Thatis,ifawordissemanticallyrelatedtoanother,theirvector representationswillbesimilar[57].Thesetechniquescanbeparticularlyusefulwhenthemodelneedstolearn thesemanticsofachunkofcodeinordertocompletethetaskathand.Itisalsoquitesimpletotokenizesource code,withacomplexityof$ = .Abuilt-infunctionfornearlyanylanguagewillsimplytakeinalineoftext, ( ) andbreakitupintotokensbasedonaprovideddelimiter.Modelssuchasword2vecanddoc2vec[57,195]are verydevelopedandareagreatwaytocreatewordembeddingsfromavocabulary.Thisisareasonwhythis representationisalsosopopular.However,tokenizersdonotcapturethestructuralpropertiesofsourcecode, andthisrepresentationthuslackstheabilitytounderstandthesyntaxofaprogram. 5.3.2 iSeVCandsSyVC. AsSyVC(sourcecode-andSyntax-basedVulnerabilityCandidate)arefeatures ofcodethathavesomevulnerabilitysyntaxcharacteristics.Anexamplewouldbeforvulnerabilitiesthatare associated with pointers. A sSyVC would be a line of code which contains a ‘*’ since this symbol is what is usedwhendealingwithpointers[144].ThesecharacteristicsareobtainedthroughASTs.[144].iSeVCstands forintermediatecodeandSemantics-basedVulnerabilityCandidateandarederivedfromsSyVCusing programslicing.ThesSyVCarethenodesofinterest,andthePDGoftheprogramallowsonetoperformthe forwardandbackwardslicing,asdescribedin 5.2.7.Theresultingsetoforderedstatements,allcontainingdata § orcontroldependenciesbetweenthem,aretheiSeVCs[144].iSeVCscontaininformationregardingdataand controldependence,hencetheirnamewhichrelatesthemtosemantics[48]. 5.3.3 ContractSnippet. AContractSnippet[47]containskeyprogramstatementsorlinesfromasmartcontract whichcouldinduceavulnerability.Thesecontractsnippetsareaimedtobehighlyexpressivesuchthatmore pertinentfeaturescanbeextracted.Thecontractsnippetsareallsemanticallyrelatedbycontrolowdependence, and all highlight a key element in reentrancy detection (which the paper this representation is proposed in focuseson)-call.value.Contractsnippetscanbegeneratedbycontrolowanalysis.Oncethecontractsnippets arecreated,theyarethentokenizedandtransformedintofeaturevectors. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.111:18 • BeatriceCasey,JoannaC.S.Santos,andGeorgePerry 5.4 MiscellaneousRepresentations Miscellaneousrepresentationsarethosethatdonottintoanyofthepreviouslydescribedcategories. 5.4.1 Image. Priorworksusedthealreadyverydevelopedtechniquesinimageanalysistoanalyzeaspectsof codeinordertodetectvulnerabilities[88,93]andmalwareinAndroidapplications[21].Thecoreideabehind thismethodisleveragingvisualpatternsinsoftwaretodetectanomaliesorsimilarities.Thistechniqueallows researcherstotakeadvantageofthetechniquesdevelopedfordetectionofelementsinregularimages. 5.4.2 CodeMetrics. Codemetricsareaquantitativemeasurethatrelatescertainfeaturestoanumericalvalue, namelythenumberoftimesthefeatureoccurs[196].Codemetricscanbedeneddierentlyfordierenttasks. Somecommonmetricsincludelinesofcode,codechurn(i.e.,howoftencodeischanged),andmore.Priorworks also introduce new metrics for a particular purpose, such as SQL injection [156]. Rather than lines of code, or other classical metrics which would not be useful in SQL injection detection, metrics such as number of semicolons, presence of always true conditions and the number of commands per statement provides more relevantinformationthatwouldresultinbetterpredictionsforSQLinjection.Thesemetricscanberelatedtoa riskfactordictatinghowmuchofanimpactthemetriccouldhaveoncodetocreateasecurityissue[196]. 5.4.3 CodeGadgets. CodeGadgetsareessentiallyamethodtodescribeorrepresentaprogramslice.They haveanumberoforderedcodestatementsorcodelinesthataresemanticallyrelatedtoeachotherbydataor |
controldependency[41].Codegadgetswerecreatedfortheexactpurposeofvulnerabilitydetection[41],which canexplainthereasonforitspopularityinsecurityrelatedtasks. 5.4.4 OpcodeSequences. Anopcode,oroperationcode,speciestheoperationtobecompletedforaninstruction [197].They,inparticular,specifythelowest-leveloperationtobecompletedsuchasPUSH,MSTORE,andCALLVALUE [177].Thesefeaturescanbeusedtounderstandonalowlevelwhatthecodeisdoing.Theopcodesneedto belearnedasvectors,andLiaoetal.[177]usesn-gramsandword2vec[57]tolearnthevectorsasembeddings. Giventhatopcodesarealreadyusedincomputerstodictatewhatoperationstocomplete,thisrepresentationis simpletogenerate. 5.4.5 RegularExpression. Theregularexpressionsproposedin[179]rsttakesanAndroidapplicationand createsaCFGfromthecallbacks.TheCFGistransformedtoanICFG.ThisgraphisthenreducedtoanAPIgraph, andtheautomatatoregularexpressionalgorithmisusedtogeneratetheregularexpressions.Thissolutionis usedfortheproblemofmultifamilymalwareclassicationandaddressestheissuesofrecognizingmalware familybehaviorpatterns,codeobfuscationandpolymorphicvariantsthatarecommonlyusedbyattackersto evadedetection.Theregularexpressionshelptodescribethebehaviorpatternsofmalwarefamilies.Whilethis methodcanbecomputationallyexpensive,asthreegraphshavetobemadebeforebeingtransformedtoaregular expression,itallowstocapturethedierencesbetweenmalwarefamilies. 5.4.6 ApplicationInformation. WhilethisrepresentationcanbesortedunderCodeMetrics,thefeaturesextracted by[23]moreaccuratelyfallunderthenameof ApplicationInformation.Inthisrepresentation,anAndroid applicationisreverseengineeredtoextracttheoriginalJavalesandAndroidXML.Fromtheseles,theAPI Callsmade,andthepermissionsusedareextracted.Otherfeaturessuchasiscryptocode orisdatabase that speciescertainfeaturesofthecodethatmightbeassociatedwithmalware[23]arealsoextracted. 5.4.7 APICalls. Wangetal.[24]usesAPICallsextractedfromthesourcecodeofanAndroidapplication,along withpermissionsextractedfromtheAndroidManifestle.ThispaperusesatoolcalledDroidAPIMinertoextract thetop20APIcallsthatarecalledbymaliciousapplications.UsingtheseAPICallsandpermissionsasfeatures allows[24]tondmalwareinAndroidapplications. ACMComput.Surv.,Vol.37,No.4,Article111.Publicationdate:March2024.ASurveyofSourceCodeRepresentationsforMachineLearning-BasedCybersecurityTasks • 111:19 RQ1Findings: Thereare42representationsoeringavarietyofinformationaboutthesourcecode,althoughacommon • goalistocapturethesemanticandsyntacticinformationincode. Thereare24uniquegraph-basedrepresentations,whichisthemostpopularrepresentationtypeforsource • code,asitshowstherelationshipsbetweendierentnodes(e.g.,linesorstatements)andhowtheyinteract. Althoughtherearealargervarietyofgraph-basedrepresentations,43papersusedtokenizersand32 • papersusedASTsastheirrepresentations,probablybecausetheyaretheeasiesttogenerateandoneof themorelightweightoptions. Sevenpapers[43–48,102]proposearepresentationuniquetotheirapplication.Forexample,acontract • graph[46]wascreatedforndingvulnerabilitiesinsmartcontracts.Itis,therefore,notapplicabletoother languagesorpurposes. 6 RQ2:DOCERTAINTASKSONLYUSEORMOSTLYUSEONETYPEOFREPRESENTATION? (cid:24)(cid:96)(cid:114)(cid:75)(cid:111)(cid:108)(cid:111)(cid:99)(cid:71)(cid:75)(cid:73)(cid:115)(cid:111)(cid:62)(cid:93)(cid:2)(cid:12)(cid:99)(cid:96)(cid:114)(cid:111)(cid:99)(cid:93)(cid:2)(cid:21)(cid:93)(cid:99)(cid:121)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:24)(cid:12)(cid:21)(cid:22)(cid:208) (cid:133) (cid:3)(cid:70)(cid:112)(cid:114)(cid:111)(cid:62)(cid:71)(cid:114)(cid:2)(cid:49)(cid:123)(cid:96)(cid:114)(cid:62)(cid:122)(cid:2)(cid:50)(cid:111)(cid:75)(cid:75)(cid:2)(cid:207)(cid:3)(cid:49)(cid:50)(cid:208) (cid:133)(cid:141) (cid:33)(cid:62)(cid:93)(cid:83)(cid:71)(cid:83)(cid:99)(cid:115)(cid:112)(cid:2)(cid:11)(cid:75)(cid:82)(cid:62)(cid:120)(cid:83)(cid:99)(cid:111) (cid:12)(cid:99)(cid:95)(cid:108)(cid:99)(cid:96)(cid:75)(cid:96)(cid:114)(cid:2)(cid:14)(cid:75)(cid:108)(cid:75)(cid:96)(cid:73)(cid:75)(cid:96)(cid:71)(cid:123)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:12)(cid:14)(cid:22)(cid:208) (cid:133) (cid:14)(cid:75)(cid:114)(cid:75)(cid:71)(cid:114)(cid:83)(cid:99)(cid:96) |
(cid:12)(cid:99)(cid:96)(cid:114)(cid:75)(cid:122)(cid:114)(cid:115)(cid:62)(cid:93)(cid:2)(cid:3)(cid:45)(cid:24)(cid:2)(cid:14)(cid:75)(cid:108)(cid:75)(cid:96)(cid:73)(cid:75)(cid:96)(cid:71)(cid:123)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:12)(cid:3)(cid:14)(cid:22)(cid:208) (cid:133) (cid:50)(cid:99)(cid:92)(cid:75)(cid:96)(cid:83)(cid:126)(cid:75)(cid:111) (cid:133)(cid:141) (cid:12)(cid:99)(cid:95)(cid:108)(cid:99)(cid:96)(cid:75)(cid:96)(cid:114)(cid:2)(cid:11)(cid:75)(cid:82)(cid:62)(cid:120)(cid:83)(cid:99)(cid:111)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:12)(cid:11)(cid:22)(cid:208) (cid:133) (cid:33)(cid:62)(cid:93)(cid:83)(cid:71)(cid:83)(cid:99)(cid:115)(cid:112)(cid:2)(cid:12)(cid:99)(cid:73)(cid:75) (cid:12)(cid:99)(cid:96)(cid:114)(cid:75)(cid:122)(cid:114)(cid:115)(cid:62)(cid:93)(cid:2)(cid:45)(cid:75)(cid:111)(cid:95)(cid:83)(cid:112)(cid:112)(cid:83)(cid:99)(cid:96)(cid:2)(cid:14)(cid:75)(cid:108)(cid:75)(cid:96)(cid:73)(cid:75)(cid:96)(cid:71)(cid:123)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:12)(cid:45)(cid:14)(cid:22)(cid:208) (cid:133) (cid:12)(cid:99)(cid:96)(cid:114)(cid:111)(cid:99)(cid:93)(cid:2)(cid:21)(cid:93)(cid:99)(cid:121)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:12)(cid:21)(cid:22)(cid:208) (cid:133)(cid:135) (cid:3)(cid:70)(cid:112)(cid:114)(cid:111)(cid:62)(cid:71)(cid:114)(cid:2)(cid:49)(cid:123)(cid:96)(cid:114)(cid:62)(cid:122)(cid:2)(cid:50)(cid:111)(cid:75)(cid:75)(cid:2)(cid:207)(cid:3)(cid:49)(cid:50)(cid:208) (cid:133) (cid:31)(cid:99)(cid:71)(cid:62)(cid:93)(cid:83)(cid:126)(cid:62)(cid:114)(cid:83)(cid:99)(cid:96) (cid:12)(cid:99)(cid:96)(cid:114)(cid:75)(cid:122)(cid:114)(cid:115)(cid:62)(cid:93)(cid:2)(cid:49)(cid:99)(cid:115)(cid:111)(cid:71)(cid:75)(cid:2)(cid:62)(cid:96)(cid:73)(cid:2)(cid:49)(cid:83)(cid:96)(cid:92)(cid:2)(cid:14)(cid:75)(cid:108)(cid:75)(cid:96)(cid:73)(cid:75)(cid:96)(cid:71)(cid:123)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:12)(cid:49)(cid:49)(cid:14)(cid:22)(cid:208) (cid:133) (cid:12)(cid:99)(cid:73)(cid:75)(cid:2)(cid:81)(cid:62)(cid:73)(cid:81)(cid:75)(cid:114)(cid:112) (cid:139) (cid:12)(cid:99)(cid:96)(cid:114)(cid:111)(cid:99)(cid:93)(cid:2)(cid:21)(cid:93)(cid:99)(cid:121)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:12)(cid:21)(cid:22)(cid:208) (cid:133) |
(cid:12)(cid:99)(cid:96)(cid:114)(cid:75)(cid:122)(cid:114)(cid:115)(cid:62)(cid:93)(cid:2)(cid:24)(cid:12)(cid:21)(cid:22)(cid:2)(cid:207)(cid:12)(cid:24)(cid:12)(cid:21)(cid:22)(cid:208) (cid:133) (cid:14)(cid:62)(cid:114)(cid:62)(cid:2)(cid:21)(cid:93)(cid:99)(cid:121)(cid:2)(cid:22)(cid:111)(cid:62)(cid:108)(cid:82)(cid:2)(cid:207)(cid:14)(cid:21)(cid:22)(cid:208) (cid:139) (cid:12)(cid:99)(cid:73)(cid:75)(cid:2)(cid:95)(cid:75)(cid:114)(cid:111)(cid:83)(cid:71)(cid:112) (cid:133) |
(cid:33) (cid:33)(cid:62) (cid:62)(cid:14)(cid:93) (cid:93) (cid:21)(cid:83) (cid:83)(cid:75)(cid:71) (cid:71) (cid:83)(cid:93)(cid:83) (cid:83)(cid:114) (cid:114)(cid:99) (cid:99)(cid:75) (cid:75)(cid:115) (cid:115)(cid:71) (cid:111)(cid:114)(cid:112) (cid:112) (cid:83)(cid:83) (cid:96)(cid:2) (cid:2)(cid:99)(cid:12) (cid:12) (cid:81)(cid:96)(cid:99) (cid:99)(cid:73) (cid:73)(cid:75) (cid:75) (cid:73) (cid:50)(cid:99)(cid:99) (cid:92)(cid:71) (cid:75)(cid:134) (cid:96)(cid:120)(cid:75) (cid:83)(cid:126)(cid:71) (cid:75)(cid:111) (cid:133) (cid:133) (cid:45)(cid:62)(cid:56) (cid:112)(cid:115) (cid:112)(cid:93) (cid:50) (cid:121)(cid:96) (cid:75)(cid:75) (cid:99)(cid:112)(cid:111) (cid:111)(cid:114)(cid:62) (cid:73)(cid:83)(cid:96)(cid:70) (cid:2)(cid:31)(cid:81)(cid:83)(cid:93) (cid:75)(cid:83) (cid:62)(cid:114)(cid:123) (cid:92)(cid:112) (cid:50)(cid:50) (cid:36) (cid:45) (cid:99)(cid:99) (cid:62)(cid:108) (cid:92)(cid:92) (cid:111)(cid:71) (cid:112) (cid:75)(cid:75) (cid:99) (cid:75) (cid:96)(cid:96) (cid:73) (cid:2) (cid:83)(cid:83) (cid:50)(cid:75) (cid:126)(cid:126) (cid:111) (cid:75)(cid:75) (cid:2) (cid:75)(cid:49) (cid:111)(cid:111) (cid:75)(cid:75)(cid:110)(cid:115)(cid:75)(cid:96) (cid:133)(cid:71)(cid:75)(cid:112) (cid:134) (cid:133) (cid:133) (cid:45) (cid:12) (cid:12)(cid:99) (cid:99)(cid:111)(cid:99) (cid:73) (cid:73)(cid:81) (cid:75) (cid:75)(cid:111) (cid:2) (cid:2)(cid:62) (cid:95) (cid:45)(cid:95) (cid:111)(cid:75) (cid:99)(cid:2) (cid:114) (cid:108)(cid:14) (cid:111) (cid:75)(cid:75) (cid:83)(cid:71) (cid:111)(cid:108) (cid:112) (cid:114)(cid:75) (cid:123)(cid:96) (cid:2)(cid:22)(cid:73) (cid:111)(cid:75) (cid:62)(cid:96) (cid:108)(cid:71) (cid:82)(cid:75) (cid:2)(cid:207)(cid:2)(cid:22) (cid:12)(cid:45)(cid:111)(cid:62) (cid:22)(cid:108) (cid:208)(cid:82)(cid:2)(cid:207)(cid:45)(cid:14)(cid:22)(cid:208) (cid:139) (cid:136) (cid:136) (cid:56)(cid:115) (cid:3)(cid:93)(cid:96) (cid:96)(cid:75) (cid:62)(cid:111) (cid:93)(cid:62) (cid:123)(cid:70) (cid:112)(cid:83)(cid:83) (cid:112)(cid:93)(cid:83)(cid:114)(cid:123) (cid:12) (cid:45) (cid:45)(cid:99) (cid:111) (cid:111)(cid:99) (cid:99)(cid:73) (cid:81) (cid:108)(cid:75) (cid:111) (cid:75)(cid:2) (cid:62)(cid:45) (cid:111)(cid:95) (cid:114)(cid:111) (cid:123)(cid:99) (cid:2) (cid:2)(cid:108) (cid:14) (cid:22)(cid:75) (cid:75) (cid:111)(cid:62)(cid:111) (cid:108)(cid:114) (cid:108)(cid:75)(cid:123) (cid:82)(cid:96)(cid:2)(cid:22) (cid:73)(cid:111) (cid:75)(cid:62) (cid:96)(cid:108) (cid:71)(cid:82) (cid:75)(cid:2)(cid:207) (cid:2)(cid:22)(cid:12)(cid:45) (cid:111)(cid:62)(cid:22) (cid:108)(cid:208) (cid:82)(cid:2)(cid:207)(cid:45)(cid:14)(cid:22)(cid:208) (cid:133) (cid:133) (cid:133) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.