{'fraction_non_alphanumeric': 0.03738592335518463, 'fraction_numerical': 0.009438293027782369, 'mean_word_length': 4.42916957431961, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Safeguarding the IoT from Malware Epidemics: A Percolation Theory Approach

The upcoming Internet of things (IoT) is foreseen to encompass massive numbers of connected devices, smart objects, and cyber-physical systems. Due to the large-scale and massive deployment of devices, it is deemed infeasible to safeguard 100% of the devices with state-of-the-art security countermeasures. Hence, large-scale IoT has inevitable loopholes for network intrusion and malware infiltration. Even worse, exploiting the high density of devices and direct wireless connectivity, malware infection can stealthily propagate through susceptible (i.e., unsecured) devices and form an epidemic outbreak without being noticed to security administration. A malware outbreak enables adversaries to compromise large population of devices, which can be exploited to launch versatile cyber and physical malicious attacks. In this context, we utilize spatial firewalls, to safeguard the IoT from malware outbreak. In particular, spatial firewalls are computationally capable devices equipped with state-of-the-art security and anti-malware programs that are spatially deployed across the network to filter the wireless traffic in order to detect and thwart malware propagation. Using tools from percolation theory, we prove that there exists a critical density of spatial firewalls beyond which malware outbreak is impossible. This, in turns, safeguards the IoT from malware epidemics regardless of the infection/treatment rates. To this end, a tractable upper bound for the critical density of spatial firewalls is obtained. Furthermore, we characterize the relative communications ranges of the spatial firewalls and IoT devices to ensure secure network connectivity. The percentage of devices secured by the firewalls is also characterized.


I. INTRODUCTION
The surging Internet of Things (IoT) and cyber physical systems (CPS) are extending wireless connectivity to billions of new devices of multitude heterogeneity [1]. In addition to phones, tablets, and laptops, the IoT and CPS integrate appliances, sensors, actuators, machines, robots, vehicles, and many other smart objects to the wireless infrastructure. It is speculated that the numbers of IoT devices per square kilometers will be in the order of millions [2]. Such ubiquitous, largescale, diverse, and massive wireless connectivity is essential for big data aggregation and smart world automation, which is expected to improve almost every aspect in our lives [1]. For instance, health care providers can access real time vital signals for patients through connected body sensors, which improves diagnostics, enables early disease detection, and decreases infection risks. Smart power grids utilize wireless connectivity of smart meters and field devices to improve energy generation and distribution. Intelligent transportation systems with connected/autonomous vehicles exploit wireless connectivity to improve road safety and reduce traffic congestion. Large-scale massive connectivity is also foundational for process automation in the next industrial revolution (i.e., industry 4.0). In addition to the aforementioned examples, IoT/CPS can bring unlimited potentials to many other verticals such as crowd management, public safety, agriculture, retail, etc.
The aforementioned benefits of IoT/CPS come at the cost of a plenty of new and challenging security threats [3]- [7]. The IoT and CPS devices are mainly installed and controlled via consumers who have limited knowledge about security threats and countermeasures. The imposed high competition between IoT vendors leads to overlooking cybersecurity aspects in order to accelerate the production of devices and reduce their prices. Furthermore, many of the IoT and CPS devices do not have sufficient energy, storage, or computational power to implement up-to-date anti-malware programs and/or sophisticated intrusion defense mechanisms [8]- [11]. In largescale IoT/CPS networks, there is no distinct boundary between secured and public (i.e., unsecured) domains to enforce security policies on the incoming/outgoing traffic. The lack of per-device defense mechanisms and network-wide security administration open several loopholes for network intrusion and malware infiltration. Even worse, exploiting the high spatial density of devices and direct wireless connectivity (e.g., machine-to-machine and device-to-device communications), the malware infection can stealthily propagate from one device to another and form an epidemic outbreak without being noticed to security administration [8], [12]- [14]. Malware diffusion through the devices can be further accelerated via emerging beyond 5G technologies such as non-orthogonal multiple access (NOMA) and ultra-reliable low latency communications (URLLC), which are meant to enhance information dissemination.
A malware outbreak gives adversaries the opportunity to compromise large population of IoT/CPS devices, which can then be used to launch versatile criminal and hostile attacks. Examples of generic IoT/CPS attacks are network-jamming, colluded eavesdropping, spoofing, denial of service, and data falsification [15]. The negative impact of any of the aforementioned attacks is proportional to the number of compromised devices. It is worth noting that, in IoT/CPS systems, adversaries can compromise, control, and manipulate physical equipment, which may lead to physical consequences such as equipment sabotage, power outage, vehicles collisions, or workers injury [3]. The aforementioned security risks call for resilient, robust, and ubiquitous security countermeasures to safeguard IoT/CPS networks from large-scale malware attacks.

II. PRIOR ART & CONTRIBUTIONS
One major research direction is to develop lightweight security countermeasures for IoT/CPS devices. Per-device IoT/CPS security can be implemented either in hardware [16] or in software [17], [18]. However, many IoT/CPS devices are too constrained (e.g., storage, energy, and computational power) to implement such per-device countermeasures. Furthermore, due to the massive number of devices, implementation of hardware solutions and licensing of software countermeasures may impose overwhelming monetary costs. Hence, it is infeasible to ubiquitously safeguard 100% of the devices against malware intrusion/infection [9], [10], [19]. Articulated differently, interim infection of some devices is inevitable in largescale massive IoT/CPS systems. Hence, timely detection and treatment of malware is the security challenge in large-scale IoT/CPS networks such that malware outbreak is prevented. Otherwise the malware infection goes out of control and large populations of devices are compromised.
To detect compromised devices, the authors in [20], [21] propose software attestation schemes to insure the integrity of the running software and configuration of IoT devices. However, the attestation schemes in [20], [21] are centralized, which may impose overwhelming overhead traffic and delay to detect compromised devices. The work in [9] proposes a game theoretic approach to select the devices that install anti-malware programs such that an epidemic outbreak is prevented. However, the proposed mechanism in [9] is based on a fully mixed epidemic model, 1 which is not adequate for wireless IoT networks. Accounting for the physical layer parameters of wireless networks, the authors in [10] propose periodic software patching for IoT/CPS devices to eliminate potential malicious codes to combat botnet formation. However, the technique proposed in [10] is oblivious to the device status, which may lead to unnecessary disruption for the IoT/CPS operation as a price for patching healthy devices. Furthermore, compromising a device shortly after being attested and/or patched may grant adversaries enough time to launch malicious attacks. Such scheduled software attestation/patching problems are more acute when employing wireless technologies such as NOMA and URLLC due to the accelerated epidemic infection rate.
To overcome the aforementioned problems, the authors in [22] propose a novel countermeasure denoted as "spatial firewalls". The spatial firewalls are wireless devices, with sufficient computational power, energy resources, and memory, to store, execute, and frequently update anti-malware and intrusion detection programs. Spatial firewalls can be edge servers, access points, or capable IoT/CPS devices, which are randomly deployed in the network to analyze the wireless traffic in order to detect and thwart emerging malware infections. However, the exposition in [22] is based on simulations, which lacks the mathematical details that are necessary to prove the concept, assess, and design spatial firewalls. In this context, we develop a rigorous mathematical framework to assess and design spatial firewalls. In order to account for the underlying limited-range wireless connectivity for the firewalls and IoT/CPS devices, we utilize percolation theory on random geometric graphs (RGG) for the developed mathematical framework.
It is worth noting that percolation theory on RGG is widely used to assess information dissemination and global network connectivity in wireless sensors networks [23], [24], robot swarms [25], high altitude platforms [26], and connected unmanned aerial vehicles [27]. Percolation models are also used to study information dissemination in cognitive networks [28], [29]. Note that the models in [23]- [29] assume proximity based wireless communications, which does not account for the aggregated network interference. Interferenceaware percolation models are developed in [30], [31], where nodes communicate if and only if the signal-to-interferenceplus-noise ratio exceeds a certain threshold. Percolation theory is also used in [32], [33] to study private information dissemination in the presence of eavesdroppers.
In this paper, we utilize percolation theory on RGG to characterize wireless malware propagation in IoT/CPS networks, and hence, prove the concept and assess the spatial firewalls solution. That is, we mathematically prove the existence of a critical density of firewalls beyond which malware outbreak becomes impossible. To this end, we find a tractable upperbound on the critical density of firewalls that is required to safeguard large-scale IoT/CPS networks against malware epidemics. In addition, we present several insights for the design of spatial firewalls. The contributions of this paper can be summarized in the following points • We define the infection susceptible graph (ISG) to characterize the risk malware propagation in large-scale IoT/CPS networks. • Using percolation theory along with the ISG, we prove that properly designed firewalls are capable to safeguard large-scale IoT/CPS networks from malware outbreak irrespective of the infection propagation rate. • We derive a tractable upperbound for the critical density of spatial firewalls that is required to safeguard large-scale IoT/CPS networks against malware epidemics. • We analytically characterize the IoT/CPS communications range that allows network connectivity while prohibiting malware epidemics. • We provide several insights on the percentage of IoT/CPS devices that are protected via the spatial firewalls.
It is worth noting that the spatial firewalls represents one layer of the IoT cybersecurity countermeasures. In the IoT era, specially when the devices are simple, ultra-dense, and managed by general public, the security problem is not a single-sided IT problem. Instead, cybersecurity in IoT is a multi-dimensional problem that should be collaboratively solved by wireless communication experts, machine learning experts, hardware designers, software developers, IT experts, in addition to IoT consumers by raising awareness regarding cybersecurity threats. This paper focuses on the wireless com-

A. Paper organization
The rest of the paper is organized as follows. Section III presents the system model and formulates the large-scale malware epidemic problem in terms of graph and percolation theory. Section IV proves the concept of spatial firewalls and shows the existence of a critical density for the spatial firewalls that safeguards large-scale IoT/CPS from malware epidemics. Section V discusses different design schemes for the spatial firewalls. Simulation and numerical results are presented in Sec. VI. Finally, concluding remarks are given in Sec. VII. For the ease of mathematical exposition, frequently used symbols are summarized in Table I.

III. SYSTEM MODEL
We consider large-scale IoT/CPS network with ad hoc topology. In particular, the IoT/CPS devices are assumed to be scattered in R 2 according to a homogeneous Poisson point process (PPP) Φ ≡ {x 0 , x 1 , · · · , x k , · · · } ⊂ R 2 with intensity λ r . We model the locations of the IoT devices as a PPP with density λ r . Note that the PPP is commonly utilized and widely accepted in the literature to model wireless networks due to its tractability and practical significance [10], [34]- [38]. The IoT/CPS devices can establish bidirectional device-to-device (D2D) links if they are within the wireless communication ranges of each other. It is assumed that all devices have the same wireless communication range of r r meters. All IoT/CPS devices are assumed to be too constrained to install and execute anti-malware programs. Hence, the D2D links can be used for legitimate code dissemination or exploited for malware infection propagation. We assume autonomous malware worms in which compromised devices are infection threats for all of their connected neighbors [12], [13]. Exploiting multihop D2D connectivity, the malware infection may diffuse to large population of devices and create an epidemic outbreak.
To secure such large-scale IoT/CPS network from malware epidemic outbreak, spatial firewalls are randomly deployed according to an independent PPP Ψ ≡ {a 0 , a 1 , · · · , a k , · · · } ⊂ R 2 with intensity λ f . Firewalls are computationally capable devices (e.g., edge computing device, access point, high-end IoT/CPS devices) that are equipped with the state-of-the-art anti-malware programs [39]- [41]. Each firewall is assumed to have a communication range of r f meters, and hence, each firewall creates a secured zone of radius r f around itself. Due to the higher transmit power and better signal capture capabilities of firewalls, it is assumed that the firewalls have larger communication and detection ranges than the IoT/CPS devices (i.e., r f ≥ r r ). IoT/CPS devices within secured zones inquire the firewall about software codes received from the wireless interface. The firewalls scan inquired codes for security threats. If the code is legitimate and free from malware threats, the firewalls approves it. Otherwise, the code is disapproved and reported to the security administration for further action. 2 Consequently, IoT/CPS devices within secured zones are protected from malware infection and do not participate in malware propagation. On the other hand, devices outside secured zones have no direct connectivity with firewalls, and hence, they opt to directly execute and relay the codes received from the wireless interface. Hence, devices that are outside secured zones are susceptible to malware infection and may participate to malware propagation. In practice, we can expect that spatial firewalls are continuously updated, monitored and maintained with highly skilled personnel. Hence, in analysis, we assume that spatial firewalls are never compromised with attackers and can ensure almost 100% security. The operation of the spatial firewalls in large-scale IoT/CPS is depicted in Fig. 1. As shown in the figure, if the firewalls are dense enough, the collective impact of secured zones can thwart malware outbreak by spatially quarantining malware infections within finite region. The firewalls can then report to the security administration about detected malware for localized  patching and treatment of compromised devices. As shown in Fig. 1, the IoT/CPS network is composed from three types of devices: • Spatial firewalls are capable devices, equipped with the state-of-the-art anti-malware programs, that are spatially distributed across the network. • Protected devices are IoT/CPS devices that fall within the secured zone of a firewall, and hence, can not be infected with malware and do not participate in malware propagation. • Susceptible devices are IoT/CPS devices that fall outside the secured zone of a firewall, and hence, can be compromised and may participate in malware propagation.

A. Mapping to Graph and Percolation Theory
To study and characterize malware propagation in IoT/CPS networks and assess the impact of spatial firewalls, we utilize graph and percolation theory. In particular, the IoT/CPS network is mapped to a RGG, denoted as G = {Φ, E}, where the devices Φ are mapped to the graph vertices. Accounting for the limited wireless D2D communications range of r r , the set of edges E is defined as where · denotes the Euclidean norm and x i x j is the edge connecting x i and x j . The edges defined in (1) represent bidirectional direct (i.e., one hop) D2D connectivity between devices. The bidirectional links in E can be used for legitimate traffic dissemination or malware propagation. An infection from a device in G can reach its direct D2D neighbor devices in one hop. Furthermore, an infection from a device in G can also reach non-neighbor distant devices through multihop connectivity if there exists a route in E that connects the compromised device to the distant device. However, due to the random devices locations and limited wireless D2D range, a compromised device does not imply an infection threat to all other devices in G. This is because there might not be a multi-hop route in E that connects the compromised device to all other devices in G. The mutual infection threat between devices in G is specified through the connected components, which are defined as: with the largest possible devices such that, within K, any device x i ∈ K can always find a multi-hop route through a set of consecutive edges in E to any other device x j ∈ K, i = j. Consequently, a malware infiltration to any device x i ∈ K represents an infection threat for all devices x j ∈ K for i = j.
Based on Definition 1 and the ability of malware infection to exploit multi-hop connectivity, a compromised device is an infection threat to all devices within its own connected component. Hence, the infection threat is directly proportional to the size of connected components. Small values of λ r and/or r r lead to sparse vertices in Φ, and hence, the graph G will be consisting from several disjoint small connected components. In such case, there is no risk of an epidemic outbreak due to the lack of multi-hop wireless connectivity that connects large population of devices. Increasing λ r and/or r r , the connected components start to merge together into larger components and an infection becomes threatening to a larger number of devices. Sufficiently high λ r and/or r r create a giant component that connects infinite number of devices [42], [43]. The existence of a giant component implies the risk of an epidemic outbreak that gets out of control and compromise large-population of IoT/CPS devices. Characterizing the network parameters that lead to the existence/absence of the giant component is the core focus of percolation theory. Formally, the percolation probability on the graph G, as a function of λ r and/or r r , is defined as Definition 2 (Percolation Probability). Percolation probability defines the probability of existence of infinitely large connected component K ⊆ G, defined as θ G (λ r , r r ) = P{|K| = ∞}, (2) where | · | denotes the set cardinality. A non-zero percolation probability θ G (λ r , r r ) > 0 defines the super-critical regime in which the network percolates and a giant component exists. On the other hand, a zero percolation probability θ G (λ r , r r ) = 0 defines the sub-critical regime with no percolation and no giant components.
In the context of the malware infection in IoT/CPS network, the super-critical regime implies the risk of having a large connected population of devices that are vulnerable to an epidemic outbreak if a single device is compromised. The relative values of λ r and r r that lead to super-critical regime operation and raise the risk of malware epidemic in the depicted IoT/CPS network is defined in the following proposition. Lemma 1. The IoT/CPS network operates in the super-critical regime θ G (λ r , r r ) > 0, and hence, is susceptible to malware epidemic if and only if where λ c (1) ≈ 1.44. Proof: The proof is similar to [44, Chapter 2] which characterizes continuum percolation on PPP networks with homogeneous communication ranges.
If (3) is not satisfied, the IoT/CPS network is physically immune to malware epidemics. That is because if the defence mechanism of an IoT device is beaten by the attacker, the largest infected region will still be finite. Remark 1. λ c (1) defined in Lemma 1 is the critical (i.e., minimum) intensity of nodes required for continuum percolation in homogeneous PPP network with a normalized communication range 1. There is no known exact value for λ c (1) in the literature. However, there exists some useful approximations in literature such as λ c (1) ≈ 1.44 [45]. There are also analytically derived lower and upper bounds: 0.768 < λ c (1) < 3.37 [44], [46].
If the condition defined in (3) of Lemma 1 is not satisfied, then the IoT/CPS network is physically immune to malware epidemics due to the lack of multi-hop D2D connectivity that can be exploited to transfer malware infection to largepopulation of devices. Otherwise, the IoT/CPS network is at risk of malware epidemic and the spatial firewalls countermeasure is required. Note that in dense IoT/CPS networks, the condition in (3) is usually satisfied.
As discussed earlier, the spatial firewalls introduce spatial secured zones that protect some IoT/CPS devices and thwart malware propagation. 3 To incorporate the impact of spatial firewalls to the mathematical framework, the vertices Φ in the RGG G are further divided into susceptible devices Ξ ⊆ Φ and protected devices Θ ⊆ Φ such that Ξ ∪ Θ = Φ and Ξ ∩ Θ = ∅.
where min aj ∈Ψ x i − a j is the minimum distance between x i and all firewalls in Ψ. Hence, Θ contains all the devices that are located within the secured zones of the firewalls, i.e., the devices that can neither be infected nor participate in malware propagation. On the other hand, the susceptible set Ξ = {x i ∈ Φ : min aj ∈Ψ x i − a j > r f } contains the devices that are located outside the secured zones of all firewalls. A pictorial illustration for a realization of G = (Φ, E) before and after deploying spatial firewalls is shown in Fig. 2.
To characterize the impact of spatial firewalls, we define the infection susceptible graph (ISG) I = {Ξ, E}, with all susceptible devices in Ξ and set of edges E, which contains all the D2D links that can be exploited for malware infection propagation. The set E is defined as The ISG is illustrated in Fig. 2b, which highlights all susceptible deceives and their D2D connectivity. It is worth noting that an infection cannot propagate from a device in Ξ to a device in Θ, or vice versa, due to the firewall protection for all devices in Θ. Hence, the definition in (4) for the edges in E is restricted to the susceptible devices in Ξ.
It is clear that the ISG is a subset of the IoT/CPS network graph I ⊆ G. At the absence of spatial firewalls (i.e., λ f = 0), all the devices are susceptible to infection, and hence, the ISG coincides with the IoT/CPS network graph I = G(Φ, E). Deploying spatial firewalls splits the set Φ into protected Θ and susceptible Ξ devices. The ISG I can be constructed by removing the vertices in Θ and their associated edges from G(Φ, E). Given that G operates in the super-critical regime, the objective is to deploy sufficiently dense spatial firewalls (i.e., λ f ) such that the ISG I ⊆ G operates in the subcritical regime. Note that the sub-critical regime operation of I ⊆ G implies that the risk of malware epidemic is eliminated. Consequently, the IoT/CPS network is safeguarded from malware epidemics regardless of the malware infection rate. Let K I ⊆ I be the largest connected component in the ISG I and let θ I (λ f , r f , λ r , r r ) = P{|K I | = ∞} be the percolation probability of the ISG I. Then, the design objective of the spatial firewalls is formally defined as To minimize the monetary cost (e.g., deployment and/or anti-malware licensing) of spatial firewalls, it is desirable to find the minimum intensity of firewalls that safeguards the IoT/CPS network against malware epidemics. In the notion of percolation theory, the optimal λ * f is denoted as the critical density for percolation.

IV. PROOF OF CONCEPT
This section proves the concept of spatial firewalls by showing that there exists a phase transition for the percolation probability of the ISG. In particular, there is a critical intensity of spatial firewall λ c f below which the ISG operates in the super-critical regime. Hence, if the firewalls are not dense enough, the percolation probability is non-zero and the risk of malware epidemic exists. If the intensity of firewalls is above the critical intensity λ c f , the ISG operates in the subcritical regime, which eliminates the risk of malware epidemic by enforcing a zero percolation probability. To complete the proof of concept, we show that the percolation probability is monotonically decreasing in λ f , which proves the phase transition at a critical intensity λ c f . Hence, the critical intensity λ c f is the optimal density that minimizes (5).
For the sake of organized presentation, Section IV-A presents the sub-critical regime operation for the ISG, which proves the effectiveness of the spatial firewalls. Then, Section IV-B presents the super-critical regime operation for the ISG, which proves the need for dense enough spatial firewalls. Last but not least, Section IV-C completes the proof of concept by showing the monotonicity of the percolation probability in λ f .

A. Sub-critical regime
This section proves that sufficiently dense firewalls enforce a sub-critical regime operation for the ISG, which safeguards the IoT/CPS networks against malware epidemics. To find sufficient conditions for spatial firewalls intensity that enforces sub-critical regime operation for the ISG, a worst case scenario of r f = r r is assumed. Such sufficient firewalls intensity would also enforce sub-critical regime for the general case of r f ≥ r r . For tractable analysis, the common practice in percolation theory is to study continuum percolation in RGG by mapping them to discrete lattices. Inspired by [32], we prove the sub-critical regime operation by mapping the ISG to hexagonal lattice as defined in the sequel. Mapping to a Hexagonal Lattice: Let L h be a hexagonal lattice with a side equal to the D2D communication range r r , which is also equal to the secured zone radius is (i.e., r f = r r ). Let H denote a randomly selected hexagon, also denoted as a face, in L h . Depending on the firewalls occupancy, a face H can be either open or closed, as explained next. In particular, open face percolation is obstructed by closed faces. In our setup, a closed face defines a protected geographical region (i.e., by secured zones of firewalls) that cannot be crossed by a malware infection. More precisely, due to the union of the secured zones of the firewalls within the triangles {T i } 3 i=1 , an infected device within the vicinity of a closed face will not have any susceptible device within its D2D reach through the closed face. Articulated differently, there could not be susceptible edges in E of the ISG that passes through a closed face in L h . A sequence of connected closed faces form a closed path, which further extends the firewalls spatial protection to larger connected (i.e, no gaps for malware propagation) geographical region. A path that starts and ends at the same face is denoted as a closed circuit. A closed circuit on L h implies no open face percolation on L h , which also implies finite connected component in I = (Ξ, E). Hence, closed circuit on L h means spatially quarantined (i.e., surrounded) malware. A pictorial illustrations of a closed face and a closed circuit are shown in Fig. 3b.
As illustrated above, malware infection is obstructed by closed faces. Hence, an infection that originated within a closed circuit is spatially quarantined within the connected component of the infected device. Due to the stationarity of the PPP, there is no loss of generality to assume that the infection originates at the device located at the origin. Hence, it is sufficient to prove that the origin is surrounded by a closed circuit to prove that the ISG operates in the sub-critical regime. The coupling between the hexagonal lattice L h and the ISG I is formally stated and proved in the following lemma.
Lemma 2 (Hexagonal lattice coupling). Let K I (0) ⊆ I(Ξ, E) and K L h (0) ⊆ L h denote connected components around the origin in, respectively, the ISG I and the hexagonal lattice Proof: A closed circuit around the origin implies a finite number of open faces on the inner side of the circuit. Consequently, |K L h (0)| < ∞ and the region covered by K L h (0) involves a finite number of vertices of I(Ξ, E). Hence, to prove that K I (0) is finite, it is sufficient to prove that no edge of I(Ξ, E) crosses C(0). Let us consider an extreme scenario for the closed face with the worst spatial setup for the three firewalls and IoT/CPS devices, shown in Fig.3a. In particular, assume each of the triangles {T i } 3 i=1 has only one firewall in the shown worst case locations such that their secured zones provides minimum protection (i.e., coverage) of the closed face. Furthermore, let us consider the most advantageous location for the IoT/CPS devices for malware infection propagation as shown Fig.3a. Recall that the side of each equilateral triangle is r r , then we have one of the following two scenarios. 1) If the two devices are within the D2D communication range of each other, then one of them should be in Θ (i.e., within the secured zone of one or more of the three spatial firewalls). 2) If both devices are in Ξ (i.e., both of them are out of the range of the three firewalls), then they are out of the D2D communication range of each other (i.e., the condition in (4) is not satisfied). The example shown in Fig.3a shows that even in the worst case spatial setup of firewalls, an infection cannot bypass the closed face. Therefore, no edge in E can cross C(0), and hence we conclude that a finite |K L h (0)| leads to a finite |K I (0)|.
Exploiting the mapping to the hexagonal lattice and the coupling introduced in Lemma 2, we can state the main result of this section in the following proposition Proposition 1 (Sufficient condition for zero percolation on ISG). For given λ r > 0 and r r > 0, the ISG operates in the sub-critical regime (i.e., θ I (λ f , r f , λ r , r r ) = 0) if Proof: Referring to the results in Lemma 2, a closed circuit C(0) on the hexagonal lattice L h implies sub-critical regime operation of the ISG I. Based on the results in [47], the origin is almost surely (a.s.) surrounded with closed circuit From the PPP properties of the spatial firewalls we have Substituting (8) back in (7), we conclude that the origin is a.s surrounded with closed circuit Rearranging the terms of (9) and following to the statement of Lemma 2 we conclude that there is a closed circuit Hence, λ f > 3.65/r 2 r is the condition that guarantees that the ISG I(Ξ, E) does not percolate, which concludes the proof of Proposition 1.
Before switching the discussion to the super-critical regime operation of the ISG, it is worth stating the following two important remarks.

Remark 2.
It is important to note that the condition in (6) that enforces sub-critical regime operation of the ISG is independent of the IoT/CPS devices intensity λ r . This is because the proof of Proposition 1 is based on the collective ability of the secured zones to spatially quarantine malware infection within finite region. That is, the condition in (6) implies that the spatial firewalls are dense enough to construct continuous secured zones that surround any malware infection to safeguard the IoT/CPS from malware epidemic regardless of the IoT/CPS devices intensity.
Remark 3. The proof of Proposition 1 is based on the assumption that r r = r f . The case of r f > r r also satisfies Definition 3 for the closed face. In fact, increasing r f expands the secured zone of H. Hence, the expression for λ f that satisfies (7) is also sufficient for no percolation when r f ≥ r r . Therefore, the proof of Proposition 1 is also valid for the case of r f ≥ r r .

B. Super-critical regime
This section shows that insufficient deployment of spatial firewalls leads to a super-critical regime operation for the ISG, which implies that the IoT/CPS network is at a risk of malware epidemics. For a tractable analysis for the super-critical regime operation, we map the ISG to a square lattice as defined in the sequel.
Mapping to a Square Lattice: Let L s be a square lattice with side s = rr    Fig 4. The rectangular lattice mapping is chosen to define a geographical region that contains a connected component of susceptible devices in the ISG I = {Ξ, E}. Since A(e) is free from firewalls, then the region covered by S 1 (e) ∪ S 2 (e) is located outside the secured zones of all firewalls. Furthermore, since each of S 1 (e) and S 2 (e) has at least one IoT/CPS device, then the region S 1 (e) ∪ S 2 (e) contains some vertices of Ξ. Lastly, since the largest distance (i.e., the diagonal) within the region S 1 (e) ∪ S 2 (e) equals to r r , all devices that are located within S 1 (e) ∪ S 2 (e) are within the D2D range of each other. Hence, the region defined by S 1 (e) ∪ S 2 (e) contains devices in Ξ that are all connected to each other with edges in E.   By virtue of Lemma 3, it is sufficient to characterize percolation in L d s to prove the super-critical regime of the ISG I(Ξ, E). However, before delving into the analysis, it is important to note the dependency between proximate edges, as stated in the following remark.

Remark 4 (Edge dependencies).
Since an open edge e ensures that firewalls are absent from the region A(e), then the status of proximate edges are correlated. The status of two edges are independent if they do not share a common spatial region that requires the absence of spatial firewalls. Hence, the smallest distance that ensures independent edges is 2s r f s horizontally and 2s r f s + 2s vertically. Now we are in position to study the super-critical regime of the ISG, which is characterized in the following proposition.
Proposition 2 (Sufficient condition for non-zero percolation on ISG). For given r r > 0 and λ r > 0, the ISG operates in the super-critical regime (i.e., θ I (λ f , r f , λ r , r r ) > 0) if where β = ( 11−2 √ 10 27 To prove the proposition, we characterize the conditions which ensure that the probability of no percolation is strictly less than one. Hence, the probability of the complement event (i.e., percolation) is strictly greater than zero. As mentioned in Lemma 3, a finite K L d s (0) implies no percolation on L d s , which in turns implies sub-critical regime of the ISG. In the following, we find the conditions that ensures that P{|K L d s (0)| < ∞} < 1. Hence, such conditions also implies non-zero probability of the complement event Hence, the ISG has non-zero probability to operate in the supercritical regime.
Let P Ls (n) denote a path of length n edges {e i } n i=1 ∈ L s . From the coupling between the dual and primal square lattices, it can be inferred that K L d s (0) is finite iff there is a closed circuit path in L s around the origin. To account for the edge dependencies within the path P Ls (n), we recall from Definition 4 that the edges e i and e j are independent if (A(e i ) ∩ A(e j )) = ∅. Let N denote the number of edges in A 0 (e) and let S I ⊆ P Ls (n) denote the subset of all independent edges in P Ls (n). Then, the set S I has a cardinality of at least n/N . The construction of A 0 (e) and the computation of N are illustrated in Appendix A.
It is shown in [48] that there are 4n3 n−2 possible ways to construct a circuit of length n around the origin. Therefore, the probability that a closed path exists around the origin is expressed as where q ≡ P{e is closed} and the last equality in (11) is obtained by treating the sum as a derivative of geometric series with respect to q 1/N . To ensure that P c is strictly less than 1, the following condition must be satisfied Based on Definition 4, an explicit expression for q can be found as follows where N A is the number of squares covered by A(e). From Fig. 4, The condition in (12) ensures that P{|K L d s (0)| < ∞} < 1, which implies non-zero probability of percolation. Hence, substituting (13) into (12) and after some basic algebraic manipulations, we can finally get the result in (10).
Remark 5. Proposition 2 shows that the super-critical regime operation, which raises the risk of malware epidemic requires both i) sufficiently dense IoT devices and ii) sufficiently sparse firewall deployment. More precisely, (10) shows an inverse relationship between λ r and λ f to allow long-range malware propagation. Hence, it may be apparent that higher intensity of IoT/CPS devices requires higher intensity of firewalls to spatially quarantine malware infections. However, this is only true up to the threshold shown in Proposition 1. This is because the intensity shown in Proposition 1 implies that the firewalls are dense enough such that the union of their secured zones form continuous circles in the spatial domain that surrounds and thwarts any emerging malware infection. Hence, the intensity of spatial firewalls shown in Proposition 1 safeguards the IoT/CPS network from malware epidemics irrespective of the IoT/CPS devices intensity.

C. Phase transition
This section shows that the percolation probability of the ISG exhibits a phase transition property in the intensity of firewalls λ f . Hence, the percolation critical intensity of firewalls is the unique intensity that minimizes (5). Such phase transition behavior is formally stated in the following theorem.
Theorem 1 (Phase transition). Let θ I (λ f , r f , λ r , r r ) denote the percolation probability of the ISG I(Ξ, E), then ∀λ r > 0 there exists a critical value λ c f < ∞ for the density of firewalls such that Proof: We start the proof by showing that the percolation probability θ I (λ f , r f , λ r , r r ) is non-increasing function in λ f . Consider two sets of firewalls Ψ 1 and Ψ 2 with intensities λ f1 < λ f2 , respectively. Owing to the fact that both Ψ 1 and Ψ 2 are PPPs and that λ f1 < λ f2 , then Ψ 1 can be constructed by thinning Ψ 2 with probability Chapter 2]. As thinning implies random removal of nodes, then |Ψ 1 ∩A| ≤ |Ψ 2 ∩A| for any A ∈ R 2 . For the set of IoT devices Φ, the set of protected devices is defined as Now consider two ISGs I 1 = (Ξ 1 , E 1 ) and I 2 = (Ξ 2 , E 2 ) constructed with the same parameters λ r , r r and r f but with the different sets of firewalls Ψ 1 and Ψ 2 . Since Ξ i = Φ \ Θ i for i ∈ {1, 2}, then |Ξ 1 ∩ A| ≥ |Ξ 2 ∩ A| for any A ∈ R 2 . So, it is valid to state that K I1 (0) ⊇ K I2 (0). Therefore, the condition 0 < λ f1 < λ f2 implies that θ I (λ f1 , r f , λ r , r r ) ≥ θ I (λ f2 , r f , λ r , r r ), and hence, θ I (λ f ) is a non-increasing function of λ f .
Recall that θ I (λ f1 , r f , λ r , r r ) > 0 for λ f < λ L as shown in Proposition 2. Also, θ I (λ f1 , r f , λ r , r r ) = 0 for λ f > λ U as shown in Proposition 1. Since θ I (λ f1 , r f , λ r , r r ) is nonincreasing in λ f , there should be a critical value λ c f that exhibit the phase transition indicated in (14) and depicted in Fig.5.

V. SECURED IOT/CPS NETWORK DESIGN
Section IV proves the concept of spatial firewalls. In particular, Theorem 1 shows that the phase transition critical intensity λ c f is the minimum intensity of firewalls that safeguards the IoT/CPS from malware epidemics. Hence, λ c f implies minimum deployment and licensing cost for spatial firewalls. However, as in the majority of continuum percolation models, there is no exact expression for λ c f . Hence, approximations and bounds are always sought. Proposition 1 shows sufficient conditions for the firewalls intensity to safeguards IoT/CPS networks from malware epidemic. However, the sufficient condition of Proposition 1 can be regarded as a loose upperbound on λ c f as it assumes a worst case scenario of r f = r f . Furthermore, Proposition 1 restricts the vulnerable and secured regions to hexagonal shapes. Relaxing the assumptions of Proposition 1, the following theorem presents a tight upperbound for λ c f , which provides an economical design of spatial firewalls. In addition, Theorem 2 gives extra parameter for manipulation of λ c f upperbound. Theorem 2. Consider an IoT/CPS network with devices intensity λ r > 0 and D2D communications range r r > 0. To secure such IoT/CPS network, spatial firewalls with communication/detection range of r f ≥ r r are deployed. Then, the critical intensity of firewalls that safeguards such IoT/CPS network from malware epidemics is bounded by where λ c (1) is given in Remark 1.
Proof: The construction of the ISG graph is based on the interaction between the IoT/CPS devices in Φ and the firewalls in Ψ. Particularly, the devices in the ISG Ξ = Φ \ Θ are the IoT/CPS devices in Φ that exists outside the secured zones of the firewalls in Ψ. Hence, Ξ and Ψ can be treated as an overlay of two non-intersecting networks: a network of firewalls and a network of susceptible devices. Let us define the vacant space V = {x ∈ R 2 : min x − Ψ > r f } as all spatial regions in R 2 that are not covered by the secured zones of the firewalls in Ψ. By virtue of the exclusive relation between I = {Ξ, E} and Ψ, an infinite connected component in I necessitates an infinite vacant component within V. Hence, to prove Theorem 2, we analyze the condition for the existence of an infinite vacant component (i.e., infinite continuous space) in V. Let us consider the worst-case arrangement shown in Fig. 6. The figure shows two IoT/CPS devices that are exactly r f away from the nearest firewall and r r away from each other. Such setup depicts the minimum vacant space W that allows for malware propagation between two IoT/CPS devices in Φ, where r o is the minimum distance from any firewall in Ψ and W . Therefore, the minimum requirement for the existence of an infinite path in I corresponds to the case of having an infinite vacant component in the Poisson Boolean model [42] with the intensity λ f and radius r o ≡ r 2 f − r 2 r 4 − 2 2 . Following [28] it can be shown that the critical intensity for coverage percolation of a Boolean model with secured zones of radius r is Substituting the value for r o in (16), we conclude that there is no infinite vacant component in V if Hence, the firewall intensity in (17) prohibits percolation in I. Owing to the fact that the critical intensity is the minimum intensity of firewalls that prohibit percolation in I and taking the limit 2 −→ 0, we finally get the upper-bound in (15).
The results in Theorem 2 shows that any firewall intensity equal to or above the threshold shown in (15) is ensured to safeguard the IoT/CPS networks from malware epidemics. Different from Theorem 1, the threshold shown in (15) accounts for the larger communication/detection range of firewalls when compared to the IoT/CPS devices. Capitalizing on Theorem 2, it is possible to prohibit malware epidemics through the design of the communication range of the IoT/CPS devices as an alternative to deploying more spatial firewalls. However, it should be noted that the communication range of the IoT/CPS devices should ensure global network connectivity. The D2D communication range that ensures both global network connectivity and prohibits malware epidemics is stated in the ε 2 Fig. 6: Worst case scenario for existence of infinite path.
Corollary 1. For a given λ f , r f , and λ r , a safeguarded wide range connectivity for the IoT/CPS network can be ensured if the D2D range satisfies the following condition Proof: The corollary can be directly proved from Theorem 2 and IoT/CPS connectivity condition in (3).
The conditions in (18) ensures that the D2D communication range is sufficient for legitimate information dissemination within G = {Φ, E} but not for a malware epidemic outbreak on I(Ξ, E). Hence, Theorem 2 and Corollary 1 allow alternative techniques for safeguarding IoT/CPS networks, namely, through the firewalls intensity λ f , the firewalls communication/detection range r f , or the IoT/CPS D2D range r r . Note that the ranges r f and r r can be controlled through the transmit powers and receivers sensitivities.
The results in Theorem 2 and Corollary 1 safeguard the IoT/CPS networks from malware epidemics. However, Theorem 2 and Corollary 1 do not give insights about the percentages of susceptible and secured IoT devices. Hence, an alternative design objective is to ensure that a required percentage, denoted as δ sec , of the devices are secured as shown in the following corollary Corollary 2. The percentage of IoT/CPS devices that are protected from malware infiltration/infection is given by Proof: By definition, a device is protected from malware infection if it falls within the secured zones of firewalls. Hence, the corollary can be directly proved from void probability of the PPP.
Combining the results of Theorem 2 and Corollary 2, it can be shown that using the critical intensity of firewalls in (15) corresponds to securing the following critical percentage of IoT/CPS devices Owing to the fact that r f ≥ r r and using λ c (1) ≈ 1.44, it can be shown that δ c sec is a decreasing function in r f which is bounded within the following range 0.67 ≤ δ c sec ≤ 0.78, where the upper limit corresponds to r f = r r and the lower limit corresponds to the r f r r . Note that δ sec approaches the lower limit rapidly with increasing r f , which appears within a quadratic term inside the exponential function.
Remark 6. The results in Theorem 2 and (21) show that lower values of r f necessitate higher intensity of firewalls to safeguard the IoT/CPS network. That is, lower values of r f requires protecting at most 10% more IoT/CPS devices to safeguard the IoT/CPS network from malware epidemics.
The results in (20) and (21) also show the percentage of devices that are required to be secured by spatial firewalls to safeguard the IoT/CPS networks from malware epidemics.

VI. NUMERICAL AND SIMULATION RESULTS
The simulation of the IoT/CPS network is implemented in Matlab. In each simulation run, two independent PPPs with intensities λ f device/m 2 for firewalls and λ r device/m 2 for IoT/CPS devices are scattered over a square region of size 100 × 100 m 2 . The set of protected devices Θ and the set of susceptible devices Ξ are first identified based on the distances between the IoT/CPS devices and firewalls. The ISG I(Ξ, E) is then constructed based on the D2D communication range among the susceptible devices in Ξ. Percolation is declared on I(Ξ, E) if it contains a connected component that spans the simulation region from left to right and from bottom to top. Percolation probability is then calculated by averaging over several realizations of the Monte-Carlo simulations. The unit of λ r , λ f , and λ c f in all the figures is device per square meter. Fig.7 shows the percolation probability versus the intensity of firewalls for r r = 2 m and λ r = 0.8 device/m 2 . Recall that the critical density, λ c f appears at the point where percolation probability drops to 0 for the first time. The figure shows a phase transition in the percolation probability, which verifies Theorem 1. The figure also highlights the positive impact of firewall communication/detection range r f . Increasing r f reduces the critical intensity that is required to safeguard the IoT/CPS network from malware epidemics. Fig. 8 plots the critical intensity of firewalls λ c f (obtained via simulations) versus the intensity of IoT/CPS devices. The figure also depicts the upper-bounds in Theorem 2 for different values of λ c (1). The figure clearly shows the three regions of operation for the IoT/CPS network. The first region is characterized by small values of λ r such that the network lacks long range multi-hop wireless connectivity, and hence, is physically immune to malware epidemics. The second region is when the intensity of IoT/CPS is sufficiently high for global network connectivity while the intensity of firewalls is not sufficient (i.e., λ f < λ c f ), and hence, the network is at risk of malware epidemics. The last region is where sufficiently dense spatial firewalls are deployed (i.e., λ f ≥ λ c f ), and hence, the network is safeguarded from malware epidemics. Fig. 8 also shows that as the intensity of IoT/CPS devices increase, denser firewalls deployment is required to prohibit malware epidemics. However, the required intensity for firewalls saturates at the upper-bound indicated in Theorem 2, which validates our analysis. That is, the figure confirms that there exists a finite intensity of firewalls λ f that safeguards the IoT/CPS network from malware epidemics regardless of the intensity of IoT/CPS devices. It is worth noting that the upperbound in (15) depends on the approximate value of λ c (1).
Hence, the figure also shows (15) when using the upper-bound on λ c (1) provided in Remark 1, which provides a safety margin against malware epidemics. Note that operating with such safety margin increases the critical percentage of protected devices from the range shown in (21) to 0.92 ≤ δ c sec ≤ 0.97 depending on the relative value of r f compared to r r . Fig. 9 shows the percentage of susceptible devices, i.e., (1 − δ sec ), for different values of λ f and r f /r r . On the same figure, we also highlight the critical percentage 1 − δ c sec , i.e., the complement of (20), which shows the percentage of susceptible devices when operating at the critical intensity λ c f derived in Theorem 2. First, the figure illustrates the range of δ c sec presented in (21) and shows the fast convergence of δ c sec to the upper limit 0.78. The figure also depicts the high impact of r f on the network design and performance. For instance, at λ f = 0.1 device/m 2 increasing r f to twice r r leads to more than 10-fold decrease in the percentage of susceptible devices. Furthermore, doubling r f also leads to around 4 times reduction in the critical intensity of firewalls required to safeguard the IoT/CPS devices. The figure also shows the costs, in terms of λ f and r f , that are required to protect more devices beyond the required critical percentage δ c sec .
VII. SUMMARY AND CONCLUSIONS The Internet-of-things (IoT) is intrinsically vulnerable to large-scale malware attacks, where malware infiltrated to one device represents an infection threat to a large population of devices. To safeguard the IoT from malware epidemics, spatial firewalls are randomly deployed in the network to detect and thwart emerging malware infections. Each firewall imposes a secured zone, determined by its wireless connectivity, that protects its proximate devices form malware infection. Mapping the network to a random geometric graph and using tools from percolation theory, we develop a novel mathematical framework to assess and design spatial firewalls.
In particular, we define the infection susceptible graph (ISG) to assess the risk of a malware outbreak (i.e., epidemic). We prove that the connectivity of the ISG exhibits a phase transition, where there exists a critical intensity of firewalls that prohibit the formation of a giant-connected component within the ISG. From the security perspective, the absence of a giant-connected component within the ISG eliminates the risk of long-range propagation of malware infection, and hence, safeguards the IoT from malware epidemics.
To this end, we present flexible design paradigm for the firewalls to safeguard the IoT. For instance, we find tight upper-bound for the critical intensity of spatial firewalls required to safeguard the IoT from malware epidemics. We also characterize the relative communications ranges of the firewalls and the IoT devices that allow secure global network connectivity. In addition, we specify the percentage of secured devices that corresponds to the critical intensity of spatial firewalls. The results show that the required density of spatial firewalls significantly decreases as we increase the relative communication range of the spatial firewalls when compared to the IoT devices. It is also shown that securing 67% to 78% of the IoT devices via firewalls is sufficient to safeguard the IoT network from malware epidemics, where the required percentage of secured IoT devices decreases as the communication range of the spatial firewalls increases.

A. Maximum number of dependent edges
This appendix illustrates how to find general expression for the maximum number of edges N that are dependent of some arbitrary edge e. We assume that all edges in the lattice have dependency region A(·) of general size a × b squares. According to the definition of dependency region, any two edges e i , e j are considered independent iff (A(e i ) ∩ A(e j )) = ∅. Therefore, let {e n } Next, we should construct maximal rectangle around e such that created region A 0 (e) does not include {e i } 8 i=1 . Hence, we can be sure that A 0 (e) covers maximal number of edges that are dependent of e. For illustrative purposes, a toy example of edge dependency problem is given in Fig. 10. By construction, the size of A 0 (e) is (2a − 2) × (2b − 1). Hence, the number of edges in A 0 (e) is N = (2a − 1)(2b − 1) + (2a − 2)2b = 8ab − 2a − 6b + 1. (22) For the scenario in Proposition 2, the dimensions of A(e) are a = 2 √ 5r f r r + 2 and b = 2 √ 5r f r r + 1.
Substituting these values in (22) leads to the final result of N .