Patent Publication Number: US-2023133791-A1

Title: Provenance Inference for Advanced CMS-Targeting Attacks

Description:
CROSS-REFERENCE TO RELATED APPLICATION(S) 
     This application claims the benefit of PCT Patent Application Serial No. PCT/US21/20894, filed Mar. 04, 2021, which claims the benefit of U.S. Provisional Pat. Application Serial No. 62/985,067, filed Mar. 04, 2020, the entirety of each of which is hereby incorporated herein by reference. 
    
    
     STATEMENT OF GOVERNMENT SUPPORT 
     This invention was made with government support under grant number 1755721, awarded by the National Science Foundation. The government has certain rights in the invention. 
    
    
     BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to digital security systems and, more specifically, to a system for detecting attacks that target CMS systems. 
     2. Description of the Related Art 
     Over 55% of the world’s websites run on content management systems (CMS), with WordPress controlling nearly 60% of the CMS market. Unfortunately, this widespread adoption has led to a swift increase in CMS-targeting cyber-attacks. These attacks are made even easier, because CMS deployments tend to be an amalgam of layered software and interpreters, all with varying degrees of network and system permission, which execute on the internet-facing web server. Also, common compromises of CMS deployments tend to exhibit what are referred to as “low and slow” characteristics indicative of multi-stage attacks. 
     Despite the significant deployment of these complex software systems few systems effectively remediate CMS-targeting cyber-attacks. Existing systems use fine-grained logging to try to understand the provenance of an attack. Unfortunately, in the CMS domain, these techniques tend not to be widely used in practice. This is because fine-grained logging solutions still incur notable performance/space overhead and often require instrumenting and training with the target systems. Moreover, website owners often have no control over the underlying web server because the entire platform is usually owned and maintained by a hosting provider. 
     For these reasons, the main approach for dealing with compromised CMS deployments employs a “backup and restore” model of security, which are offered by popular platforms (e.g., Dropmysite, Codeguard, GoDaddy, Sucuri, and iPage). These systems stores nightly backups of each website’s files that are maintained offsite. They also employ anti-virus (AV) scanners to detect compromises in websites. When a compromised data is detected by an AV scanner in a website, these systems restore the last-know non-compromised copy of the website. (Backed up copies of websites are often referred to as “snapshots” of the website.) 
     Unfortunately, the signatures used by AV scanners catch only well-known malware and they frequently fail to detect stealthy multi-stage attacks. Also, high false alarm rates often result in real alerts being ignored. Moreover, website owners often erroneously revert to the most recent snapshot which did not trigger an AV alert, but the snapshot used to restore the website may actually include stealthy malware code that the AV scanner failed to detect. Also, it has been found that website owners rollback to an earlier snapshot for only about 31% of true alerts and only one-third of those rollback to an actually pre-initial-infection state. 
     Recently, Applicants have discovered that the evolution of a typical CMS attack tends to exhibit clear multi-stage attack patterns: (1) slowly establishing an initial foothold; (2) quietly maintaining persistence; (3) lateral movement; and (2) cleaning up traces of earlier phases. Because these patterns tend to evolve over time, it can be difficult to detect an attack by analyzing a single snapshot. Generally, it has been found that attacks persist in CMS websites for a minimum of 6 days and a maximum of 1694 days, with a median of 40 to 100 days. One study indicated that more than 20% of WordPress websites observed in one study housed attacks for over a year. These attacks typically involved stealthily dropping a huge volume of malicious code affecting the web server. 
     Therefore, there is a need for a system that detects a likelihood that that website has been attacked by analyzing states of the website over time. 
     SUMMARY OF THE INVENTION 
     The disadvantages of the prior art are overcome by the present invention which, in one aspect, is a method for detecting an attack compromise window in a CMS website for which a temporal sequence of a plurality of snapshots of website backups have been stored, in which a temporally ordered set of spatial elements from each snapshot is constructed. Spatial metrics are computed for each individual snapshot’s elements. The collected spatial metrics are temporally correlated and queried against attack models to recover an attack timeline. Attack events in the attack timeline are labelled. A sequence of assigned attack labels is verified. The compromise window is extracted from the plurality of snapshots. 
     In another aspect, the invention is a method for detecting an attack compromise window in a CMS website for which a temporal sequence of a plurality of snapshots of website backups have been stored, in which the following steps are executed: 
     constructing a temporally ordered set of spatial elements from each snapshot by extracting files associated with each snapshot and mapping the files as spatial elements; computing spatial metrics for each individual snapshot’s elements by executing the steps of: extracting a structural metric from each snapshot’s elements; and extracting a code metric from each snapshot’s elements; temporally correlating the collected spatial metrics and querying them against attack models to recover an attack timeline and labelling attack events in the attack timeline by executing the steps of: querying each two consecutive temporal snapshots in a window at a time against a plurality of attack models; and assigning an attack label and a corresponding severity to each temporal snapshot, thereby building an incremental the attack timeline; verifying a sequence of assigned attack labels; and extracting the compromise window from the plurality of snapshots. 
     These and other aspects of the invention will become apparent from the following description of the preferred embodiments taken in conjunction with the following drawings. As would be obvious to one skilled in the art, many variations and modifications of the invention may be effected without departing from the spirit and scope of the novel concepts of the disclosure. 
    
    
     
       BRIEF DESCRIPTION OF THE FIGURES OF THE DRAWINGS 
         FIGS.  1 A- 1 C  are schematic diagrams showing three models of temporal infection evolution. 
         FIG.  2    is a schematic diagrams showing an overview of the steps employed in the system of the present invention. 
         FIG.  3    is a chart showing Outlier detection within the directive length distribution of all code elements in one snapshot. 
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     A preferred embodiment of the invention is now described in detail. Referring to the drawings, like numbers indicate like parts throughout the views. Unless otherwise specifically indicated in the disclosure that follows, the drawings are not necessarily drawn to scale. The present disclosure should in no way be limited to the exemplary implementations and techniques illustrated in the drawings and described below. As used in the description herein and throughout the claims, the following terms take the meanings explicitly associated herein, unless the context clearly dictates otherwise: the meaning of “a,” “an,” and “the” includes plural reference, the meaning of “in” includes “in” and “on.” 
     In one embodiment, the system is an automated provenance inference technique, which enables the investigation and remediation of CMS-targeting attacks based on only the nightly backups already being collected by website hosting companies. 
     The system of the present invention reconstructs a timeline of the attack phases and recovers the compromise window, or the period of time during which the snapshots should not be trusted. In inferring provenance patterns, applicant has discovered that a finite number of identical provenance patterns exist within the evolution of all the websites. Generally, a file in a given snapshot can exist in 1 of 3 states: added, modified, or deleted. As shown in  FIGS.  1 A- 1 C , three infection scenarios can be observed in the website backups. A file added (denoted by Ⓐ) can be flagged as suspicious (denoted by ⓛ) by an antivirus (AV) system at some point throughout its life cycle. These files could also be flagged as suspicious (by an AV) after they are modified (as denoted by Ⓜ). In some cases, a snapshot rollback is performed to treat the suspicious files by deleting (as denoted by Ⓓ) them. If the rollback deletes all of the attacker’s files then the attack is cured  110 , as shown in  FIG.  1 A . If the rollback adopts a snapshot that still includes the attacker’s files, as shown in  FIG.  1 B , the attack regenerates the malicious files  120 . In other cases, no action is taken despite detecting a suspicious file  130 , as shown in  FIG.  1 C . This indicates that the industry standard of “backup and restore” is entirely insufficient. In fact, it has been found that about 80% of these websites remain infected — even though many website owners had rolled back to a snapshot and patched the vulnerability. This probably because most website owners lack forensic expertise and are unable to identify a pre-infection snapshot (leaving initial backdoors in place and allowing the attack to recur). 
     In order to quickly rollback to a clean snapshot, administrators must recover the compromised window or the period of time during which the snapshots should not be trusted. This is further complicated by the fact that each snapshot contains tens of thousands of files (an average of 11,292 files were counted in one study), adding to the complexity of the recovery. One experimental study drilled down into the individual snapshots from a single Drupal website (referred to herein as “W6828862” to ensure anonymity) over the course of 17 different snapshots (see Table I, below), which will serve as a running example throughout this disclosure. 
     Single Snapshot Metrics: The complexity of each snapshot can be reduced to a set of measurements, called spatial metrics, that highlight the existence of cyber attack evidence. In addition to the state of each file in the snapshot from before (the first spatial metric), another spatial metric measures extension mismatches among the files, i.e. if a file’s internal format matches the filename’s extension. Similarly, another spatial metric identifies UTF-8 based code obfuscation patterns in server-side script files. For example, in the case of W682886, 3 PHP files had obfuscated payloads disguised as icon files in the 5 June snapshot which initiated the attack. The system of the present invention employs 9 spatial metrics, which will be discussed in more detail below. These spatial metrics were found to be effective at highlighting the presence of cyber attack artifacts within a single snapshot. 
     Temporal Evolution Of Attack Phases: The experimental embodiment collected spatial metrics to represent each snapshot of W682886, paying specific attention to sudden changes between pairs of consecutive snapshots. This revealed that modelling the implicit events which trigger these sudden changes can expose the attack phases. Plot the temporal progression of the spatial metrics across a range of snapshots can show trends that lead to the detection of a cyber attack. 
     For example, Table I shows one such progression for website W682886 considering only a single spatial metric, i.e., the file format numbers. The temporal evolution of this metric exposes the first attack signs. As seen in Table I, sudden changes in the file format metric stand out on 21 April, 5-8 June, and 13-14 June (the dates on which the metrics were measured). Identical spatial metric outliers in 3 other Drupal websites from 14 April to 21 May suggest the attack’s lateral movement. It has been found that web attacks tend to drop large volumes of files on a web server, which explains the sudden changes observed in file format metrics. These patterns also appear to evolve similarly over time — adding more functionality to the existing malicious code (e.g., one example started with only file read capabilities, and after 8 days evolved to modify files and communicate over an SSL gateway). Eventually, these attacks also tend to attempt cleaning up their footprints by deleting most of the attack files.  
     
       
         
          TABLE I
           
               
               
               
               
               
               
               
               
             
               
                 Temporal File Differential Analysis: 
               
               
                 Date 
                 Outlier 
                 PHP 
                 HTML 
                 ASCII 
                 XML 
                 PNG 
                 ZIP 
               
             
            
               
                 20 Apr 
                 - 
                 0 
                 0 
                 +1 
                 0 
                 0 
                 0 
               
               
                 21 Apr 
                 Ⓘ 
                 +7 
                 +1 
                 +3 
                 +21 
                 0 
                 0 
               
               
                 22 Apr 
                 - 
                 -2 
                 0 
                 +1 
                 0 
                 0 
                 0 
               
               
                 23 Apr 
                 - 
                 0 
                 +2 
                 +2 
                 0 
                 0 
                 0 
               
               
                 24 Apr 
                 - 
                 0 
                 0 
                 +1 
                 0 
                 0 
                 0 
               
               
                 25 Apr 
                 - 
                 +3 
                 -1 
                 +6 
                 0 
                 0 
                 0 
               
               
                 05 Jun 
                 Ⓘ 
                 -13 
                 +5 
                 +50 
                 0 
                 +9 
                 +1 
               
               
                 07 Jun 
                 Ⓘ 
                 -31 
                 0 
                 +1 
                 0 
                 0 
                 0 
               
               
                 08 Jun 
                 Ⓘ 
                 -18 
                 -6 
                 -22 
                 -20 
                 -9 
                 -1 
               
               
                 09 Jun 
                 - 
                 +5 
                 0 
                 0 
                 0 
                 0 
                 0 
               
               
                 10 Jun 
                 - 
                 0 
                 0 
                 +3 
                 0 
                 0 
                 0 
               
               
                 11 Jun 
                 - 
                 +5 
                 0 
                 +1 
                 0 
                 0 
                 0 
               
               
                 12 Jun 
                 - 
                 +3 
                 -7 
                 -4 
                 0 
                 0 
                 0 
               
               
                 13 Jun 
                 Ⓘ 
                 +9 
                 +13 
                 +28 
                 +20 
                 0 
                 +1 
               
               
                 14 Jun 
                 Ⓘ 
                 -13 
                 -13 
                 -26 
                 -20 
                 0 
                 -1 
               
               
                 15 Jun 
                 - 
                 0 
                 0 
                 +1 
                 0 
                 0 
                 0 
               
               
                 16 Jun 
                 - 
                 0 
                 0 
                 +1 
                 0 
                 0 
                 0 
               
            
           
         
       
     
     Attack Model: These patterns form the basis of the multi-stage attack model disclosed herein. Applicant’s study found that these attacks consisted of slow and steady attack patterns starting with establishing an initial foothold, malware injection, maintaining persistence, lateral movement, and eventually cleaning up any traces of malicious activity. 
     Taken together, the above key observations drove the design of the system of the present invention. Modeling the temporal evolution of the spatial metrics allows the system of the present invention to infer the provenance of attack evidence. Further, identifying outliers within that evolution reveals both the compromise window (e.g., starting Apr 21 for W682886) and the progression of the attack phases. Using the system of the present invention, forensic investigators can know where to focus their efforts and website owners can quickly revert the website to a clean snapshot. 
     The design the system of the present invention overcomes the challenges discussed above through provenance inference technique, using only the nightly backups of the CMS deployment. An overview of the phases of the system  200  of the present invention’s operation are shown in  FIG.  2   , which includes four phases. Phase 1 constructs spatial element sets from the website backup. Phase 2 computes the structural and code metrics for each individual snapshot. Phase 3 temporally correlates the collected metrics and labels attack events. Phase 4 verifies the assigned attack labels and extracts the compromise window. First, the system of the present invention constructs a temporally ordered set of spatial elements from each snapshot of the website. It then computes spatial metrics for each individual snapshot’s elements. This is followed by temporally correlating the collected spatial metrics and querying them against attack models to recover the timeline and label attack events. Finally, it verifies the sequence of assigned attack labels and extracts the compromise window. 
     Spatial Element Sequencing: The system of the present invention extracts the files associated with each night’s snapshot and maps them as spatial elements (el j (ψ i ) ∈ V i ) for each snapshot ψ i  ∈ Ψ. Here, Ψ is the set of all ψi, the label i denotes the index of the temporal snapshot under analysis, and j denotes the index of a spatial element in V i . Essentially, ψi is a point in time when the i th  snapshot was taken. V i  is the set of spatial elements (el j ) collected at time ψ i . For example, the initial snapshot is collected at ψ 0 , the next snapshot at ψ 1  and so on. At snapshot ψ 0 , the set of elements are represented as V0=[el 0 ,el 1 , ...]. These elements (el j (ψ i )) ∈ V i  reside in the space Θ that denotes the monitoring space of all spatial elements (i.e., all versions of all files hosted on the web server). 
     While processing each temporal snapshot ψ i , a set of initial spatial metrics (m k (ψ i ) ∈ M i ) are recorded in the set M i . Here, the label k denotes the index of the spatial metrics collected at temporal snapshot ψ i . These initial spatial metrics consists of the file type counts, and the state of each spatial element in terms of added, modified, or deleted. M i  is further populated with carefully selected measurements. A comprehensive definition of the terminology used is presented in Table II below.  
     
       
         
          TABLE II
           
               
               
               
               
             
               
                 Formal Definitions of the State of the CMS Deployment: 
               
               
                 Name 
                 Symbol 
                 Definition 
                 Description 
               
             
            
               
                 Time 
                 Ψ = (ψ,...) 
                 Ψ = (ℤ,+) 
                 Time measured in terms of the snapshot versions. 
               
               
                 Space 
                 θ = (θ,...) 
                 θ = (ℤ,+) 
                 Space of elements that can be monitored, 
               
               
                 Elements 
                 V = (el,...) 
                 el = el (θ,ψ,ψ′) 
                 Files under investigation within their life span. 
               
               
                 Spatial Metrics 
                 M = (m,...) 
                 m = m (θ,ψ) 
                 Measurements computed against a single night’s snapshot of the website backup attributes. 
               
               
                 Labels 
                 L = (lb,...) 
                 lb = lb (ψ,θ) 
                 An enumerable set of labels describing the events associated with the security of the elements. 
               
            
           
         
       
     
     For example, the website W682886&#39;s initial snapshot (ψ 0 ) contained 11, 327 files. All of these files are mapped as a sequence of spatial elements in V 0 . As an example of a single spatial metric, this snapshot also contained 23 different file types (e.g., PHP, HTML, JS, CSS, etc.). This information was recorded within the spatial metric set M 0 . If the backups are collected on a nightly basis for 3 months (e.g., 91 backups), then: 
     
       
         
           
             V 
             = 
             
               
                 
                   V 
                   0 
                 
                 , 
                 
                   V 
                   1 
                 
                 , 
                 … 
                 , 
                 
                   V 
                   
                     90 
                   
                 
               
             
           
         
       
     
     
       
         
           
             M 
             = 
             
               
                 
                   M 
                   0 
                 
                 , 
                 
                   M 
                   1 
                 
                 , 
                 … 
                 , 
                 
                   M 
                   
                     90 
                   
                 
               
             
           
         
       
     
     
       
         
           
             
               V 
               0 
             
             = 
             
               
                 
                   
                     el 
                   
                   0 
                 
                 , 
                 
                   
                     el 
                   
                   1 
                 
                 , 
                 … 
                 , 
                 
                   
                     el 
                   
                   
                     11326 
                   
                 
               
             
           
         
       
     
     
       
         
           
             
               M 
               0 
             
             = 
             
               
                 num 
                 
                   
                     PHP 
                   
                 
                 = 
                 727 
                 , 
                 num 
                 
                   
                     CSS 
                   
                 
                 = 
                 829 
                 , 
                 … 
               
             
           
         
       
     
     Spatial Analysis: The set of spatial elements include various file types (such as PHP, HTML, JS, CSS, images, plaintext, etc.), each of which requires disparate investigation techniques to identify attack attributes. To address this challenge, the system splits spatial analysis to extract two types of metrics: (1) structural metrics and (2) code metrics. 
     Structural Metrics: With the computed set of spatial elements V and the initial metrics M for each temporal snapshot, the set V is investigated. The system employs a suite of lightweight measurements that highlight the existence of suspicious elements. 
     Hidden Files and Directories: Long-lived multi-stage attacks can be characterized by the attacker’s intent to modify the existing setup and laying low at the same time. Applicant has observed that this was achieved by dropping malicious and/or suspicious elements as a hidden file or by placing them in a hidden directory to evade first order defenses. The system of the present invention employs pattern matching by filtering the typically expected hidden elements (such as .htaccess) and appends a structural metric Hide(el j (ψ i )) to M i  upon finding an element el j  ∈ V i  in a hidden location, because clean websites do not often employ hidden files or directories. 
     Extension Mismatch: Applicants have also observed that another common tactic used in CMS-targeting attacks was to disguise a server-side executable as something else. For example, spatial elements are frequently renamed deceptively as an icon file (e.g. favicon.ico) but contain PHP code to evade less technical CMS users. The system of the present invention uses the spatial element’s filename to extract its extension and then matches it against the inferred file structural metric ExtMis(el j (ψ i )) to M i . 
     Filename Entropy: Another indicator of suspicious activity seen in CMS-targeting attacks is long, incoherent, or randomly generated filenames. The system of the present invention measures the entropy of filenames for all spatial elements el j . A higher entropy indicates a more random filename that is less likely to be a human-generated benign filename. Entropy is measured using existing password strength calculation logic, which computes a filename’s “randomness” score by measuring its similarity to several dictionaries, spatial keyboard patterns (e.g., QWERTY, Dvorak), repetition of a single character, sequences of numbers or characters, and other commonly used keywords (e.g., l33t). For the system of the present invention, the password strength output is analogous to higher entropy (more randomness) and thus a more suspicious filename. 
     Since may not be practical to identify an absolute threshold for high entropy in filenames, the system of the present invention compares the relative entropy of the spatial elements using the median absolute deviation (MAD) test. Specifically, instead of computing an absolute threshold for filename entropy, which is difficult to predict with certainty, the system of the present invention considers all of the elements in a given temporal snapshot to first find the median entropy of all elements, followed by computing the median absolute deviations for each element and eventually checking if the median absolute deviation is greater than a relative threshold. When a relatively higher entropy is identified for an element el j  ∈ V i  from a temporal snapshot ψ i , the structural metric HEntrp(el j (ψ i )) is appended to M i . 
     Permission Change: The system of the present invention uses temporal tracking of each spatial element to detect permission changes between snapshots. In particular, when the permissions of spatial elements change from non-executable (read-only, read-write, etc.) to executable, it raises suspicion since it is unusual for a developer to start with a non-executable and provide execute privileges to it. Multi-stage attacks package shell scripts in a text file and then change the permissions of the file to explore privilege escalation opportunities. Upon identifying an element el j  ∈ V i  from a temporal snapshot ψ i  with permission change equipping it with execute capabilities, the system of the present invention appends a structural metric Exec(el j (ψ i )) to M i . 
     Code Metrics: Since the system is concerned with server-side attacks targeting CMSs, the system of the present invention analyzes the spatial elements containing code. These collected metrics are recorded for each snapshot ψ i  and appended to the spatial metric set M. 
     Script Directive Outlier Analysis: Most of the server-side source code is either part of the CMS core, associated plugins, or website-owner developed code. As they are meant to be maintained by developers, it is unusual to find source code files among the spatial elements with script directives (parsable instruction sequences) that are thousands of characters long. Hence, injecting exceptionally long and complex lines of obscure code in the spatial elements is a strong indicator that can be leveraged to identify attack behaviors. Attackers use this tactic to limit the readability of injected code, delaying immediate reverse engineering attempts. 
     As shown in  FIG.  3   , the directive length distribution for all spatial elements containing server-side code for W682886&#39;s 2 May snapshot is plotted in a chart  300 . The x-axis presents the spatial element index j, and the longest directive length for each of these code files is plotted along the y-axis. In benign elements (in which each data point is represented as a round dot) none of the directives were more than 500 characters long, whereas most attacker-injected elements (in which each data point is represented as a star) in this snapshot contained directives longer than 1500 characters. There was a mix of benign and malicious elements with maximum directive length between 500 and 1500 characters, which becomes the suspicious range (in which each data point is represented as a diamond). 
     Despite learning that long directives in spatial elements are suspicious, finding a threshold for directive length may not be practical due to varied coding styles and practices followed by different developers. However, it is possible to decide if a spatial element is suspicious by relatively comparing all the elements in any given temporal snapshot and performing outlier analysis. Thus, one can find suspicious files with relatively long directives using the median absolute deviation (MAD) previously described. Upon detection of the suspiciously long directive lines in a spatial element el j  ∈ V i  from a temporal snapshot ψ i , the system of the present invention appends the code metric LongLine(el j (ψ i )) to the spatial metric set M i . 
     Obfuscation Detection: server-side malware often uses a string that contains both UTF-8 characters (i.e., wide characters) and traditional 8-bit characters. While the construction of such a string itself is not malicious, it is a commonly used tactic to avoid detectors that look for known malicious string/code snippets. For example, a malicious PHP file disguised as an icon file can be included from the root of the CMS using the following long UTF-8 (shown in italic) coupled with ASCII (shown in bold) path to the file:  
     
       
         
           
               
            
               
                 @include “\x2fmn\x74/s\x74or\x31-w\x632-\x64fw\x31/4\ 
               
               
                          x3505\x327/\x77ww\x2ecv\x6dar\x61ci\x6eg.\x63om\ 
               
               
                          x2fwe\x62/c\x6fnt\x65nt\x2fmo\x64ul\x65s/\x61gg\ 
               
               
                          x72eg\x61to\x72/t\x65st\x73/f\x61vi\x63on\x5fbd\ 
               
               
                          x33fd\x35.i\x63o”; 
               
            
           
         
       
     
     Array map obfuscation is another obfuscation scheme commonly used to evade defenses. An array map is defined to map each character to a different character. This map is used to deobfuscate what appears to be a jumbled list of characters to a reverse engineer trying to make sense of this obfuscated spatial element. For example, in the following code snippet, lnhqvwxeon() is a function that takes a jumbled character string (in the variable $zvkgw) and uses the array map in $lyfuf to generate malicious code that gets executed as part of the PHP eval function:  
     
       
         
           
               
            
               
                 $lyfuf = Array (&#39;1&#39;=&gt;&#39;G&#39;, &#39;0&#39;=&gt;&#39;6&#39;, &#39;3&#39;=&gt;&#39;4&#39;, 
               
               
                                &#39;2&#39;=&gt;&#39;L&#39;, &#39;5&#39;=&gt;&#39;1&#39;, &#39;4&#39;=&gt;&#39;W&#39;, &#39;7&#39;=&gt;&#39;y&#39;, ... , 
               
               
                                &#39;y&#39;=&gt;&#39;w&#39;, &#39;x&#39;=&gt;&#39;F&#39;, &#39;z&#39;=&gt;&#39;1&#39;); 
               
               
                          eval(lnhqvwxeon($zvkgw, $lyfuf)); 
               
            
           
         
       
     
      Upon spatial detection of obfuscation in an element el j  ∈ V i  from a temporal snapshot ψ i  via regex pattern matching for the cases described above, the system of the present invention appends a code metric Obfus(el j (ψ i )) to M i  indicating the presence of obfuscation in the element el j . 
     Suspicious Payload Evaluation: In server-side spatial elements, functions such as eval, base64_decode, and url_decode are commonly paired to execute previously identified obfuscated code. The system of the present invention identifies and flags instances of the eval and base64_decode/url_decode pairing via pattern matching along each control flow. Upon identifying this code unwrapping technique in an element el j  ∈ V i  from a temporal snapshot ψ i , the system of the present invention appends a code metric EvDc(el j (ψ i )) to M i  indicating unsafe or suspicious code, compressed to avoid more conventional detectors. 
     Code Generation Capability: Almost every server-side spatial element contributing to the multi-stage CMS-targeting attack contains code generation capabilities such as the use of create_function. Although several developers use this as part of certain CMS plugins, it is very rarely employed in ordinary server-side code development. The system of the present invention scouts for such code generation capabilities and appends a code metric CodeGen(el j (ψ i )) to the spatial metric set M i  upon finding an element el j  ∈ V i  satisfying the constraints. 
     Temporal Correlation and Forensic Recovery: Based on the collected spatial metrics for each snapshot, the system of the present invention now attempts to temporally correlate these metrics across snapshots to identify suspicious activities that evolve within the website. Here, the system of the present invention is programmed to track developments over a sliding n - day time window (e.g., n = 20 means track developments in the spatial metrics by comparing them across 20 days). In this stage, the system of the present invention temporally correlates the spatial metric set M i  at any temporal snapshot ψ i  with the spatial metrics M x  from all previous temporal snapshots within the sliding window (i - n&lt;x ≤ i) to capture the persistent adversary relationship and extract the timeline of events. 
     Patterns in the metrics M, assigned as a function of spatial elements, indicate long-lived multi-stage attack behaviors which can be detected. The system constructs rules to encode these behaviors based on the Boolean composition of the spatial metrics. These rules are designed to be agnostic to the individual metrics and are based on the invariants of the phases that long-lived multi-stage attacks go through. Table III, below, shows the representative set of rules applied as part of the current implementation. Further, the temporal correlation of events encapsulating the patterns in spatial metrics is implemented by considering two consecutive temporal snapshots at a time. In particular, the 2-tuple (M i -1, M i ) is passed to the system of the present invention’s temporal correlation phase (as shown in  FIG.  2   ) where it is queried against the attack models from Table III. An attack label set L i  and a severity are assigned to each temporal snapshot, thus incrementally building the attack timeline. The assigned severity of the attack labels tells the investigator which of the labels are more critical than the others.  
     
       
         
          TABLE III
           
               
               
               
             
               
                 Rules to Model Compromised CMS Events as Multi-Stage Attack Phases: 
               
               
                 Attack Label L 
                 Severity 
                 Attack Modeling Rule 
               
             
            
               
                 Establish Foothold 
                 Medium 
                 ExtMis(el j (ψ i ))∨[(el j ∉)∧[HEntrp(el j (ψ i ))∨Hide(el j (ψ i ))]] 
               
               
                 Obfuscated Code Injection 
                 High 
                 [(size(el j (ψ i ))&gt;size(el j (ψ i-1 ))∨(MaxL(el j (ψ i ))&gt;MaxL(el j (ψ i-1 )))]∧Obfus(el j (ψ j )) 
               
               
                 Malware Dropped 
                 High 
                 (el j ∉V i-1 )∧[Obfus(el j (ψ i ))∨LongLine(el j (ψ i ))∨EvDc(el j (ψ i ))] 
               
               
                 Code Generation Capability 
                 Low 
                 CodeGen(el j (ψ i )) 
               
               
                 Defense Evasion 
                 High 
                 Hide(el j (ψ i ))∧[Obfus(el j (ψ i ))∨EvD(el j (ψ i ))∨HEntrp(el j (ψ i )∨ExtMis(el j (ψ i ))] 
               
               
                 Escalate Privileges 
                 High 
                 Exec(el j (ψ i ))∧¬Exec(el j (ψ i-1 )) 
               
               
                 Maintain Presence 
                 Medium 
                 (Sev(el j (ψ i ))==High)∧(Sev(el j (ψ i-1 ))==High) 
               
               
                 Attack Cleanup 
                 Medium 
                 (Sev(el j (ψ i-1 ))==High)∧[(Sev(el j (ψ i ))==None)∨(Sev(el j (ψ i ))==Low)∨((el j (ψ i ))∉ i 
 
               
            
           
         
       
     
     The rules presented in Table III capture the overall intuition behind our insights. For example, the running example W682886 has two cases of obfuscated code injection: (1) Suspicious obfuscated code injected into an existing unobfuscated element; and (2) Additional obfuscated code appended to an already obfuscated element. Based on this observation, if an obfuscated spatial element el j (ψ i ) ∈ V i  increases in size (i.e. obfuscated attack progression), or if a script directive outlier is flagged in el j (ψ i ) but not el j (ψ i  -1) (i.e. obfuscated code is injected into an existing unobfuscated element), and the code metric Obfus(el j (ψ i )) ∈ M i , then an attack label “Obfuscated Code Injection” is appended to the set L i  at snapshot ψ i . For the W682886 example, this label was assigned on 21 April, 7 June, and 13 June. 
     Note that multiple spatial elements el j (ψ i ) ∈ V i  can give rise to multiple labels for each temporal snapshot. For example, there can be three spatial elements associated with Obfus (el j (ψ i )) ∈ M i  (i.e., 3 files with obfuscated code in them), and four other spatial elements associated with ExtMis (el j (ψ i )) ∈ M i  (i.e., four shell scripts disguised as gifs). In this case, both event labels Obfuscated Code Injection and Privilege Escalation are appended to the set L i , and the highest severity of the union of this set L i  is assigned to the temporal snapshot ψ i . It is also possible that multiple labels get assigned to a temporal snapshot due to one spatial element, i.e., an adversary can move a benign file to a hidden directory and inject it with suspicious obfuscated code. In this case, both Defense Evasion and Obfuscated Code Injection labels get appended to the set L i  and follow the highest severity assignment as described above. 
     Compromise Window Recovery: With the attack labels in hand, the system of the present invention proceeds to extract the compromise window by parsing consecutive pairs of the 3-tuple of spatial elements, spatial metrics, and the assigned attack labels (i.e. (V, M, L) i ). Algorithm 1 below presents the pseudocode for this procedure. Lines 1-3 in Algorithm 1 describe how it takes the 3-tuple (V, M, L) as input, computes the differential spatial metrics DiffAttri for each snapshot at ψ i  from consecutive pairs of (V, M) i -1,(V, M) i  (e.g., recall the differential file type information shown in Table I). 
     
       
         
           
               
               
               
               
             
               
                 Algorithm 1: Compromise Window Detection 
               
             
            
               
                 Input:V = [V 0 , V 1 , ..., V N-1 ], M = [M 0 , M 1 , ..., M N-1 ], 
               
               
                 L= [L 0,  L 1 , ..., L N-1 ], 
               
               
                 N = Number of temporal snapshots 
               
               
                 Output: SuspiciousRanks = [ψ x   0 , ψ x   1 , ..., ψ x   N   -1 ], 
               
               
                 CompromiseWindow = [ψ x   0 , ψ x   1 , ..., ψ x   k ] // Calculate frequency of each attribute value 
               
               
                 1 
                 for ∀ψ i  ∈ Ψ do 
               
               
                 2 
                 Diff Attr i  ← V i  - V i-1 , for each el j  ∈ V i 
 
               
               
                 3 
                 Diff Attr i  ← M i  - M i-1 , for each m j  ∈ M i 
 
               
               
                   
                 // Verify label sequence 
               
               
                 4 
                 if i! = 0 and L i  comes after L i-1  then 
               
               
                 5 
                   
                 CorrectLabel i  = True 
               
               
                 6 
                 end 
               
               
                 7 
                 end Attr Freq = Frequency of each attribute da j  ∈ DiffAttr 
               
               
                 8 
               
               
                   
                 // Calculate AVF scores 
               
               
                 9 
                 for ∀Diff Attr i  ∈ Diff Attr do 
               
               
                 10 
                 score ← 0; 
               
               
                 11 
                 for da j  ∈ Diff Attr i  do 
               
               
                   
                   
                 // Score for snapshot ψ i 
 
               
               
                 12 
                   
                 score ← score + Attr Freq[da j ] 
               
               
                 13 
                 end 
               
               
                 14 
                 AVF scores ← score/size(Diff Attr i ) 
               
               
                 15 
                 end 
               
               
                 16 
                 Suspicious Ranks ← return (sort ψ i  in order of minimum 
               
               
                   
                 AVF scores) 
               
               
                 17 
                 for ∀ψ i  ∈ Ψ do 
               
               
                 18 
                 if CorrectLabel i  == True then 
               
               
                 19 
                   
                 while AVF Scores outside CompromiseWindow &lt; 
               
               
                   
                   
                 AVF Scores inside CompromiseWindow do 
               
               
                 20 
                   
                   
                 CompromiseWindow ← compute (range between 
               
               
                   
                   
                   
                 first and last ψ i  with verified L i  ) 
               
               
                 21 
                   
                 end 
               
               
                 22 
                 end 
               
               
                 23 
                 end 
               
               
                 24 
                 return SuspiciousRanks, CompromiseWindow 
               
            
           
         
       
     
     As shown in Lines 8-16 in Algorithm 1, it then computes the attribute value frequencies (AVF) using the AVF algorithm (one representative example of which is shown below as Algorithm 2) on the differential spatial metrics DiffAttri and processes it to rank the temporal snapshots ψ i  in order of suspicious activities. The AVF algorithm performs well on categorical data with multiple attributes, the differential spatial metrics in our case. In a typical AVF application, the number of anomalies to be detected are preprogrammed. Here, instead of choosing the number of anomalies to be detected, the system of the present invention uses the AVF algorithm to rank the temporal snapshots in the compromise window in the order of most suspicious to least suspicious. 
     Algorithm 2: Example of pseudocode for the AVF algorithm:  
     
       
         
           
               
            
               
                 # Label all data points as non-outliers 
               
               
                     # calculate frequency of each attribute value 
               
               
                     # foreach point x 
               
               
                     # AVFscore = Sum(frequency each attrib. value in 
               
               
                     x)/num.attribs 
               
               
                     # end foreach 
               
               
                     # return top k outliers with minimum AVFscore 
               
            
           
         
       
     
     Before the system of the present invention outputs the final attack labels for the entire temporal sequence, it passes the label set L through logical sequence verification of the associated labels (Lines 4-6 in Algorithm 1) and assesses their order of appearance. For example, when the only labels assigned are ‘code generation capability’ and ‘attack cleanup’, it has been observed that these behaviors arise from benign elements populated by the web developer and mean no harm. In such cases, the labels are retained but their severities are reduced to ‘None’. If the label ‘maintain presence’ is seen on a snapshot prior to any other event label such as ‘establish foothold’ or ‘malware dropped’ or any other high severity modeling rule, since we know that this event sequence is intuitively not feasible, the system of the present invention has been programmed (again via Boolean composition of the previous label rules) to filter out sequences that do not make logical sense. 
     The system of the present invention’s compromise window is influenced only by the order of 2 out of the 8 labels, i.e., attack cleanup and maintain presence. The system of the present invention considers all combinations of the other labels as the beginning of a compromise window. This makes the system of the present invention robust against attackers who might try to deploy out-of-order payloads to confound the system of the present invention. 
     Once the logical sequence of the assigned labels is verified and the temporal snapshots are ranked in the order of suspicious activities, the system of the present invention then identifies the compromise window — the period between the first and the last temporal snapshot comprising of suspicious activities with assigned and verified labels L. Also, the window is chosen such that the AVF score for every temporal snapshot outside the compromise window is higher than the score for every temporal snapshot within the compromise window (see, lines 17 -21 of Algorithm 1). This is the period when maximum suspicious activities take place in the website and help one to narrow down the analysis to a smaller window. These intuitive temporally correlated spatial metrics and the attack models both align well with the design and work well in practice. 
     For the example website under investigation (“W682886”), from 1 April - 30 June, the compromise window was identified from 21 April - 16 June. By applying the AVF algorithm, the system of the present invention output the following temporal snapshots for this website ranked in order of most suspicious to least suspicious as follows:  
     
       
         
           
               
            
               
                 &lt;-Most suspicious.................Least suspicious -&gt; 
               
               
                     5 June, 13 June, 8 June, 14 June,21 April,..,29 June 
               
            
           
         
       
     
      This aligns with the earlier visual inspection of the differential file type metrics presented in Table I. 
     Note than these attack models are scalable irrespective of the underlying CMS, i.e. when a new tactic is identified, the system of the present invention framework is designed to be highly modularized and can be easily updated to capture the essence of the new tactic and the attack label associated with it. Essentially, applying the attack modeling rules to spatial metrics and incrementally sliding along each temporal snapshot enables the system of the present invention to assign appropriate labels L along the compromise window, thus providing a timeline of the events as part of the long-lived multi-stage attack analysis. 
     Although specific advantages have been enumerated above, various embodiments may include some, none, or all of the enumerated advantages. Other technical advantages may become readily apparent to one of ordinary skill in the art after review of the following figures and description. It is understood that, although exemplary embodiments are illustrated in the figures and described below, the principles of the present disclosure may be implemented using any number of techniques, whether currently known or not. Modifications, additions, or omissions may be made to the systems, apparatuses, and methods described herein without departing from the scope of the invention. The components of the systems and apparatuses may be integrated or separated. The operations of the systems and apparatuses disclosed herein may be performed by more, fewer, or other components and the methods described may include more, fewer, or other steps. Additionally, steps may be performed in any suitable order. As used in this document, “each” refers to each member of a set or each member of a subset of a set. It is intended that the claims and claim elements recited below do not invoke 35 U.S.C. §112(f) unless the words “means for” or “step for” are explicitly used in the particular claim. The above-described embodiments, while including the preferred embodiment and the best mode of the invention known to the inventor at the time of filing, are given as illustrative examples only. It will be readily appreciated that many deviations may be made from the specific embodiments disclosed in this specification without departing from the spirit and scope of the invention. Accordingly, the scope of the invention is to be determined by the claims below rather than being limited to the specifically described embodiments above.