{'fraction_non_alphanumeric': 0.0254403967846759, 'fraction_numerical': 0.006926629040533607, 'mean_word_length': 4.5981330780277645, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Novel Control-flow based Intrusion Detection Technique for Big Data Systems

Security and distributed infrastructure are two of the most common requirements for big data software. But the security features of the big data platforms are still premature. It is critical to identify, modify, test and execute some of the existing security mechanisms before using them in the big data world. In this paper, we propose a novel intrusion detection technique that understands and works according to the needs of big data systems. Our proposed technique identifies program level anomalies using two methods - a profiling method that models application behavior by creating process signatures from control-flow graphs; and a matching method that checks for coherence among the replica nodes of a big data system by matching the process signatures. The profiling method creates a process signature by reducing the control-flow graph of a process to a set of minimum spanning trees and then creates a hash of that set. The matching method first checks for similarity in process behavior by matching the received process signature with the local signature and then shares the result with all replica datanodes for consensus. Experimental results show only 0.8% overhead due to the proposed technique when tested on the hadoop map-reduce examples in real-time.


I. INTRODUCTION
The architectures for big data systems rely on parallel execution techniques like mapreduce [1] for fast processing. With the growing popularity of real-time data processing in big data environments, there is a pressing need to re-imagine the traditional computing techniques. For example, data locality in popular big data system distributions like hadoop [2] and spark [3] is redefined as bringing compute to data instead of the traditional approach of the moving the data that needs to get processed. This trend of re-inventing the traditional methods do not necessarily transform to the security needs of big data. The security features implemented in big data systems are still based on traditional methods for systems based on general purpose machines. User authentication, multi-level data access control and logging are typically used for security in big data [4]. Data encryption is slowly being adopted in the big data field, but it is limited by big data properties like volume and velocity. As we covered in our previous work [5], big data security is premature and there is a lot of scope for improvement in this area. For instance, the current security standards for big data systems assume systemlevel consistency which is not necessarily true always. We demonstrated in our previous work [5] that big data platforms can be affected by insider attacks. In this work, we concentrate on detecting process-level intrusions within big data systems.
Intrusion detection systems (IDS) can identify malicious use based on their knowledge of possible threats or by learning from the behavior of programs. Knowledge-based IDS usually search a program for known threat signatures that are stored in a database. With new and zero-day attacks emerging regularly, it is impractical to have a pre-populated database of all possible threats. Even if it is assumed to have such a database, maintaining it would require a lot of resources and running search queries against it would be expensive. Behavior based IDS tries to model, analyze and compare application behavior to identify anomalies. This technique needs more resources and is more complex than signature-based IDS but it is more effective in a dynamically changing threat environment. Behavior based IDS generally use statistics and rules to detect anomalies. Figure 1 gives a taxonomy of the different types of IDS.
In today's internet age, a distributed implementation of IDS is needed for which aggregation, communication and cooperation are key factors of success. Distributed IDS gives centralized control and detects behavioral patterns even in large networks but it has to be employed at multiple levels: host, network and data [6]. Hence, using big data in generalpurpose distributed IDS implementations is recommended for faster processing. In this work, we concentrate on IDS that can be used for security within big data systems. IDS within a big data system favors anamoly-based IDS when compared to knowledge-based IDS because of the naturally large and ever increasing scope of threats.
Using control-flow graphs for logic level intrusion detection is a commonly known idea [7], [8], [9]. For example, controlflow integrity [10] is a security mechanism that can identify misuse of application logic bugs, like buffer-overflow attacks. Though CFGs are generally sparse graphs, they can grow very big in size. Hence, it is important to design IDS techniques that can work with a reduced representation of CFGs. A Minimum Spanning Tree (MST) contains all vertices and only some paths of its source graph and the number of MSTs for sparse graphs is generally less. Hence, a set of MSTs extracted from a CFG can be used for IDS that detects program level anomalies.
In this paper, we propose a control-flow based intrusion detection technique for big data systems. The proposed technique checks for program level anomalies in big data applications by analyzing and comparing the control-flow behavior of all processes running inside a big data system. The proposed intrusion detection technique is divided into two parts. First, the control-flow of each process running on a data node in the big data cluster is locally analyzed. This is done by extracting a set of MSTs from the instruction level CFG of a compiled program. The extracted set of MSTs are hashed and stored in an array called the program signature. Then, the stored program signature is encrypted and shared with other replica nodes that run the same program. In the second step, the received encrypted program signature is decrypted and matched with the local version to check for coherence. Matching two program signatures involves finding a perfect match for every MST in a signature within the set of MSTs of the other. The result of the matching step is then shared with replica nodes for consensus. Our technique is designed to be simple, scalable and efficient in identifying both control-flow and brute-force attacks.
The rest of this paper is organized as follows. Section II gives some background about big data systems, controlflow graphs and IDS. The various related works are also discussed here. Section III explains the proposed intrusion detection technique in detail. Experimental setup and results are thoroughly discussed in Section IV. Finally, Section V gives the conclusion and future work.

II. BACKGROUND AND RELATED WORK
In this section, background about the three topics -big data systems, control-flow graphs and intrusion detection is provided. The related works are briefly outlined here.

A. Big Data Systems
Big data systems are data driven and their work can be classified into 2 major tasks -writing user data to the disk for storage and; reading stored data when user requests for it. Typically, this data is quantified in units called blocks. For fast and fault-tolerant service, big data systems rely on replication of data blocks which in turn demands data consistency. Big data systems cannot afford to have read or write service-level inconsistency. The motivation for this work comes from a weak assumption in the big data community that the services used by a big data system to maintain data consistency are never attacked. It is our knowledge that this problem has not been widely addressed before.
To propose an IDS for big data services, it is important to understand how the services work. For this, we picked 2 popular big data services -reads and writes. When a client (or user) wants to write a block, the namenode picks n data nodes from the big data cluster to complete this task where n is the replication factor of the cluster. First the namenode checks if the datanodes are ready. It sends a ready request to datanode1 which when ready, forwards that request to datanode2 and so on. When the namenode knows that all n datanodes are ready, it asks the client to start writing. The client only writes to datanode1 which is subsequently written on to datanode2, datanode3 and so on. In case of any failure, namenode orders a new datanode to maintain block replicas. When the client wants to read a block, namenode gives the client a list of all datanodes that have the block and the client picks first datanode. If there is a problem reading from datanode1, the client request gets forwarded to the next datanode that has a copy of the same block.

B. Control-flow Graphs
A control-flow graph (CFG) is a directed graph representation of a program and usually a sparse graph. CFGs include all possible control paths in a program. This makes CFG a great tool to obtain control-flow behavior of its process. Vertices in a CFG give the level of detail, such as instructionlevel or basic block level, that cannot be further divided. Edges in CFG represent control jumps and are classified into two types -forward and backward. Branch instructions, function calls, conditional and unconditional jumps account for forward edges. Virtual calls and indirect function calls are also considered as forward edges but their destinations are difficult to determine. Loops and returns generally account for backward edges. The integrity among duplicate processes that run on replica nodes of a big data system can be verified with the information available in a CFG [11]. Similarity check between program logic of two programs can be performed by comparing their CFGs for isomorphism. There are many ways to check for such graph isomorphism [24], [25] but analyzing the similarity of two processes by conducting CFG level graph isomorphism is hard and time consuming. Graph isomorphism is a complex problem, sometimes known to be NP-complete as well [8]. To reduce the complexity of graph algorithms, CFGs can be reduced to trees or subgraphs before performing any coherence or integrity checks [12]. A CFG can be converted to a tree using methods such as Depth-first traversal. Several tree structures like Dominator Tree, Minimumm Spanning Tree (MST), Minimumm Spanning Arborescence (MSA) can be extracted form CFGs [13], [14], [15]. For this work, MST and MSA can be used interchangeably. CFGs can be broken into subgraphs using methods like k sub-graph matching and • Based on Edit Distance: Using Smith-Waterman algorithm with Levenshtein distance to identify similarity between two graphs represented as strings [16]. The time complexity is O(nm). • Based on Traversal: (a) A preorder traversal of a graph G where each node is processed before its descendants. (b) A reverse postorder in a DAG gives a topological order of the nodes [17]. • Based on Dominator trees: A data structure built using Depth First Search or using the method proposed by Tarjan in [18]. Tarjan's method has a time complexity of O((n+m)log(n+m)). • Based on Reachability: Transitive reduction of a sparse graph to another graph with fewer edges but same transitive closure [19]. The time complexity is O(nm).
In this work, we chose to reduce a CFG to a set of MSTs because CFGs are generally sparse graphs and hence the size of the set of MSTs will be finite and small. Edmond's algorithm can be used to extract MSTs from a digraph [13], [14], [15]. Since an MST contains all vertices of its graph, there will be no loss in the program instruction data. Depend-ing on the connectedness of the graph, the edge count will defer between the CFG and MST representation of a program. Figure 2 shows transformation of a line of java code to basic blocks of bytecode to CFG to set of MSAs. Vertices B1, B2, B3, B4 are the basic blocks formed from java bytecode. There exists an O(m + n log n) time algorithm to compute a min-cost arborescence [13]. Alternately, another approach for converting a CFG to MST using union find is used by popular compilers like llvm and gcc for security purposes [?]. One known disadvantage of using CFGs and MSTs for security is that dynamic link library calls cannot be verified.

C. Intrusion Detection Systems
Traditionally, IDS checks for known malware in programs by performing signature matching on a threat database [20]. Signature match using exact string matching is limited in its scope. This is because variants of same attack will have different signatures. Recently, methods to detect new malwares using statistical machine learning have been proposed. Static analysis using CFG is another efficient way to detect intrusions but it is very complex [21]. Converting a CFG to a string and implementing string matching is another way to deal with this problem but the solution will not be polynomial. Also, CFG at basic block level can have basic block variants that look different but perform the same function. To deal with these shortcomings, many approximate matching techniques have been proposed. Tracing applications to get their CFG is another approach that is used in applications like xtrace, pivottrace etc [22], [23]. In case of big data systems, data nodes usually have the same processor architecture. Hence it can be assumed that there will be no variants when the CFG is constructed at byte-level. It is then sufficient to verify similarity among the CFGs of two processes to confirm coherence in the nodes of a big data system.

III. PROPOSED TECHNIQUE
In this section, we describe our proposed two-step intrusion detection technique for big data systems. The first step involves capturing the control-flow of a process running on a datanode of the big data system. The second step involves processlevel similarity check followed by consensus among replica datanodes.

A. Generating Process Signatures
In this work, we emphasize on process level intrusion detection by observing coherence in the behavior of duplicate processes running on replica datanodes of a distributed big data system. To capture the program behavior, the first step is to identify a representation of the program that has the information we need and filters out all other data. We call this representation as the program signature. Since our goal is to identify intrusions from control-flow mismatch, our program signatures should contain all possible control flow information of a program.
Compiled source code of a program is generally used to generate static CFG. Since most big data frameworks use , an instruction level CFG in this context is generated from java byte code. In this work, disassembled object code (DOC) from java byte code is used as input to generate the CFG at instruction level. It is important for the program signature to contain only the information that is necessary. Hence, every CFG is converted into a set of MSTs that are later used to generate the program signature. In this work, we propose the idea of representing a program by a set of MSTs/MSAs that can be extracted from a byte-level CFG using Edmonds algorithm. This set of MSTs that are extracted from a CFG are further filtered to only the set of edge-disjoint MSTs. There are many versions proposed for Edmonds algorithm [13], [14], [15] and for this work we used a version from NetworkX graph library [31] that generates edge disjoint spanning trees from the root vertex of a given digraph. Once a minimal representation of the logic in a program is obtained in the form of an MSA, it is converted into a string by listing the node list first followed by edge list, which is in accordance to the DOT format representation.
The length of a MST string in DOT format is dependent on program size. To make the comparison step faster, we convert the variable length MST strings of a program to fixed length strings using hashing. The extracted set of edge-disjoint MSTs are hashed using popular hashing algorithms like SHA or MD5 to generate a set of fixed-length hash strings. Since a sparse graph like CFG can have multiple MSAs, the program signature can be a single hash string or a set of hash strings. Having all possible MSAs in the program signature makes the graph similarity check more reliable. In the end, a program signature is a set of fixed-length strings.
Program signatures are encrypted before being shared with replica datanodes for tighter security. The private key for encryption is generated from a harcoded master key if we use secure hardware like the one proposed in our previous work [5]. Every datanode in a big data system runs the proposed profiling method for every running process and it includes all the steps involved in converting the compiled binary of a program to its program signature. A pictorial representation of the steps in profiling method is given in Figure 3.

B. Matching Process Signatures
Replication property of big data systems opens scope for new methods of implementing application logic level IDS techniques. Process similarity check among duplicate nodes of the cluster helps in checking for coherence among the replica datanodes while performing a write or read operation. When a process is scheduled to run on a datanode that hosts the primary copy of a data, a signature for that process is created by the profiling method (Step 1) of our proposed IDS technique and that signature string is shared with all replica datanodes. In the matching method (Step 2), these signatures received from other datanodes are decrypted and matched with the local versions of the same process. The results are shared with all other replica datanodes for consensus. For secure communication among datanodes, we intend to use the same secure communication protocol that was proposed in our previous work [5].
The most important part of the matching method is to check for similarity (or dissimilarity) between two program signatures. Generally, graph similarity check can be performed by checking node similarity and edge similarity. The following points are considered while comparing MSTs to check for similarity among programs: • MSTs are sparse graphs obtained from byte-level CFGs. Hence, checking for path sensitivity is not exponential. • All edges are assumed to have the same weight of 1. • The total number of MSTs for a CFG is limited (by Cayley's formula [26]). • By Edmonds theorem, a graph which is k-connected always has k edge-disjoint arborescences. • Two MSTs are a perfect match if their node sets and edge sets match exactly. • If edge set of one MST is a subset of the edge set of another MST, the source graphs of these MSTs are not similar. • Two graphs are similar if for every MST in one graph there exists a perfect match in the set of MSTs of the other graph. • Hashing algorithms like SHA1 or MD5 are quick and efficient. Based on the points listed above, the following method is developed for graph similarity check. Let us consider 2 control-flow graphs G1 and G2. Let <N 1, E1> represent G1 where N1 is the node set of the graph G1 and E1 is the edge set of the graph. Similarly, <N 2, E2> represents G2 where N2 is the node set of the graph G1 and E2 is the edge set of the graph. After employing a variation of Edmonds algorithm on these CFGs (such as finding all edge-disjoint MSTs), lets us assume that M1 [<N 1, E1 >] is the set of MST/MSA for G1 and M2 [<N 2, E2 >] is the set of MST/MSA for G2. In order to check for similarity in both graphs G1 and G2, we check if there is a perfect match in M2 for all MSTs in M1. In order to simplify the match function, we propose using a hash function on M1 and M2 that creates a unique hash for every MST. Let H1 be a set of hashes generated from M1 and H2 be the set of hashes from M2. If any hash in H1 does not exist in H2, we deduce that the graphs are not equal.

IV. EXPERIMENTAL RESULTS
In this section, the experimental setup and experiments used for testing the proposed technique are provided. The results and some analysis are also provided.

A. Setup
An Amazon EC2 [27] m4.xlarge instance running Ubuntu 14.04 is used to generate MSTs (and their hashes) from CFGs using SageMath. The proposed technique was implemented and tested on an Amazon EC2 big data cluster of 5 t2.micro nodes -1 master node, 1 secondary master node and 3 datanodes with a replication factor of 3. The list of softwares used in conducting our experiments are: • SageMath [28] is a free open-source mathematics software system for mathematical calculations. • GraphML [29] is a popular graph representation format which can used to represent both CFG and MST. • Graphviz [30] is open source graph visualization software that takes input in DOT format and makes diagrams in useful formats. • NetworkX [31] is a Python language software package that provides graph algorithms like Edmonds and VF2. • Control-flow graph factory [32] is a software that generates CFGs from java bytecode (class file) and exports them to GraphML or DOT formats.

B. Experiments
The proposed intrusion detection technique was tested using 16 hadoop map-reduce examples that can be found in all hadoop distributions. These examples cover a wide range of big data applications as listed in Table I. The class files of these examples are readily available in the hadoop distributions. First, control-flow graph factory [32] was used to generate control flow graphs from the class files. These graphs are stored in graphml format and given as input to a simple Sage-Math [28] script that uses NetworkX library [31] and computes the edge-disjoint MSAs and hashes them using MD5. A C++ application was used to implement encryption and secure communication needed for the proposed IDS technique. The implementation was based on framework from [5]. The hashes are fixed length strings and so we restrained to using a basic numeric key based left/right shift for encryption/decryption of messages. Since there are no benchmarks for some of these examples, we executed them with minimum input requirements.   Figure 4b that the time required by the proposed technique is influenced by the profiling method trying to extract MSAs from CFG, particularly when there are more than one MSAs for a CFG. Though the matching method performance is directly proportional to the square of the size of the number of edge-disjoint MSAs in a CFG i.e. O(n 2 ) worst case complexity, we observed that it is rare to have more than a couple of edge-disjoint MSAs in a CFG because of the sparse nature of CFG.

V. CONCLUSION AND FUTURE WORK
In this paper, we introduced a novel approach to detect program level intrusions in big data systems with help of control flow analysis. The main idea is to use the replication property of big data systems and check for coherence in program behavior among replica datanodes. Behavior of a program is modeled by extracting a MSA set representation of its CFG. Similarity check among duplicate programs is performed by a complete matching among hashed sets of MSAs. Experiments were conducted on real-world hadoop map-reduce examples and it is observed that the proposed technique takes only 0.8% of execution time to identify intrusions. The naturally sparse nature of CFGs helps in achieving this low overhead. For future work, we would like to explore graph string matching and compare the proposed matching method (step2) with other graph isomorphism techniques.