{'fraction_non_alphanumeric': 0.030603333036271278, 'fraction_numerical': 0.011157650833259068, 'mean_word_length': 4.922727752559907, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Deep Learning-based Fine-grained Hierarchical Learning Approach for Robust Malware Classification

The wide acceptance of Internet of Things (IoT) for both household and industrial applications is accompanied by several security concerns. A major security concern is their probable abuse by adversaries towards their malicious intent. Understanding and analyzing IoT malicious behaviors is crucial, especially with their rapid growth and adoption in wide-range of applications. However, recent studies have shown that machine learning-based approaches are susceptible to adversarial attacks by adding junk codes to the binaries, for example, with an intention to fool those machine learning or deep learning-based detection systems. Realizing the importance of addressing this challenge, this study proposes a malware detection system that is robust to adversarial attacks. To do so, examine the performance of the state-of-the-art methods against adversarial IoT software crafted using the graph embedding and augmentation techniques. In particular, we study the robustness of such methods against two black-box adversarial methods, GEA and SGEA, to generate Adversarial Examples (AEs) with reduced overhead, and keeping their practicality intact. Our comprehensive experimentation with GEA-based AEs show the relation between misclassification and the graph size of the injected sample. Upon optimization and with small perturbation, by use of SGEA, all the IoT malware samples are misclassified as benign. This highlights the vulnerability of current detection systems under adversarial settings. With the landscape of possible adversarial attacks, we then propose DL-FHMC, a fine-grained hierarchical learning approach for malware detection and classification, that is robust to AEs with a capability to detect 88.52% of the malicious AEs.


INTRODUCTION
The Internet of Things (IoT) has shown its fast growth in the last decade. The communication media of IoT devices is not limited only in the form of home networking, but also the cellular, which significantly accelerated their connectivity and accessibility. According to Ericsson [27], 3.5 billion IoT devices are expected to communicate using cellular in 2023. On the one side, taking advantage from the a large number of interconnected devices, many applications can be adopted on a large scale. Moreover, due to the high-speed and low-latency connection of these devices, time critical applications will become feasible in the real world. On the down side, however, the high accessibility also provides a convenience to adversaries. Due to the constrained resource of IoT devices, the protection function is usually inefficient. Moreover, due to the large population, low physical accessibility, and the unrestricted use of policies in many scenarios, IoT devices can be easily compromised and abused by adversaries to launch a variety of attacks, such as Distributed Denial of Service (DDoS) attacks launched by Mirai botnet [12]. Such adversarial scenarios are expected to grow for many years to come, posing a critical security threats for the IoT ecosystem.
There has been a large body of research work on the problem of malware analysis using both static and dynamic approaches [28,31,37], and a few attempts on analyzing IoT malware in particular. Recently, machine learning algorithms, specifically deep learning techniques, are actively utilized in security and privacy applications [1-3, 20, 32], particularly, for detecting and classifying malicious software from benign ones. However, it should be noted that the research work on IoT malware analysis has been very limited not only in the size of the analyzed samples, but also the utilized approaches [14,21,42,44]. Among the static analysis-based approaches, one of the prominent approach is to use an abstract graph structures for IoT malware analysis and detection, such as the control flow graph (CFG) [8,10]. Previously, it has been shown that the software graph-based analysis can be incorporated with machine learning methods to introduce more powerful analysis tools [13,56]. For the IoT malware detection, CFGs allow defenders to extract plentiful feature representations that can be used to distinguish those malware from benign, owing to their various properties, such as the degree distribution, centrality measures, radius, etc.. [10]. Those properties can be represented as a feature vector that can be used to enable machine learning algorithms to accurately detect and classify IoT malware samples. Proposed by Alasmary et al., one such application is exploring IoT malware using both graph analysis and machine/deep learning [10]. Their model not only can learn the representative characteristics of the graph, but also can be utilized to build an automatic detection system for predicting the label of the unseen software.
Unfortunately, machine learning-based IoT malware detection methods are prone to adversarial manipulation [40]. The rise of adversarial machine learning has highlighted the fragile nature of those algorithms to perturbation and data poisoning attacks that lead to misclassification. For example, an adversary can introduce a small modification to the input sample to make the classifier misidentify the malware as a benign (i.e., the adversary introduce an adversarial example). Such modification are usually crafted using small perturbation to make the AE undetectable and very difficult to distinguish for the original sample.
To date, there has been a large body of work exploring the generation of AEs in general image-based classification problems [30,38] as well as in the context of malware classification [5,29,41]. Also, there is an active trend in the research area towards investigating adversarial machine learning to overcome these threat. However, there is very limited research that aims to understand the impact of adversarial learning on deep learning-based IoT malware detection system and practical implications, especially for those approaches that utilize CFG features. We stress the importance of addressing the threat posed by the machine learning vulnerability to AEs, particularly in security-sensitive applications. We undertake this challenge by 1 showing the high potential of successful detection/classification of IoT malware using deep learning methods; 2 assessing the robustness of such methods to AEs generated by different stateof-the-art CFG-based AEs generation techniques; 3 introducing a fine-grained hierarchical approach to tackle adversarial attacks by leveraging patterns extracted from the basic and elementary structure of the tested software.
To this end, we introduce DL-SSMC, Deep Learning-based Single Shot Malware Classification approach, for accurate IoT malware detection and classification. Then, we examine the approach against AEs generated by GEA [5] and SGEA [4]. The GEA and SGEA are graph-based AEs generation approaches that are recently proposed to launch targeted and untargeted misclassification attacks.To cope with adversarial settings and to minimize their effects, we propose DL-FHMC, Fine-grained Hierarchical Learning for Malware Classification, for detecting and classifying malware samples by operating on a fine-grained level of structures and patterns extracted from the tested software sample. Our experiments show the effectiveness of the proposed approach in detecting malware samples as well as high-degree of robustness against variety of adversarial attacks. Summary of contributions. Our contributions are as follows: First, we introduce DL-SSMC for IoT malware detection and classification. Second, we examine the robustness of the CFG-based deep learning IoT malware detection system using two different approaches, including GEA and SGEA. The GEA approach generates adversarial IoT software, through embedding representative target sample to the original software, while maintaining the practicality and functionality of the targeted sample. SGEA is an optimization of GEA to generate AEs with reduced injection size. Through comprehensive experiments, we show the effectiveness of GEA and SGEA in producing successful AEs that can fool the machine learning-based malware detection system. The results show that GEA and SGEA approaches achieve a malware-to-benign misclassification rate of up to 100%. To tackle such vulnerability, we propose DL-FHMC that gains insights by investigating the malicious subgraphs (patterns) within the IoT malware families. Using a fine-grained hierarchical learning approach, DL-FHMC utilizes subgraph mining and pattern recognition to detect suspicious and malicious behaviors within the tested samples, mitigating the effects of AEs and detecting 88.52% of malicious AEs.
Organization. This work is organized as follows: In §2, a brief background is provided. The presented practical approach for generating practical adversarial IoT software is described in §3. In §4, we evaluate the proposed adversarial methods on traditional deep learning techniques. Then, we propose a fine-grained hierarchical learning technique for suspicious behavior detection in §5. In §6, we discuss the proposed adversarial methods and suspicious behavior detection approach. Related work has been discussed in §7. Finally, we conclude our work in §8.

PRELIMINARIES
We incorporate adversarial learning techniques into CFG-based deep learning IoT malware detection systems in an attempt to understand the robustness of such models against adversarial learning attacks as a result of AEs. We provide a required preliminary knowledge for understanding those techniques and approaches required for malware analysis to extract graph structures and to automate their labeling using machine learning. In particular, we provide general knowledge about the malware analysis approaches in §2.1. The CFG-based analysis for IoT malware detection is described in §2.2. Finally, we describe background knowledge about the concept of adversarial machine learning and its effects on machine learning models in §2.3.

Malware Analysis
Malware analysis is widely used to understand the functionality and behavior of malware. It helps us to understand the capabilities and the intent of the malware and malware authors. The results of the analyses are often used to build detectors and design defenses to protect against future malware campaigns. There are two approaches utilized for analyzing malicious software: (i) static and (ii) dynamic analyses. Static analysis approaches analyze malware binaries without the need for execution. Given the malicious nature of the malware, static analysis is utilized as a precursor to the dynamic analysis. The malware binary can then be executed in a sandboxed environment with a much-reduced focus to observe the patterns, like the behavioral artifacts in which is called the dynamic analysis. Static Analysis. Static analysis approaches employ various techniques to extract indicators to determine whether the software is malicious or benign [57]. The various analysis points, such as instructions, basic blocks, functions etc. hint at the possible execution pattern of the software. For example, the traces of using user name and password list, along with shell-based login attempts, implies possible usage of dictionary attack being launched by the software. These inferential results are drawn from static analysis to enable the analysts to emphasize and predict specific patterns. Additionally, traces can also be used by analysts to address issues during dynamic analysis, e.g., virtual machine obfuscation, ptrace obfuscation etc.. Traces and components of software are often extracted using a reverse engineering process of the software binaries that allow the understanding of its composition, architecture, and design. Analysts perform reverse engineering of software binaries using several available off-the-shelf tools. The reverse engineering process also generates artifacts to be subject of analysis including high-level representation of the binaries such as the CFGs and Data Flow Graphs (DFGs). The CFG of a program is the graphical representation of the flow of control during the execution of that program. While the DFG represents the system events to understand the possible execution of the system behaviors. It explains the flow of the data that passes from one node to another. Although static analysis is quite powerful and popular, it sometimes falls short of achieving its end goals of providing in-depth insights to the software due to multiple evasion techniques. For example, malware developers use evasion techniques to the analysis of their produced malware. The evasion techniques include packing (UPX [25]), obfuscation (function-, string-obfuscation), etc.. Dynamic Analysis. Unlike static analysis, dynamic analysis executes the application in a simulated and monitored environment to observe its behavior and understand its functionality [49]. This approach aims to capture different behavioral patterns of software. For example, dynamic analysis helps unraveling the program's network patterns, such as communication with the Command and Control (C&C) server. Since the malicious nature of software can affect the status of the machine it is executed on, the following observations are made: 1) comparing the system state before and after the execution of the application, or 2) monitoring the application's actions during the execution. Similar to the static analysis, dynamic analysis can be evaded by software developers by adopting means that prevent their software from getting dynamically-analyzed. For example, malware developers often employ conditions that crashes the software once encountering virtual machines, debugging tools or network monitoring tools.

Graph Analysis
Graph Analysis. The CFG is a graph representation of the program which shows all paths that can be reached during the execution as in Figure 1. In a CFG, the set of nodes means the basic blocks where each block is a straight-line instruction without any jump or jump target, while the set of directed edges corresponds to the jump which traverses from the block to the other block at the branch (if), loop (while, for), and the end of the function (return). Once the first instruction of the basic block is executed, the rest of the instructions in the same block are necessarily executed unless terminated by external interference. In general, CFG is used for the structural analysis of the program. For example, from the perspective of optimization, the CFG is used to analyze the reachability of each block. By constructing the CFG and evaluating the reachability, the flaws of the program (infinite loop or unreachable codes) can be found and addressed. CFG-based Analysis. In graph theory, there are various concepts that express the characteristics of a graph. Given G = (V , E), for example, the number of vertices (|V |) means the order of G, while the number of edges (|E|) corresponds to the size of G. The density of the graph can be defined as D = |E|/(|V | * (|V | − 1)) for directed simple graph, which means the ratio of the number of edges in G to the maximal number of edges in the complete graph. The centrality is measured for each node v ∈ V , which shows how important a specific node is. In detail, there are several different kinds of centrality, such as closeness centrality, betweenness centrality, Eigenvector centrality, etc..
These indicators (and further concepts not described above) can be considered the features of the graph G. Moreover, the combination of those metrics can be a more deterministic characteristic of the graph. Considering that a CFG is a kind of graph, it is true that each binary has not only its unique graph representation but also the associated values, such as the order, size, and density of CFG, and centrality for each vertex in CFG. On the other hand, the graph-based analysis can provide the possibility for identifying the malware. Because it is highly likely that the binaries in the same "family" share the structural similarity (even if there is a little difference), the CFGbased features can be combined with the state-of-the-art machine learning technique to determine whether a given binary is malicious.

Threat Model
The rapid reliance on machine learning methods in various applications have raised several security and privacy concerns, especially in security-sensitive applications. It has become crucial to understand and assess the robustness of machine learning techniques to several adversarial settings. These adversarial settings includes AEs, where an adversary intends to fool or misguide the classification model with malicious inputs that are generated by applying minimal perturbation to the original sample [41]. These inputs misclassify the samples of the model from benign to malware and vice versa and even misclassify the malware classes to another class. Such adversarial attacks can be launched under different adversarial capabilities that allow for either black-box and white-box attack. In a white-box attack, the adversary has full knowledge of the inner networking paradigm of the model, while in a black-box attack, the adversary has only access to the model via an oracle and observe only the output of the model.
The literature on AEs and their effects shows numerous studies conducted on images, where the perturbation is applied to image pixels [40,41,48]. Unlike image AEs, the generated AEs from the IoT software must preserve the original sample's functionality and practicality in order to function properly. In this study, we generate AEs from the IoT software based on code-level manipulation using GEA [5] and SGEA [4]. Adversarial machine learning can be derived from two perspectives: targeted and non-targeted attacks. Targeted attacks. The focus of this attack is to generate AE x ′ that forces the classifier f to misclassify into a specific target class t. For instance, the adversary generates a set of malicious IoT software samples, which are classified as benign. That is: , where f (.) represents the classifierâȂŹs output, ∆ (x, x ′ ) denotes the difference between x and x ′ , whereas ϵ is the distortion threshold. Non-targeted attacks. The focus of non-targeted attack is to generate an AE that forces the classifier f to misclassify to any class other than the original class f (x), where x is the original input. That is: where f (.) shows the classifier's output, ∆ (x, x ′ ) represents the difference between x and x ′ , and ϵ is the distortion threshold.

MALWARE AND ADVERSARIAL EXAMPLES
This work aims to investigate the robustness of current practices of machine learning in analyzing IoT malware for detection and classification, especially against sophisticated AEs. To generate AE, an adversary applies a perturbation ϵ to the model's input x to fool the classifier by generating a new input feature space , aiming to misclassify the output of the targeted model. For a practical and functional adversarial behavior with the ability of being hiding from detection systems, the perturbation ϵ is minimized to be δ = ϵ min , where f (x) f (x + δ ). For IoT malware detection system, the AE process aims to generate AEs that preserve the functionality and practicality of the original IoT software. Recent work [5] proposed a Graph Embedding and Augmentation (GEA) approach that ensures the practicality of the AEs by applying ϵ at the code-level of the IoT samples. To reduce the perturbation overhead of GEA for efficient adversarial settings, another approach for generating AEs, Sub-GEA (SGEA) [4], was proposed. This section describes the dataset used in this work and the two approaches for generating AEs, namely: GEA and SGEA.

Dataset
For the purpose of this study, we gathered a dataset of IoT malware samples. We collected binaries of two categories, IoT malicious and benign samples. The malicious samples are collected from CyberI-OCs [22] in the period of January 2018 to late February of 2019, with a total of 5,670 samples that belong to three malware families. Additionally, we assembled a dataset of 3,000 benign IoT samples compiled from the source files on GitHub [23]. Ground Truth Class. The benign and malicious samples in our dataset were validated using the VirusTotal [24]. We uploaded the samples on VirusTotal and gathered the scan results corresponding to each sample. We then used AVClass [43] to classify the malicious samples into their families. We summarize the dataset in table 1. Dataset Creation. Samples of the IoT benign category (3,000 sample) and IoT malware category (5,670 samples) were reverse-engineered using Radare2 [26], a reverse engineering framework that provides various analysis capabilities, for obtaining the samples' corresponding CFGs. Using the samples' CFGs extracted by Radare2, we extracted different graph-theoretic features to represent the software sample for the machine learning algorithm. We extracted 23 different algorithmic features categorized into seven groups. Table 2 shows the feature category and the number of features in each category. The five features extracted from each feature category represent minimum, maximum, median, mean, and standard deviation values for the observed parameters.

Graph Embedding and Augmentation (GEA)
Recent work [5] introduces GEA approach that generates realistic AEs, where they maintain the functionality and practicality of the original IoT sample and achieving a high misclassification rate. The main goal was to combine an original CFG with a selected targeted CFG. The authors show that such a combination leads to a high misclassification rate. In the following, we briefly describe the GEA approach using an example. Practical Implementation. Assume x or д is an original sample and x sel is a selected target sample, GEA aims to combine the original sample (x or д ) with a selected target sample (x sel ) while preserving the functionality and practicality of the original sample (x or д ). For example, Listing 1 shows the original sample script (x or д ), and Listing 2 shows the selected target sample script (x sel ). The GEA process combines the two scripts while ensuring that (x sel ) does not affect the process and functionality of (x or д ). The generated AE in Listing 3 shows the script after the combination process. Note that the condition is set to execute only the functionality related to (x or д ) and preventing the processes of (x sel ) from being executed. Prior to generating the CFG for these algorithms, we compile the code using the GNU Compiler Collection (GCC) command. Afterward, Radare2 [26] is used to extract the CFG from the binaries. Figure 1 and Figure 2 show the generated CFGs for both (x or д ) and (x sel ), respectively. As shown in Figure 3, the combined CFG consists of the two scripts sharing the same entry and exit nodes. Therefore, the GEA approach adds modifications to the CFG for generating the AE. Given the nature of the extracted features, the applied changes on the CFG is reflected upon the features, regardless of the effects on the functionality and executability of the original sample. Following the adopted approach in [5], we select six different-sized graphs from benign and malicious samples as x sel . The selected graphs vary in size by minimum, median, or max graph size, where the size is the number of nodes in the graph. To generate AEs, we selected a graph and connected it with all samples from the opposite class using shared entry and exit nodes.

Sub-GEA (SGEA)
While GEA combines an original CFG to a selected CFG of the IoT samples to fool the classifier, SGEA approach aims to reduce the injection size and achive the adversarial objectives with minimal perturbation. More specifically, it uses deep discriminative subgraph patterns extracted from the CFGs of each class using a correspondence-based quality criterion (CORK) algorithm, which defines a submodular quality criterion that ensures a solution close to the optimal solution [47]. This is done by using subgraphs that GEAVar2 += 2 ; } i n t GEAVar3 = 0 ; / / b l o c k 6 } Listing 4: C script of an example Gafgyt extracted subgraph. Each block is represented as a node in the generated CFG. Appending this code to the source code of a sample will lead to producing the subgraph shown in Figure 4.
appear more frequently in one class than others, to fool the machine learning model in predicting that class (e.g., when launching a targeted attack). Let D denotes the CFGs of the training samples, is the class label of graph G i . Also let D + and D − denote the set of graphs in the corresponding classes. For a multi-class dataset, we run the CORK algorithm once for each class where all the graph that belong to the same class are included in D + and the other graphs are the supporting graphs of a subgraph S. Moreover, let D + S and D − S , denote the supporting graphs of the subgraph in the positive and negative graphs, respectively. CORK defines a submodular quality criterion, q, for a subgraph based on the set of supporting graphs ('hits') and non-supporting graphs ('misses') in the two classes and is calculated as follows: . The best quality score is achieved when a subgraph appears in all graphs of one class and not once in the graphs of the other classes; the quality score is 0. Pruning strategies, as used in the quality criterion of CORK, are integrated into the gSpan algorithm [54] to directly mine discriminative subgraphs. Once the set of discriminative subgraphs are mined, we employ gSpan, a graph-based substructure mining pattern for mining frequent subgraphs of size five nodes or higher. Practical Implementation. The original sample (x or д ) is combined with the selected discriminative subgraph (x sel ). For example, Figure 4 shows the discriminative subgraph extracted from the Gafgyt class and listing 4 shows the equivalent C script to generate that subgraph, which can then be combined with the original sample (x or д ) to generate an AE. Figure 5 shows the overview of patterns extraction and the process of generating AEs in the SGEA approach. While GEA modifies the CFG by connecting the selected graph with  the original sample, SGEA connects a carefully generated subgraph with the original sample to generate AE, reducing the injected graph size. To generate the subgraph, we extracted the discriminative subgraph patterns from each class, with a size of five nodes or higher. Then, in order to reduce the graph size needed to be injected, we connect the original sample with the subgraph with minimum size. If the generated AE misclassifies, the process succeed, and the AE will be returned; else, we select the next subgraph in ascending order regarding the number of nodes in the subgraph. In case none of the subgraphs cause misclassification, the original sample will be returned as the process failed. Constructing an AE. As shown in Figure 5, we extract a set of subgraphs from the targeted class. Then, we combine the original sample with the smallest extracted subgraph of the targeted class regarding the number of nodes. If the generated CFG failed to be misclassified by the model, another subgraph is selected in ascending order with respect to the number of nodes in the set of generated subgraphs and combined with the same original graph to generate another CFG. This process is repeated until a subgraph successfully achieves a misclassification. If no existing subgraph from the set of targeted subgraphs causes misclassification, the original sample is returned, hence generating AE is failed.

DL-SSMC: DESIGN AND EVALUATION
This section presents DL-SSMC, Deep Learning-based Single Shot Malware Classification approach. We describe the design and methods for DL-SSMC in §4.1 and present the evaluation in §4.2.

DL-SSMC: System Design
For the malware detection design, DL-SSMC aims to distinguish the malicious IoT applications from the benign. The implementation of DL-SSMC incorporates deep learning models, e.g., Convolutional   Figure 6: Internal design of the CNN architecture used for detection and classification task. Notice that 46@1x3, for example, refers to applying 46 filters each of size 1x3 on the input data. The design consists of four convolutional layers with maxpooling and dropout operations. Then, a dense layer of size 512 is used with a softmax activation function to output the prediction.
Neural Network (CNN)-based and Deep Neural Network (DNN)based models, trained using the extracted CFG-based algorithmic features. The input (X ) to the model is a one-dimensional (1D) vector of size 1 × 23 representing the extracted features. We explore the capabilities of two deep learning architectures, namely CNN and DNN. We describe the separate designs in the following. CNN-based Design. The CNN-based DL-SSMC model constitutes of three blocks, namely convolutional block 1 (ConvB1), convolutional block 2 (ConvB2), and classification block (CB). Figure 6 illustrates the CNN-based DL-SSMC model architecture.
• ConvB1. This block takes in feature vector (X ) as the input. Architecturally, it is made up of two convolutional layers, a 1D convolutional layer (Conv 1) with padding and 46 filters (F b1 ′ ) of size 1 × 3, convolving over the input data (X ) with stride of 1, resulting in a 2D tensor (C b1 ′ ) of size 1 × 23. Followed by a similar 1D convolutional layer (Conv 2) without padding. The output of this layer is a 2D tensor (C b1 ′′ ) of size 46 × 21. Then, a maxpooling operation of size and stride of 2 and dropout with probability of 0.25 are applied. The output of this block is a 2D tensor S b1 of size 46 × 10.
The result of the ConvB1 block (S b1 ) is fed into this block. It is similar to ConvB1, except for the difference in the number of filters (F b2 ′ ) in the convolutional layers. This block consists of a 1D convolutional layer (Conv 3) with padding and 92 filters of size 1 × 3, convolving with a stride of 1. Followed by a similar 1D convolutional layer (Conv 4) without padding. The output of this layer is a 2D tensor C b2 ′′ of size 92 × 8. Maxpooling operation of size and stride of 2 is applied, followed by a dropout with a probability of 0.25, resulting in a 2D tensor S b2 of size 92 × 4.
The generated tensor in ConvB2 (S b2 ) is then fed into this block. The input is forwarded to flatten operation, resulting in a 1D tensor (F l ) of size 1×368. Followed by a fully connected (FC) dense layer (FCL) of size 512 and a dropout with a probability of 0.5 resulting in S F C . Finally, S F C is fed to the softmax layer as the output layer. Figure 7 illustrates the DNN-based DL-SSMC model. The architecture of the DNN-based model consists of two consecutive and fully connected dense layers of size 1 × 100 connected to the input vector, followed by a dropout operation with a probability of 0.25. The output of the dropout function is fed to fully connected with another two fully connected dense layers of size 1 × 100, succeeded by a dropout operation with a probability of 0.5. The output is then fed to the softmax layer. This design enables the extraction of deep feature representations and patterns from the 1/ 21   Input   1x23   1x100  1x100  1x100  1x100  1x100 Softmax Layer Dropout p(0. 25) FPR FNR AR Evaluation Metrics 1x100 Dropout p(0.50) Figure 7: The internal architectural of the DNN used for the detection and classification tasks. The design consists of six fully connected layers, with dropout operations and softmax activation function.
feature vectors, and therefore, finding discriminative characteristics for detection and classification processes. Training Process. We trained the two model architectures, i.e., CNN-based and DNN-based DL-SSMC, using 100 epochs with a batch size of 32. Both the convolutional and the fully connected layers use Rectified Linear Units (ReLU) as the activation function. For regularization, we use dropout to prevent model over-fitting and allow the propagation of robust and distinct features through the model layers. Malware Classification Task. Malware classification task refers to identifying the malware family of targeted samples, while the detection process aims to detect malicious behavior regardless of the category to which the malicious behaviors belong. Therefore, the detection task can be viewed as a binary classification task that aims to detect malicious behavior from the extracted features of the CFG. The classification task, on the other hand, aims to detect and identify the family of the malicious behavior.

DL-SSMC: Baseline
Performance. DL-SSMC: Detection Task. We designed two-class detection DL-SSMC using the CNN-and DNN-based models that distinguish IoT malware from the IoT benign applications. The model is trained over 23 CFGbased graph-theoretic features categorized into seven groups. The   two models, CNN-and DNN-based, achieve an accuracy rate of 98.96% and 98.67% with a FNR of 0.88% and 1.41% and FPR of 1.33% and 1.16%, respectively. Table 3 shows the evaluation of each trained model. DL-SSMC: Classification Task. In addition to detecting the IoT malicious samples, we also design a four-class classification DL-SSMC incorporating CNN-and DNN-based model designs. The classification task aims to evaluate DL-SSMC for classifying the malicious samples into their corresponding families. We achieved a CNN-and DNN-based model accuracy rate of 98.09% and 97.57%, respectively as shown in Table 4. We also provide the the confusion matrices in Figure 8a and Figure 8b to report the performance of CNN-based and DNN-based DL-SSMC for the individual class as each column represents the ground truth class, and every row represents the predicted labels.

DL-SSMC: Robustness Assessment against GEA.
We investigate the robustness of DL-SSMC against AEs generated using GEA. GEA is designed to generate practical AEs that fools the classifier while preserving the functionality and executability of the original sample. We explore the impact of the size of the graph and discuss the fundamental overhead of using GEA. Note that all generated samples maintain the practicality and functionality of the original code. From the benign and malicious IoT software, we selected three graphs as targets (the selected samples have the minimum, median, and maximum size across the dataset). and connected each of these target graphs with every graph in the testing dataset of the other class. We used the target graphs to have different sizes, e.g., minimum, median, and maximum graph size across the dataset, to understand the impact of size on the misclassification rate introduced by AEs using GEA.
Robustness of Detection Models. The results of DL-SSMC performance against AEs generated by GEA are shown in Table 5 and Table 6. Intuitively, a key finding is the impact of graph size on the misclassification rate, since the increase in the graph size, i.e., the included number of nodes, results in higher misclassification rate. However, this success rate of adversarial objectives comes with a computational cost since the reported time for crafting AEs is proportional to the size of the injected graph as perturbation. In the IoT malware detection task, we achieved a malware to benign misclassification rate of as high as 100% on both CNN-and DNN-based models, and a benign to malware misclassification rate of 60.22% and 60.89% on the respective models. Robustness of Classification Models. Table 7 shows the targeted and non-targeted misclassification rates over the IoT malware classification task. Non-targeted misclassification indicates that after combining the original and selected samples, the original sample class changes. On the other hand, if the new assigned label is the selected sample class, it is considered as targeted misclassification.
Here, we achieved a targeted misclassification rate of 100% from all malicious families, i.e., when designing AEs with benign-selected samples so the models misclassify them to benign, using both the CNN-and DNN-based models. Similar to the IoT malware detection  system, the targeted and non-targeted misclassification rates increase with the increase in the number of nodes for the injected graph.

DL-SSMC:
Robustness Assessment against SGEA. The GEA achieves high misclassification rate by injecting the original sample with another selected sample from a target class to fool the models in predicting the wrong class. The GEA approach comes with computational cost and increased binary size that accommodate the combination of two samples into one. These costs are reduced   by using the SGEA approach that reduces the size of injection to carefully selected subgraph that achieves the adversarial objective. Robustness of Detection Models. Table 8 and Table 9 show the results of SGEA against CNN-and DNN-based DL-SSMC detection models. Notice that GEA outperforms SGEA in benign to malware misclassification. However, SGEA achieves 100% malware to benign misclassification rate against CNN-and DNN-based models, outperforming the GEA approach with an average subgraph size of 6.80 and 6.86, respectively. Robustness of Classification Models. Figure 9 and Figure 10 show the results of the CNN-and DNN-based DL-SSMC classification models against the SGEA approach. Figure 9a and Figure 9c represent the non-targeted and targeted misclassification rate using the CNN-based model, respectively. Similarly, Figure 10a, and Figure 10c show the non-targeted and targeted misclassification rate using the DNN-based model, respectively. While the columns represent the sample's original class, the rows represent the class that subgraph pattern was extracted from. Targeted misclassification occurs when the AE's predicted label is not different than the class that the subgraph pattern belongs to. Figure 9b, Figure 9d, Figure 10b and Figure 10d represent the average size of the connected subgraphs to generate the AEs over the CNN-and DNN-based models. For instance, SGEA approach successfully misclassifies all Gafgyt test samples into benign using the CNN-based classification model with an average subgraph size of 20.23 nodes. Moreover, it misclassifies all Gafgyt test samples into other classes using discriminative subgraphs from benign samples with an average size of 6.77 nodes. Note that all classes have a high targeted misclassification rate toward benign class and low targeted misclassification rate from benign to malicious families and among the malicious families. This is a result of the nature of the benign samples; they are diverse in characteristics and functionalities. However, malicious samples within the same family are more likely to share similar behaviors, resulting in distinctive traits that can be captured from the extracted CFG. AE Crafting Time (GEA vs. SGEA). The SGEA significantly reduces the size of AEs and introduces more sophisticated adversarial settings by incorporating reduced perturbation to the software sample. However, similar to GEA, the SGEA approach is computationally extensive. We observe an average AE crafting time of 4.74 and 3.95 seconds per sample using CNN-and DNN-based classification models, in comparison to the average crafting time of 0.65 seconds for the GEA approach.

DL-FHMC: COPING WITH AES
In this section, we propose and describe the DL-FHMC approach, Fine-grained Hierarchical Learning for Malware Classification. Machine learning methods for malware detection and classification, e.g., DL-SSMC, are susceptible to AEs and fall short of delivering a robust system against adversarial settings, as shown in §4. This motivates to explore methods and alternative designs to cope with such vulnerabilities to adversarial attacks. We propose DL-FHMC, a robust system for malware detection and classification that leverages deep learning on a fine-grained and hierarchical manner to detect suspicious malicious behaviors.

DL-FHMC: System Design
The design of DL-FHMC consists of five components as illustrated in Figure 11. Description of each component is in the following.
• CFG Extraction. This component is responsible for extracting the CFGs of the software samples using Radare2, and presenting them as labeled CFGs for further analysis.  Table 2. • Malware Detection. The malware detection component utilizes a CNN-based model that has the model architecture of Figure 6.
The purpose of this model is to classify the samples into malware and benign. Samples classified as benign are directed to a suspicious behavior detection process. Samples classified as malware are directed to a classification model. Suspicious Behavior Detector. Suspicious Behavior Detector is a graph mining-based technique to investigate suspicious malicious patterns within software samples classified as benign. Figure 12 highlights the design of the Suspicious Behavior Detector, which consists of four modules, 1 subgraphs mining, 2 pattern selection, 3 data representation, and 4 suspicious behavior detection model. In the following, we describe each module. 1 Subgraphs Mining: This module extracts common subgraphs within each IoT malware family. Using gSpan, we extracted and collected frequent subgraphs of a size range between 5 to 20 nodes from each malicious family. In particular, we used the gSpan algorithm to extract subgraphs from the training samples of each malicious family. This process took more than 160 hours to finish and resulted in over 2,150,170 patterns distributed as 22,953 for Gafgyt, 127,217 for Mirai, and over 2,000,000 for Tsunami families. The extracted frequent subgraphs (patterns) for each malicious family are then subjected to further analysis. 2 Pattern Selection: This module ranks the extracted patterns based on four factors: pattern size, frequency, coverage, and inverse frequency. For examples, large patterns are assigned higher value since they are distinctive and more likely to be unique to their family. Moreover, large patterns can be further decomposed to smaller patterns. Further, the number of occurrences of a pattern within a malicious family is considered as an indication of its maliciousness. On the other hand, less frequent patterns are more likely to be function-oriented and solely contribute to the functionality of the code rather than the general behavior of the malware family. Therefore, we excluded all patterns that occurred in less than 5% of the targeted family samples. The coverage of the pattern is defined as n i=1 1/occurrence i − 1, where n is a set of samples in which the pattern occurred, and occurrence i is the number of patterns contained within the sample i. For example, if a sample contains only one pattern, that pattern will have the highest rank. In addition, we compute the number of occurrences for each pattern in the benign training samples. Note that benign samples may have patterns similar to the ones in the malware due to the abstract nature of the CFG and the considered size and functionality of patterns. To ensure that all patterns hold some behavioral characteristics of the malicious family, we excluded all malicious patterns that appeared in more than ten benign samples. We filtered the patterns and selected the top 10,000 ranked patterns from each family to be its representative patterns. This results in a total of 30,000 malware patterns for the three malware families. We denote this set of patterns as P.
3 Data Representation: To investigate an IoT software, we find whether each of the selected 30,000 patterns is a subgraph of the CFG of the software using the VF2 subgraph isomorphism algorithm [19]. Each sample is represented as a binary vector in the space of the patterns extracted in the previous module, i.e., v ∈ {0, 1} |P | . Specifically, we represent each sample by a hot-encoding vector v of size 30,000, where v i = 1 if the i th pattern is a subgraph of the sample's CFG, i.e., v i = 1 if p i ⊆ G , p i ∈ P. Time-wise, representing a software's CFG as a hot-encoding vector may require several minutes and up to several hours, depending on its size (number of nodes) and structure. 4 Suspicious Behavior Detection Model: Suspicious Behavior Detector model is a CNN-based model trained on the feature representations extracted from the training dataset shown in Table 1. The goal of this module is to investigate suspicious behavior within the sample. If the sample is classified as suspicious, further analysis is required by an analyst or dynamic analysis approach. Experimental Setup. We trained the Suspicious Behavior Detector model on the feature representation of the training dataset, where all malicious samples are labeled as suspicious. We did not incorporate AEs in the training process, and thus the process may be biased in evaluating the system against samples generated using the same approach (e.g., SGEA). Further, we generated AEs using both GEA and SGEA, to force the detection model to misclassify the IoT malware samples as benign, thereby, directing the samples to the Suspicious Behavior Detector component. The generation of the AEs are similar to the process discussed in §4. However, we focus on the malware to benign misclassification only, as such behavior have critical consequences on the system behavior.  levels of abstractions. The first task of the system is the malware detection, where samples are classified into malicious and benign. This task is conducted using the same model architecture described in §4.1 and illustrated in Figure 6. The baseline performance of the detection model is shown in Table 3 achieving an accuracy of 98.96%. We also demonstrated the robustness assessment of the model against AEs generated by GEA and SGEA in Table 5 and Table 9, respectively. We assume using the same detection model, and evaluate the overall system (DL-FHMC), by including the performance of the the following components of the system, which are the Suspicious Behavior Detector and the malware classification model.  Table 10 shows the performance of the classification model on the AEs. Since the malicious AEs generated by SGEA and large GEA are passed with no detection, i.e., their misclassification rate is 100% on the detection task, they were not directed to the classification model and therefore are not included  Table 11 the detector achieves an accuracy of 93.00% for classifying benign samples and an accuracy of 62.79%, 98.78%, and 100% for classifying GEA-based AEs with small, median, and large perturbation, respectively. The detector achieves a detection accuracy of 79.63% for AEs generated using SGEA approach. Introducing large perturbations in the samples increases the changes of introducing some subgraph patterns that are signatures of the malicious samples. This explains the high accuracy achieved by the detector for large perturbations. This results show that using DL-FHMC enabled a systematic methods of coping with adversarial manipulation to malware. When a suspicious behavior is detected for a given sample, other methods can be adopted to analyze the sample in order to provide robust evaluation of malicious activities.

DISCUSSION
DL-FHMC: Cost of Security. The security of machine learning algorithms is important for many applications since it has been shown that such algorithms are vulnerable to adversarial attacks (i.e., AEs). In malware classification field, AEs pose critical security implications as emerging studies have shown that AEs can fool the machine learning-based malware detection system [4,5,45]. However, limited studies have investigated potential defenses. In this work, we show that launching adversarial attacks against malware detection system can lead to a misclassification rate of as high as 100%. To cope with such adversarial settings and capabilities, we introduced DL-FHMC that operates on multiple level of behavioral analysis of the software to insure its security. Since AEs are derived from a combination of benign and malware components, detecting them is a challenging task and often comes at the cost of misclassifying a portion of benign samples as malicious, hence producing false alarms. For example, in our experiments, we show that successfullydetecting 88.52% of AEs is accompanied by 7.00% false alarms resulting from detecting suspicious behavior in the benign samples. DL-FHMC Robustness. The suspicious behavior detector in DL-FHMC consists of a CNN-based model trained on the vector representations of the extracted patterns. In the context of adversarial attacks, it should be robust against perturbation to the original samples. Otherwise, it will suffer from the effects of adversarial examples. We took this into account in the design process. Ideally, the detector represents the benign samples into a vector representation of zeros. In our dataset, ≈ 85% of the benign samples are represented as a vector of all zeros, indicating that none of the malicious patterns captured within them. Therefore, to generate successful AEs against DL-FHMC, adversaries have to conceal malicious patterns by modifying the functionality of the malicious sample, therefore, contrasting the practicality and functionality requirements of the generated AE. Potential Investigation Technique: Dynamic Analysis. For accurate and fail-proof malware detection, every sample should be analyzed dynamically and filtered based on its behavior. However, dynamic analysis has its own downsides: 1 It requires setting up of a sandboxed environment such that the execution of the malware does not impact the underlining host system. 2 It is costly in terms of time and memory. These make the dynamic analysis techniques difficult to scale. Our proposed technique puts forward a static analysis based fine-grained hierarchical approach towards malware detection. The samples classified as benign in the first phase are sent to the Suspicious Behavior Detector for investigation using the deeper CFG based features (subgraphs). The samples that are detected as suspicious in the second phase are finally considered as potential for dynamic analysis. Statistically, only 2.42% (42 out of 1,733) of the normal samples, i.e., non-adversarial, were identified as the ones to be directed for dynamic analysis, thereby reducing the load on the dynamic analysis technique, hence overcoming its potential difficulties. Binary Obfuscation. Malware authors often use different packing techniques, e.g., Ultimate Packer for Executables (UPX), to obfuscate different parts of the malware code base, such as functions and strings. In obfuscated functions, the CFG would differ from the actual unpacked malware. Thereby, the detector should be aware of obfuscation and can accurately classify the obfuscated software and examining the behavior of packed and unpacked software.

RELATED WORK
Malware Analysis. While a lot of effort has been put towards malware analysis and detection in general, IoT malware analysis still lacks the effort. Among the IoT malware studies, efforts towards the analysis and detection of malicious software are limited, particularly, from the lens of CFG. ManXu et al. [53] proposed a CNN-based malware detection system for the Android application from the semantic representation of the graph (i.e., control and data flow graphs representations). In addition, Yang et al. [55] identified and detected Android malicious behaviors throughout generating two-level behavioral representations built from the CFG graph and call graphs of the program. Allix et al. [11] designed multiple machine learning classifiers to detect Android malware using different textual representations extracted from the applications' CFGs. Further, Alasmary et al. [9] conducted an in-depth CFG-based comparative study for the Android and IoT malware. Similarly, Pa et al. [39] established the first IoT honeypot and sandbox system, called IoTPOT, that run over eight CPU architectures to capture the IoT attacks running over Telnet protocol. Similarly, Caselden et al. [17] built an algorithm that generates an attack from the representation of the hybrid information and CFG applied to the program binaries. Alam et al. [7] proposed a metamorphic malware analysis and detection system that uses two different techniques that match the CFGs of small malware and then address the change in the opcodes frequencies. Moreover, Tamersoy et al. [46] proposed a malware detection algorithm that identifies the executable files of the malware and then computes the similarities between them to partial dataset files from the Norton Community Watch. Then, they construct graphs based on the measurement of inter-relationship between these files. In addition, Wuchner et al. [51] proposed a graph-based detection system that uses a quantitative data flow graphs generated from the system calls, and use the graph node properties, i.e., centrality metric, as a feature vector for the classification between malicious and benign programs. Moreover, they extended the work by using a compression-based mining technique applied to the quantitative data flow graphs for malware detection [50]. Moreover, Cen et al. [18] used Android API calls as features extracted from the decompiled source code of the software, and proposed a probabilistic logistic regression-based model for malware detection. Adversarial Machine Learning. Machine/deep learning networks are widely used in security-related tasks, including malware detection [10,13,36,37]. However, it has been shown that deep learningbased models are vulnerable against adversarial attacks [35]. Given that, it should be noted that such a behavior can be a critical issue in malware detection systems, where misclassifying malware as benign may result in disastrous consequences [4,6]. Various adversarial machine learning attack methods in the context of image classification have been introduced to generate AEs. For example, Goodfellow et al. [30] introduced FGSM, a family of fast method attacks to generate AEs that forces the model to misclassification. In addition, Carlini et al. [16] proposed three L-norm-based adversarial attacks, known as C&W adversarial attacks, to investigate the robustness of neural networks and existing adversarial defenses. Similarly, Moosavi et al. [38] proposed DeepFool, an L 2 distance-based adversarial iterative method to generate AEs with minimal perturbation. Further, a critical application of the AEs is malware detection. Recent studies investigated generating AEs in the context of malware detection [45]. For instance, Grosse et al. [29] implemented an augmented adversarial crafting algorithm to generate AEs, misleading a CNN-based classifier to misclassify 63% of the malware samples to benign. The detection of the AEs is challenging [15]. While, to the best of our knowledge, no one has investigated the detection of AEs in the context of malware detection, multiple studies attempt to detect them in the context of image classification [33,34,52], achieving detection accuracy of 20% to 80%. In this study, we implemented DL-FHMC, a graph mining-based fine-grained hierarchical learning approach for suspicious behavior detection, achieving an accuracy of 88.52% in detecting CFG-based AEs.

CONCLUSION
This work investigates the robustness of graph-based deep learning models against adversarial machine learning attacks. To set out, first, an in-depth analysis of malware binaries is conducted through constructing abstract structures using CFG, which are analyzed from multiple aspects, such as the number of nodes and edges, as well as graph algorithmic constructs, such as average shortest path, betweenness, closeness, density, etc. Then, two IoT malware classification approaches are introduced, DL-SSMC and DL-FHMC. Then, we generate AEs using two state-of-the-art adversarial attacks, GEA and SGEA approaches. We observed that both GEA and SGEA are capable to misclassify 100% of malware samples as benign in DL-SSMC. However, DL-FHMC was able to detect 88.52% of the AEs, improving the overall robustness in compare to DL-SSMC.