{'fraction_non_alphanumeric': 0.024978541705146733, 'fraction_numerical': 0.009604624126728887, 'mean_word_length': 4.662606127722407, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Measuring Privacy Leakage for IDS Rules

This paper proposes a measurement approach for estimating the privacy leakage from Intrusion Detection System (IDS) alarms. Quantitative information flow analysis is used to build a theoretical model of privacy leakage from IDS rules, based on information entropy. This theoretical model is subsequently verified empirically both based on simulations and in an experimental study. The analysis shows that the metric is able to distinguish between IDS rules that have no or low expected privacy leakage and IDS rules with a significant risk of leaking sensitive information, for example on user behaviour. The analysis is based on measurements of number of IDS alarms, data length and data entropy for relevant parts of IDS rules (for example payload). This is a promising approach that opens up for privacy benchmarking of Managed Security Service providers.


I. INTRODUCTION
The objective of this paper is to develop an entropy-based metric that can be used for privacy leakage detection in intrusion detection system (IDS) alarms. The approach should be able to identify IDS rules that according to stakeholders' perception have a significant potential for leaking private or confidential information. It should also identify the worst IDS rules from a privacy or confidentiality perspective based on indicators that can be calculated automatically. For example IDS rules that: • have a significant risk to leak information that is sensitive (privacy sensitive, security sensitive, business sensitive etc.); • have an unclear or too simple definition of the attack detecting pattern, and therefore may trigger unnecessarily, in the worst case on person sensitive or confidential information. Privacy policies can be used to define what information that is sensitive. Examples of sensitive information may be certain IP ranges of classified systems or sampled payload that may reveal private or confidential information. Information can also be defined as person sensitive by law, for example the sampled payload from a health institution which may contain person sensitive information. Another example is critical infrastructures that may contain security sensitive or confidential information in the data traffic about the processes being controlled. Last, but not least, payment databases handling financial transactions may reveal sensitive information like credit card numbers.
In these cases, the information is per definition sensitive, which means that any leakage of information that can be identified may be problematic. For such use cases, an objective information leakage metric will be sufficient to identify problematic leakage of private or confidential information.
In other cases, the privacy sensitivity will be subjective, and can only be evaluated in a representative way by the owners of the data being sampled -the users themselves. It may even in this case be possible for the data controller to get realistic estimates of the perceived privacy sensitivity by asking a representative random set of users, for example using a random poll on the service being used, about how they would value privacy leakages. However this approach will be expensive and does not scale well. It is therefore only viable for smaller evaluations of privacy impact.
It is therefore assumed possible for an authority like the data controller, that is overseeing the privacy interests, to estimate the privacy impact, denoted by I ≥ 0, that an identified information leakage L ≥ 0 causes. The privacy impact could for example be the subjective value or expected liability from privacy or confidentiality breaches, as proposed by [19]. The privacy leakage, denoted by π R for a given IDS rule R can then be defined as the product of the information leakage metric L and the privacy impact I, i.e: π R = I · L. However, if investigation shows that the information leakage is caused by activities from attack vectors that do not cause any risk of revealing private, business sensitive or confidential information, then the privacy impact for a given IDS rule may be set low or even to zero. The combined metric π R can be regarded as a privacy leakage risk metric, that can be used to measure and perform incremental improvements of the Managed Security Service (MSS) operation from a privacy perspective.
Current IDSs typically provide an all or nothing solution for handling private or confidential information in the alarms. The payload of the alarms is either being sent in cleartext or may be pseudonymised, for example by only sending references to where more information can be found in a data forensics system. There does not exist a more fine-grained management nor any measurements of sensitive information flows in such systems. It is in particular common that Open Source based IDS's like Snort, OSSEC or Prelude send payload in cleartext in the IDS alarms. Having a metric for how privacy invasive an MSS operation is will therefore be useful to benchmark arXiv:1308.5421v1 [cs.CR] 25 Aug 2013 the performance of different MSS providers from a privacy perspective. It will also be useful for tuning the IDS rulesets and for implementing anonymisation policies to reduce the privacy impact of the monitoring. Intuitively, such a privacy leakage model relates to the perceived preciseness of the IDS rule, i.e. how good it is at detecting only attack traffic without revealing non-attack traffic.
A promising candidate for a privacy leakage metric for IDS rules, is data entropy. This is a privacy leakage metric that is based on the variability of the underlying data. Examples of such metrics are Shannon-, Rnyi or Min-entropy, which previously have been proposed as anonymity metrics [32,5]. Entropy can also be used to measure coding efficiency, for example whether sampled payload excerpts most likely are encrypted or compressed [32]. This paper investigates a model of privacy leakage from IDS rules that is based on the variation in entropy between IDS alarms. This is to the best of our knowledge the first comprehensive privacy leakage model for IDS rules based on quantitative measurements of information flow founded in information theory.
The proposed privacy leakage metric has several practical applications. First, it can be used to identify imprecise IDS rules, since such rules typically will have more variation in the underlying data, and therefore also a larger variance in entropy than more precise IDS rules. Furthermore, an advantage with the proposed metric is that it can detect two common ways of preserving privacy or data confidentiality: anonymisation and pseudonymisation. Both encrypted and anonymised information can be expected to have zero entropy variance, given sufficiently long input. On the other hand, the entropy variance of plaintext data will be significantly larger than for encrypted data, as will be discussed in Section V-C.
This means that the entropy variance can be used as a metric to detect leakage of private or confidential information in message oriented data streams in general and IDS alarms in particular. It can also be used to verify whether an anonymisation/pseudonymisation or encryption scheme works as intended.
This paper is organised as follows: Section II discusses the motivation behind introducing an entropy variance based information leakage metric, based on existing knowledge of how common attack vectors work. Section III describes the threat model and scenario that is assumed when using the privacy leakage metric. Section IV develops the entropy-based privacy leakage model based on quantitative information flow analysis after introducing the necessary theoretical background information. The last part discusses how clustering based on the Expectation Maximisation algorithm can be used to identify the underlying attack vectors for IDS rules that detect more than one attack vector. Section V does a detailed analysis of the convergence speed as a function of amount of input data for the entropy algorithms and symbol definitions considered. This includes analysing the metrics' abilities to distinguish between plaintext and encrypted data. Section VI analyses experimental results based on realistic measurements of IDS alarms. Section VIII discusses related works; Section IX concludes the paper and Section X suggests future work and research opportunities.

II. MOTIVATION
A precise IDS rule will in many cases report only one or a few different attack patterns corresponding to real attack vectors, as will be discussed below. One common type of attack vector that follows this behaviour, is stack or heap buffer overflow attacks [39]. These attack vectors frequently use large sequences of characters corresponding to the NOP operation or similar to increase the probability of successfully exploiting buffer overflow vulnerabilities. The attacker does then not need to know the exact memory location of injected shellcode, since returning to any address within the NOP sled will cause the shellcode to be executed. This makes it simpler for the adversary to exploit such vulnerabilities. The entropy of this NOP sled will be zero, and variance zero, as long as only NOP operations are being used in the sled and the attack vector does not mutate (e.g. by changing the length of the NOP sled). This is clearly distinguishable from ordinary traffic, and also easy to distinguish for rule-based IDSs.
Such naive attacks are however not so common nowadays, because the IDS and anti-virus technologies easily can detect such anomalies in the input. It is therefore increasingly common that the adversaries obfuscate the attack vector. Obfuscation of the NOP sled can for example be done using metamorphic coding, which means that instructions in the sled are substituted with other instructions that effectively perform the same function [21]. Furthermore, it is now common practice that also the shellcode of the attack is being obfuscated by using encryption techniques. This means that the attack after the NOP sled contains a small decryption program, with a decryption key that decrypts the obfuscated shellcode before it is being run [37]. Even the decryption program can be hidden by using metamorphic coding techniques [37], although this is still not very common [28].
This means that obfuscated attack vectors can be expected to have quite high entropy, in some cases indistinguishable from encrypted traffic [37,18]. This means that the variation in entropy can be expected to go towards zero for a sufficiently large data sample from a polymorphic attack vector, given that it is indistinguishable from a perfect encryption scheme. Such an attack vector will behave like random uniform data. This means that the entropy variance of sufficiently large attack vector samples from both traditional NOP sled based attacks and modern obfuscated attacks also can be expected to have low entropy variance.
It can furthermore be observed that samples of encrypted user traffic, assuming that strong encryption is used, in itself does not leak any private or confidential information, hence can be expected to have low entropy variance. Ordinary nonencrypted user traffic, can however be expected to show a significant variance in entropy between different samples, as illustrated in Figure V.2. This indicates that entropy variance may be an interesting metric for measuring whether IDS alarms leak information, in particular for buffer overflow type of attacks. However this metric does obviously not understand the semantics of the data traffic, and can therefore not be used to evaluate whether the leaked information is private or confidential.
There also exist attack vectors that are indistinguishable from plaintext data. Examples of such attacks are nonobfuscated Javascript Trojans or SQL injection attacks. This means that the entropy standard deviation not necessarily can be assumed to be close to the extreme points: encrypted data (entropy close to 1) or NOP sleds (octet-entropy close to 0). However, there are still some other useful characteristics of such plaintext attacks in particular, and malware in general, that can be exploited by such a metric: • Attacks are to a great extent automated and performed by large botnets of compromised hosts. • Attack vectors do typically not yet mutate or change dynamically 1 . This means that multiple attacks by a given host being controlled by an adversary typically has the same payload. Different hosts running the same version of a given malware can also be expected to typically have the same payload [28]. • Attack vectors are modular programs that are improved incrementally, which means that not all parts of a malware will change at the same time, and some parts of malware code are even shared between different malware families [28]. • Botherders, that manage large botnets of compromised hosts, will also have a self interest in a "well managed" botnet. This means that the malware of a botnet at regular intervals will be upgraded to include patches and new functionalities, amongst others to avoid being detected by Anti-Virus and IDS [17]. It is therefore reasonable to believe that a large amount of the machines in a given botnet will run the same version of the malware and therefore also will use the same arsenal of attack vectors for attacking other hosts. This means that if an IDS rule is able to detect a given attack, or attack variants, then there are several reasons to believe that the entropy variance between instances of the same attack vector may be small, even for nonobfuscated Javascript or SQL injection attacks. This furthermore means that if the underlying attack vectors detected by an IDS rule can be identified, then the entropy variance (or entropy standard deviation) around each attack vector can be considered a measure of the precision of that rule hence also an indicator of possible privacy leakages.

III. THREAT MODEL
The paper assumes that intrusion detection services have been outsourced to a third party Managed Security Service (MSS) provider. Security monitoring is furthermore subdivided into two different security levels. An outsourced first-line service that is doing 24x7 monitoring of the computer networks, and a trusted second-line service that will have full knowledge of the IDS service, including capabilities to perform data forensic analysis. It is assumed that the MSS provider operates using a privacy-enhanced IDS, so that changes to the IDS ruleset must be agreed upon by both the data controller and the second line security analyst responsible for updating the IDS ruleset, to avoid that excessively privacy violating IDS rules are being deployed.
It is therefore assumed that the IDS services run in a controlled environment, where enforcement of a privacy policy supported by privacy leakage metrics makes sense. An example of such an environment is critical infrastructures or hospitals where security services have been outsourced to a third party, and privacy metrics are required to ensure compliance both to privacy and security policies. These policies must ensure that the first-line security analysts, that are not trusted to see sensitive information, do not get access to information considered private or confidential by the owner of the critical infrastructure. The objective is a stricter enforcement of the need-to-know principle than what IDSs typically have today. However, in order to enforce such privacy and security policies, suitable privacy metrics are needed, which will be developed here.
This paper mainly focuses on two adversaries: an external adversary that may want to manipulate the privacy metrics for example to reduce the chance of attacks being detected. The IDS ruleset is assumed public, so that an external adversary can investigate how the IDS rules work in order to perform targeted attacks on either privacy or security. However the external adversary will not know which IDS rules that are enabled.
Insiders are divided into two main groups. First-line security analysts are considered untrusted insiders, that only have limited authorisation to see information and no authorisation to modify information related to the IDS configuration. They do not have access to the data forensic tool to investigate attacks in detail. Second-line analysts are considered a trusted CERT team, that has authorisation to perform security investigations and reconfigure the IDS. A third actor is the data controller, who shares the responsibility for managing the IDS ruleset with the security officer, to ensure that both the privacy and security objectives are being considered. The paper furthermore assumes that suitable enforcement mechanisms exist, for example anonymisation or pseudonymisation schemes for sensitive information in IDS alarms, so that the privacy leakage metrics can be used for verification of the security or privacy policies.

IV. A PRIVACY LEAKAGE MODEL OF IDS RULES
This section will first provide an information theoretic analysis of privacy leakage from IDS alarms, assuming a simple model of a perfect IDS rule R P that does not have any false alarms. This model is subsequently generalised to handle IDS rules that may leak potentially sensitive information, and we then show how this model corresponds to measuring the standard deviation of entropy from the IDS rule. It is finally shown how to measure the privacy leakage from IDS rules that detect more than one attack vector.

A. Basic Definitions
The definitions and notation in this section give a short introduction to quantitative information flow analysis, and is based on [34]. It is throughout this paper assumed that the logarithm is taken to the base 2, i.e. log(x) means log 2 (x). Shannon and Min-entropy can be considered instances of the more general Rnyi entropy [30], and we therefore use the Rnyi notation to describe the entropies. Any Rnyi entropy metric is denoted as H α (X), where α is the entropy degree; α = 1 represents Shannon entropy and α = ∞ represents Min-entropy. Given an IDS rule R, which may leak sensitive information from a set of input data X and to a set of IDS alarms Y , the objective is then to measure how much information R leaks.
Let X and Y be random variables whose set of possible values are X and Y respectively. The Shannon entropy is then defined by [32]: Shannon entropy indicates the number of bits that are required to transfer X in an optimal way. The conditional entropy denoted as H 1 (X|Y ) indicates the expected resulting entropy from input data X given a set of IDS alarms Y that pass through the IDS rule R [34]: where (IV.3) Min-entropy is another entropy metric that is calculated based on the worst case (maximum) symbol occurrence probability, defined as the vulnerability V (X) that an adversary can guess the value of X correctly in one try [34]: Min-entropy indicates the number of bits required to store V (X), and is defined as [34]: The conditional min-entropy can be defined as [34]: It is then possible to define the information leakage L XY from X to Y using either Shannon or Min-entropy as proposed by [34]: (IV.8)

B. Perfect model IDS Rule
Assume a perfect model IDS rule R P , that always detects the attack vector and does not have any false alarms or other entropy sources. Furthermore assume that the given attack vector does not change between different attack instances. The payload sample in the IDS alarm from R P is also assumed to not contain any other entropy sources. The IDS will in this case always sample the same payload excerpt in every alarm according to the attack pattern definition.
This IDS rule is termed a perfect model IDS rule, since it is considered perfect according to the theoretical model of privacy leakage. R P is in other words a perfect model of IDS rule behaviour from a privacy perspective. This is not a purely theoretical IDS rule behaviour. We observed three IDS rules that behaved like R P in our experiments, for example the Snort IDS rule with SID 1:2003 SQL Worm Propagation attempt, as shown in Figure IV.1. This is obviously a simplistic model of an IDS rule, since it does not handle the fact that many IDS rules and also non-rule based technologies like anomalybased IDS will be able to detect more than one attack vector, and also variants of attack vectors. The model is furthermore oblivious to whether the source of entropies is adversarial or ordinary user activities. An entropy-based metric can only measure whether information is leaking or not. Therefore the privacy impact I will need to be evaluated, as discussed earlier.
The perfect model IDS rule will under these assumptions provide a constant leakage denoted as c of information in each alarm, corresponding to the pattern matched by R P .
The privacy impact I of this constant information leakage as a privacy leakage is however not known. The privacy impact of the information leakage from each IDS rule must therefore be evaluated by a data controller, to determine whether the expected information leakage from the IDS rule can be considered necessary and acceptable from a security perspective, and also that the effective privacy impact from the rule can be considered negligible if the rule is effective over time. This manual quality assurance procedure makes it possible to detect and avoid IDS rules where I · c in itself is judged to cause a significant privacy leakage, for example if the rule itself triggers on person sensitive information. The privacy leakage I ·c from each installed IDS rule is therefore in the rest of this paper considered as either necessary or negligible. If this constant privacy leakage is not considered tolerable, then it is assumed that this can be mitigated using anonymisation or pseudonymisation policies. R P will under these assumptions always triggers on the same attack pattern Y = {y}, as illustrated in Figure IV.2. The inter-alarm entropy, assuming a set of input data X, denoted as H int α (X|Y ), is defined as the entropy between different IDS alarms, calculated over the entire payload excerpt (i.e. each IDS alarm is considered as one "symbol"). The inter-alarm entropy will in this case be H int α (X|Y ) = 0, since P [Y = y] = 1. This means that a perfect model IDS rule according to this definition from an information theoretical perspective does not reveal any additional information apart from what can be inferred from the limited and constant information leakage c in each alarm.
This does not mean that additional leakage of sensitive information cannot occur, since the resulting privacy leakage also will depend on the timing and context of the alarms. Additional information may for example be revealed by correlating the interdependencies between the IDS rules.
However, under the given assumptions, this means that when R P triggers, then a known data pattern will have been sent in the input data stream. This information leakage is considered a tolerable privacy leakage under the assumptions in the previous subsection.

C. A Non-perfect IDS rule R
Then consider a non-perfect IDS rule R, which in addition to the assumed necessary and limited information leakage by the attack pattern, also may have false alarms or other entropy sources, as illustrated in Figure IV.3. However, it still only detects one attack vector, that does not change between attacks. This means that the entropy distribution function will be unimodal, perhaps with some outliers as illustrated in Figure IV.3. This is a simplistic model of how an IDS rule behaves. It does not assume any particular IDS rule implementation (e.g. whether string matching or regular expressions are being used) and does not take any position on the type of IDS technology being used. Experimental results have however shown that a significant amount of all IDS rules   (35-53% in the experiments we have performed 2 ) actually behave in this way. However, this also means that many IDS rules actually do not behave this way. We will therefore later discuss how this restriction can be removed. The model of a unimodal non-perfect IDS rule is illustrated in Figure IV

D. Privacy Leakage Model
The next question is how to model the privacy leakage from the non-perfect IDS rule R. One way to do this, is to measure the information leakage of the non-perfect IDS rule R relative to a perfect model IDS rule R P , as illustrated in Figure IV rule. Both IDS rules have the objective to trigger on the same attack vector, however the first IDS rule R is non-perfect, and may have false alarms or other entropy sources, whereas the second IDS rule R P is considered a perfect model IDS rule. The advantage of using a cascading model, is that this allows for comparing known values, and it is not dependent on the unknown Internet traffic X. The set of alarms Y from R are known by the MSS provider and the set of expected alarms Z from R P are also known given Y .
Focusing on the inter-alarm entropies is not a fruitful approach here, since the difference in inter-alarm en- What is needed, is therefore a measure of the limited information leakage that the perfect model IDS rule causes.
This initial information loss, denoted as the intra-alarm information loss H α (X), can be expressed by measuring the entropy of the IDS alarm in bits, instead of measuring the interalarm entropy H int α (the entropy between IDS alarms, considering the entire IDS alarm as one symbol). The intra-alarm entropy for a perfect model IDS rule R P can be calculated by assuming that the IDS alarm consists of a large sequence of bits. This can be expressed formally by considering a given IDS alarm as Considering the perfect model IDS rule first, then this IDS rule will always return the same IDS alarm Z = {y} where y ∈ {0, 1} with bit-probability {P [y = 0], P [y = 1]}. The information leakage is defined according to (IV.8) as: (IV.9) Since R P is deterministic, then Z will be determined by Y , which means that H α (Y |Z) = 0. Furthermore, for Shannon entropy: (IV.10) P [X = x|Y = y] = 0 for x = y, which means that this can be expressed as: which gives: This shows that R P has a constant privacy leakage L Y Z = c 1 for Shannon entropy. This can also be shown for Minentropy by substituting into Equation (IV.6): where the vulnerability V (X|Y = y) can be expressed as: (IV.15) P [X = x|Y = y] = 0 for x = y, which means that this can be expressed as: which can be expressed as This shows that the vulnerability is V (X|Y = y) = 1 for P [y = 0] ∈ {0, 1}. The lowest vulnerability is V (X|Y = y) = 1 2 for P [y = 0] = 1 2 , as expected. This means that the Min-entropy for R P can be expressed as: 18) This means that R P has a constant information leakage for both Shannon-entropy L Y Z = c 1 and Min-entropy L Y Z = c ∞ . However these constants are different, except in the special cases where P [y = 0] ∈ {0, 1 2 , 1}, as can be expected (see Figure IV.6).
Let the constant information leakage for either Shannon or Min-entropy be denoted as c α . The relative information leakage from the IDS rule R can then be formally defined as follows: Definition 1. Let R be a non-perfect IDS rule, that in addition to the assumed necessary and limited information leakage by the attack pattern, also may have false alarms or other entropy sources. Let R P be a perfect model IDS rule with a limited privacy leakage c α , α ∈ {1, ∞} 3 . The relative information leakage L Y Z for an IDS rule R with input X, that generates a set of IDS alarms Y = {y 1 , y 2 , ..., y N }, each with probability P [Y = y i ], i = 1, ..., N is then defined as the difference in intra-alarm entropy between R and a perfect model IDS rule R P that both trigger on the same attack vector: If the probability distribution function (PDF) of the IDS alarm entropies for a given attack vector is symmetric, then the average entropy denoted as H α (X|Y ) for input X and a sufficiently large set of IDS alarms Y can be considered as a good estimator of c α . For skewed distributions, the median may give a better estimate, given that the sample is sufficiently large. It can furthermore be observed that the precision of this estimator will improve with the precision of the IDS rule R. This means that the information leakage of R for a given IDS alarm y i can be expressed as: where the average entropy can be expressed as for a set of input data X.

E. Information Leakage for a Sample of IDS Alarms
The average entropy per byte for a sample y 1 , y 2 , ..., y N of N IDS alarms generated by an IDS rule R that detects a single attack vector, can be expressed as The information leakage for any IDS alarm y j , denoted as L R (y j ) can then be expressed as: Further processing of the information leakage L R (y i ) for the IDS alarms y 1 , y 2 , ..., y n can now be calculated using traditional statistical analysis. The privacy leakage of the IDS rule can be expressed as the standard deviation σ α , error margin 2σ α or the 95% confidence interval ±2σ α of the IDS rule. This gives an indication of the expected precision of the IDS rule. Another useful metric, is to consider the worst-case information leakage denoted as L max Both of these can be useful in statistical analyses, in addition to the standard deviation. Furthermore, the privacy leakage can be calculated as π L R = L R · I R , where I R is the privacy impact estimated by the data controller.
F. Sample Standard Deviation of Entropy σ α 1) Normal Distribution: Assuming that the probability distribution of alarms can be approximated using a Normal distribution, then the standard deviation can be calculated using the second norm.
Assume that the IDS generates a sample of n IDS alarms (y 1 , y 2 , ..., y N ). Each alarm y i contains payload or other potentially privacy leaking elements or attributes from the IDS alarms generated by an IDS rule R. The sample standard deviation of the entropy of the elements can then be expressed as: The general properties of the variance of entropy measurements σ 2 α will fulfill the same requirements as the standard deviation of entropy measurements. However, the standard deviation is considered more appropriate, since it operates with the same unit of measure as the entropy.
2) Laplacian Distribution: An alternative distribution that during the experiment was shown to fit the data well, is the Laplacian (or double exponential) distribution. The Laplacian standard deviation, denoted as σ L α is based the L 1 norm (or Manhattan distance), and can be expressed as the sum of absolute deviations: A well known advantage with σ L α , is that it will be less influenced by outliers in the tail of the PDFs than the standard deviation of the Normal distribution.
The standard deviation of normalised entropy is a measure of the relative information leakage from an IDS rule, under the assumption that it detects only one nonmutating attack vector. If an IDS rule detects the attack vector perfectly without any false alarms, then the entropy of the IDS alarms will always be the same, and σ α = 0. If the IDS alarm is precise at detecting the attack, then only a few bits of information will vary between IDS alarms. This means that all alarms will have similar entropy with low standard deviation and therefore also low information leakage. However if the IDS rule also has a significant amount of false alarms, or gets entropy from other sources then the entropy variance, and therefore also the information leakage from the IDS rule, will increase.

G. Aggregating σ α
This subsection shows how the standard deviation of entropy metric can be aggregated for a set of IDS rules. Assume that an IDS uses a rule set denoted as R all with m IDS rules R all = {R 1 , R 2 , ..., R m }. Each IDS rule R i matches independently a set of N i IDS alarms: .., m where the number of IDS alarms N i typically will vary between IDS rules. Furthermore, assume that the IDS alarms are independent and non-overlapping, i.e. Y i ∩Y j = ∅ for i = j. This means that all Assume that an IDS rule R i has entropy standard deviation denoted as σ i and resulting standard deviation denoted as σ all . The aggregated metric should furthermore fulfill the following criteria in order to provide meaningful aggregation: C1 If all IDS rules have the same standard deviation, say σ i , then σ all should also be the same, i.e. σ all = σ i . C2 The resulting entropy standard deviation should be weighted according to how many alarms that trigger on a given IDS rule R i . Each IDS rule should be assessed individually, in the same way as each underlying vulnerability should be assessed individually. This means that a weighted average, weighted by number of alarms from each IDS rule, can be used as aggregation function for σ all , i.e: This function fulfills criterion C1, since the resulting average weighted sum is the same if σ i is the same for all IDS rules R i and it fulfills C2 by weighting the standard deviation against number of IDS alarms.

H. IDS Rules Detecting Several Attack Vectors
A significant part of the IDS rules will detect more than one attack vector, as illustrated in Figure VI.1. The data set used in this paper has 47% of the IDS rules with more than one attack vector. An earlier preliminary experiment at a commercial MSS provider shows even higher percentage (65%). An indication of an IDS rule that detects several attack vectors, is that the entropy probability distribution is multimodal. Figure  required to make the metric incentive compatible 4 . The details of this can be ignored for now, since this will be discussed in Section V-D. Each attack vector cluster corresponds to a different SIP service provider. A clustering algorithm is needed to identify each underlying attack vector for multi-modal distributions. Each individual cluster will in this case represent an attack vector, which behaves in a similar way as a non-perfect IDS rule described in Section IV-C. This means that the privacy leakage of each attack vector cluster can be calculated as the entropy standard deviation over all samples belonging to the cluster, and the resulting privacy leakage for the IDS rule can be calculated by aggregating the data over all IDS rules in the cluster using Equation IV.26.

I. How to Perform the Clustering
There are two main types of clustering algorithms: hard clustering and soft clustering. Hard clustering algorithms assign each sample to a given cluster. Examples of a hard clustering algorithm is the popular k-means and k-medians algorithms [25,4]. Hard clustering is however not appropriate for clustering the IDS rules, since it cuts off the samples at the tail of the distribution where two distributions overlap. This will give a bias towards lower entropy standard deviation than can be expected.
Soft clustering is then a better approach, since it assigns the probability that each sample belongs to a given cluster, instead of assigning each sample to a given cluster. A commonly used soft clustering technique is the Expectation Maximisation (EM) algorithm [8]. This soft-clustering method provides a Maximum Likelihood estimate of the underlying data distribution as a mixture of assumed probability distributions. The EM-algorithm is basically a two-step hill-climbing technique where the first step (E-step) calculates the expectation of the log-likelihood using the current estimate of the parameters of the underlying probability distributions. The second step (Mstep) computes the parameters that maximise the expected loglikelihood identified during the E-step.
There are however some drawbacks with the EM-algorithm. It is prone to get stuck in local minima, which means that it is sensitive to the initial cluster parameters. We use the cluster centers identified by k-means, since this is a generally recommended method of initialising the cluster centers 5 . Another issue is the selection of number of clusters. Too many clusters may cause EM to overfit the data, whereas too few clusters may give a poor representation of the distribution of the samples.
It is commonly assumed that the underlying probability distribution either is a mixture of Gaussian or Laplacian probability density functions. Both outliers and skewedness have been found to be significant during the experimental analysis in Section VI. We have therefore decided to model the probability distribution as a mixture of Laplacian probability density functions using the method proposed in [6]. This method is based on order statistics (uses a weighted median instead of the mean), and is therefore more robust against outliers and skewedness than using a Gaussian mixture [6]. The remainder of this section highlights the necessary theory and notation to understand how we have implemented the Laplacian mixture based clustering.

J. Laplacian Mixture Model
This section defines the general notation, which is based on the well-known theory of learning finite mixture models [2,13]. Furthermore, the Laplacian Mixture Model used here, is based on [6]. Our implementation is simplified compared to the original solution, since only univariate clustering is needed. Let H R be a random variable representing the IDS alarm entropies of an IDS rule R, with H α representing one particular outcome of H R . This random variable is expressed as: where β 1 , ..., β K are the mixing probabilities, each θ k is the set of parameters defining the k-th component of the mixture and Θ = {θ 1 , ..., θ K , β 1 , ..., β K } is the complete set of parameters that define the mixture. Being probabilities, β k must satisfy β k ≥ 0 and K k=1 β k = 1. It is assumed that all the components of the mixture are Laplacian distributions The Laplacian distribution is defined as: where H α (y i ) is the entropy of the IDS alarm y i , λ k > 0 is the scale parameter andμ k is the median for mixture component θ k . In the remainder, assume the shorthand notation that L α,i,k = L (H α (y i )|θ k ).

K. EM-Algorithm for Laplacian Mixture Model
The implementation of the EM-algorithm is based on [6,13]. Assume that the EM-algorithm is performing cluster analysis on a sample of N ordered entropy values These entropy values are calculated over the IDS alarms y 1 , y 2 , ..., y N generated by an IDS rule R. The Expectation Maximisation algorithm for the Laplacian Mixture Model then consists of two steps that are iterated until convergence is detected: E-step: calculate the conditional expectation of the complete log-likelihood M-step: estimate new model parameters θ k = (μ k , λ k ) and weights β k that maximise the log-likelihood log(L α,i,k ) of the model: where the algorithm to calculate the weighted median for a given cluster k, according to [6], is described in Algorithm 1.
else if q i = 1 2 q N then 12: return H α (y i ) 13: end if 14: end for 15: end function The algorithm uses the Minimum Message Length (MML) as stop criterion [40], assuming one-dimensional data. We do not go into details on the MML criterion and just present the implemented solution here. The detailed derivation of the MML criterion used can be found in [13].
The last term of Equation IV.33 is derived from the fact that the minimum of the M M L criterion over Θ can be obtained by using the negative maximum of the log-likelihood (the last term), since (IV.34) The algorithm stops when the difference in MML length between two iterations is less than M M L = 1 × 10 −4 . In addition to the MML criterion, the implementation of the EM algorithm requires at least 40 iterations to converge initially, and at least 20 iterations to converge after modifications of the cluster definitions. This is to avoid accidentally hitting a local MML minimum before convergence has occurred.

L. Determining the Optimal Number of Clusters k
We initially tested the method for estimating the number of components in [13]. This method worked for nice continuous distributions, however it did not work equally well for for noisy or a mixture containing binomial distributions, since the EM-algorithm then easily got stuck in local modes. Overfitting was also a significant problem for binomial distributions.
Furthermore, to judge whether a cluster should be interpreted as an attack vector or not typically requires that the data controller does some investigation of the IDS alarms. This means that some degree of manual intervention typically will be required during the clustering to assert obvious clusters that the clustering algorithm has missed or delete clusters where overfitting occurs. A typical example of overfitting is where several components with the same median are used to represent a given cluster. Another example is for skewed distributions, where the EM attempts to fit the skewed curve by overfitting the data.
We implemented a simple user interface for managing the clusters. It supports configuration of the initial number of clusters k as well as managing the model definition Θ after the initial configuration. The program also supports selecting type of entropy data and IDS rule to analyse from the datasets. The user interface for managing the clustering consists of the following functions: setcl(k,μ k ) Assert that the cluster number k has a mode at µ k . delcl(clusterlist) Delete clusters at index clusterlist. Deleted clusters are marked with θ k = (µ k = 0, ρ k = 0, β = 0).

pickcl()
Pick the cluster to be asserted by clicking the mouse at the position to be asserted in the histogram showing the frequency distribution of the IDS alarm entropies. If there are no clusters that are marked as deleted, then the least significant cluster (with lowest β k ) will be chosen. After having modified the clusters, the EM-algorithm continues by typing the cont command in the debugger. When the data controller is satisfied with the cluster definition, typing cont without modifying the cluster causes the algorithm to finish and print out the calculated privacy leakage for each cluster and also the aggregated privacy leakage for the IDS rule R.

M. Calculating the Privacy Leakage for Clusters
The privacy leakage for the identified clusters is calculated after the data controller has asserted that the relevant clusters have been identified and that the EM-algorithm subsequently has converged. All probability mass is then assigned to the clusters, which means that the privacy leakage can be calculated for the given IDS rule R.
First, the model Θ will in itself give an indication of the privacy leakage in the form of the entropy standard deviation of the Laplacian function L (H α (y i )|θ k ) for a given cluster k. It is a well known fact that this can be calculated from the scale parameter λ k for a Laplacian distribution as σ L k = √ 2λ k . However to be able to aggregate the entropy standard deviation over all clusters, the relative proportion of the samples for a given cluster θ k must be estimated, which is exactly what β k indicates. This means that the resulting entropy standard deviation for the IDS rule R can be calculated as the weighted average using Equation IV.26, substituting N i with β k : A disadvantage by using σ L k , is that this only will be correct if the model fits the data reasonably well. This may be true in some cases, however the sample distributions in the experiments do in several cases deviate significantly from the model due to outliers, heavy tails or noise. In these cases, it will be more correct to have a measure of σ α that is based on the underlying samples H α (y i ) weighted according to the conditional expectation w i,k of the model distributions defined by Θ, so that the weighted entropy is described by w i,k H α (y i ). This means that the model distributions is used to specify how the samples are divided between the clusters, instead of defining the clusters directly. The mean value of the cluster entropies for cluster k can then be expressed as: 36) and the Normal standard deviation can be expressed in a similar way as: (IV.37) Furthermore, the Laplacian standard deviation, based on the L 1 norm, can be expressed in terms of the conditional expectation w i,k and the median of the mixture component µ k as: The resulting aggregated entropy standard deviation for the IDS rule R can in both these cases be calculated from Equation IV.35 by substituting the relevant standard deviation into the equation. The clustering analysis tool prints out both the individual standard deviations per cluster as well as the resulting standard deviation for the IDS rule based on both the standard deviation of the model σ L R , Normal standard deviation σ k and Laplacian standard deviation σ L k . It is useful to compare these, since a large deviation between σ L R and the other standard deviations indicate a poor model fit, which may or may not be relevant depending on examination of the underlying data.
One can for example expect good model fit for IDS rules with some Gaussian or Laplacian noise, since this is close to the expected model of privacy leakage. However very noisy rules that match random traffic will get a poor model fit. An example of this is the IDS rule 1:1394000 in our experiments that detects random traffic. It has a standard deviation over all data of 6.7 for both Normal and Laplacian standard deviation, but only a model standard deviation of σ L 1:1394000 =1,44 . In such cases the standard deviation of the model σ L R will not be usable. Another example is if σ k is significantly larger than σ L k , then σ k may be unduly influenced by outliers, which means that σ L k would be the more robust estimate. In general, the Laplacian standard deviation can be expected to give the most conservative estimate, which is least influenced by skewedness and outliers.

N. Summary of EM-based Clustering
The Laplacian Mixture Model is implemented using the EM-algorithm. A semiautomatic process is used to identify the underlying clusters in the IDS alarms. The standard deviation of entropy metric is then calculated for each cluster and also the aggregated metric for the entire IDS rule. A possible attack on the clustering method, is an overfitting attack where a MSS provider decides to shirk by deliberately overfitting the attack vectors, by asserting too many clusters during the clustering process. It is therefore important that the role as data controller is separate from the role as security manager, and also that external quality assurance entities like certification organisations oversee the operation, to ensure that it is not overly privacy invasive. It must be emphasised that the objective not necessarily is to match the underlying probability distribution as closely as possible. The objective is rather to identify any likely attack vectors, and distribute the samples between these. The EM algorithm does this reasonably well.
The EM-based clustering generalises the privacy leakage metric to work for IDS rules that detect more than one attack vector. This generalisation is necessary, since our experiments have shown that a significant amount of all IDS rules trigger on more than one underlying attack vector. An advantage with this generalisation, is that it avoids the incentive incompatibility of the single cluster metric, which would encourage a shirking MSS provider to cheat by splitting up IDS rules into smaller IDS rules detecting a single attack vector.

V. DETAILED ANALYSIS OF σ α
This section does a more thorough investigation of the standard deviation of entropy metric σ α . The objective of this discussion is to do an analysis of the convergence speed required to reliably detect random uniform input data as a function of the data length. It is expected that random uniform input data converges towards zero entropy standard deviation for a sufficiently long data series. This convergence speed is an important decision factor for the selection of entropy algorithm and symbol definition, since the IDS alarm entropies are calculated over a limited number of IDS alarms. Furthermore, it is discussed which metric and symbol definition that works best for distinguishing between plaintext and encrypted data. This analysis shows which entropy type (Min-or Shannon entropy) and symbol size (bit or octet) that is best for calculating privacy leakage in IDS rules.

A. Entropy Calculation
There are at least three obvious ways of selecting the symbol space that is used to calculate the entropies: 1) Define the payload of the IDS alarm as the symbol, i.e. calculate the inter-alarm entropy; 2) Use binary entropy, i.e. the intra-alarm entropy as described in Section V-A; 3) Use octets, i.e. 8-bit words, which commonly are used to define the character set in computer systems. Other word sizes are possible, however these are considered the most common and interesting ones for our purpose. Each of these symbol definitions have their advantages and disadvantages, and it is important to note that the entropy values calculated from each of these definitions typically will be different. It has already been shown that the intra-alarm entropy calculated from bit-entropy is different from the interalarm entropy by a constant value. Furthermore, the interalarm entropy is not possible to use, since it can not be used to calculate the standard deviation of entropy.
Bit-entropy was used to develop the Equation IV.20, since it is the easiest way to develop the theory for the privacy leakage metric. The entropy standard deviation formula is however not dependent on any particular symbol definition, as long as the symbol definition ensures that the entropy standard deviation in the worst case, i.e. for random, uniform data, can be measured to be sufficiently close to zero for encrypted traffic. It is assumed that σ α converges towards zero for random, uniform data as a function of input data length, however the convergence speed is unknown and must be investigated. It can furthermore be observed that for a perfect encryption scheme that is approximated by random uniform data, the symbol definition does not matter, since random uniform data does not leak any information. This means that if the objective is to purely detect whether the information conveyed is encrypted or not, then the entropy scheme with fastest convergence speed may make sense to use.
This means that the minimum length of data required to reliably detect that random uniform data has zero variance (i.e. speed of convergence) is an important design factor that this metric relies on. It can be expected that different entropy metrics will have different convergence speed. In particular, can Min-entropy be expected to converge more slowly, since it only considers the maximum symbol occurrence probability, and not a weighted sum of all symbol occurrence probabilities, as Shannon entropy does.

B. Entropy Bias of Finite Length Encrypted Data
A question that needs to be investigated, is therefore how different entropy standard deviation metrics σ α (Shannonor Min-entropy) respond to random uniform data strings of varying length, and also how it is influenced by the symbol width, i.e. whether bit-entropy or octet-based entropy is used. The reason for this, as discussed in Subsection IV-F2, is that the metric shall be able to measure privacy leakage sufficiently close to zero in the following three cases: 1) For a perfect model IDS rule R P which detects and displays one or more non-changing attack vectors perfectly; 2) for anonymised IDS alarms from the IDS rule; 3) as a limit case for encrypted (e.g. pseudonymised) IDS alarms from the IDS rule, as the number of bits n in the IDS alarm goes towards infinity. The entropy standard deviation bias for finite length encrypted data, denoted as σ bias α , can be analysed by simulating the response function of σ bias α as a function of number of bits of data. The simulation is based on a set of Monte-Carlo experiments, one for each octet of data. Each standard deviation is the average of an ensemble of 10000 experiments. Bit-length is calculated for each octet as eight times the octet length, in order to have comparable x-axis values for bit-and octet-based data. The experiments are based on simulations using random uniform data selection, which means that a Normal distribution can be assumed. Figure V.1 shows a log-log plot of the entropy standard deviations. The bit-entropies both appear to be log-linear, which means that the bias for detecting a perfectly encrypted IDS alarm with length n bits can be expressed as log 2 (σ bias α ) = log 2 (γ α + ψ α n), where γ α is the offset and ψ α is the slope of the log-log scale. This gives σ bias α = 2 γα n ψα , where 2 γα is constant. The slope can be calculated from the experimental data, which shows that that ψ 1 = −1.005 ≈ −1  for Shannon bit-entropy and ψ ∞ = −0.479 ≈ − 1 2 for Minentropy. This means that σ bias 1 ≈ 2 γ 1 n , whereas σ bias ∞ ≈ 2 γ∞ √ n , which means that Shannon bit-entropy converges by an order of O(n − 1 2 ) faster towards zero than Min-entropy 6 . Shannon bit-entropy has initially 2.7 times less bias than Min-entropy for perfectly encrypted (i.e. random uniform) data.
The octet-based entropies perform very poorly during the initial transient phase, but are then stabilised on a slope similar to the respective bit-entropy slopes, as shown in Figure  V.1. This means that there is a significant, but approximately constant, difference between the bit-and octet-based metrics after the initial transient phase. Shannon bit-entropy entropy ends up with a precision 143 times better than Shannon octetentropy after 80 kbit. The difference in precision between bitand octet-based Min-entropy is smaller, only 25 times.
A nice property is that the bias is systematic, which means that the entropy standard deviation calculations may be able to compensate for it by subtracting the expected bias from the entropy standard deviation, given that the number of samples (IDS alarms) is sufficiently large. However, this only makes sense if it is known that the data are encrypted. Since this in general is not known for the payload from IDS rules, and it will be wrong to correct for this bias for nonencrypted data, this means that the metric with fastest convergence speed is preferable.
It must also be noted that bit-based entropies (both Shannon Min-entropy) are computationally less complex than octetbased Shannon entropy, which needs to calculate the weighted logarithm expression for each symbol in an octet. Counting the number of bits set to one in an octet or word (list of octets) can be done by calculating the Hamming weight, which is implemented in hardware on most modern Intel or AMD processors using the popcnt (population count) operator.  This opens up for efficient implementations of bit-entropy calculations for up to 64 bits word chunks [7], which is more efficient than iterating to calculate the octet frequencies, as required by octet-based entropies.

C. Entropy Standard Deviation Difference between Encrypted and Plaintext data
Another foundational scenario that must be investigated, is how well the proposed entropy algorithms and symbol definitions distinguish between encrypted and plaintext information. The entire theory behind σ α hinges on the assumption that there is a difference in entropy standard deviation between plaintext and as a limit case encrypted information. To determine whether this assumption is true or not, and which entropy configuration that works best, we set up another Monte-Carlo simulation, this time comparing the entropy standard deviation of plaintext data with the entropy standard deviation of random uniform data for both Min-and Shannon-entropy, using both bit and octet-based symbol definition.
The experiment configuration calculates the average and the 95% confidence band (±2σ) from an ensemble of 10000 experiments. Each experiment calculates the standard deviation over 50 samples for varying input data length in bits, assuming that this is the smallest number of samples that in practice will be used to reliably distinguish between encrypted and plaintext data. If less samples are used per experiment, then the confidence band will widen out, meaning that longer payload will be needed to reliably distinguish between encrypted and plaintext data. There is in other words a tradeoff between the payload length and the number of samples required to reliably detect encrypted content.
Random uniform data was measured in a similar way as the previous experiment. The plaintext data was extracted using randomly selected contiguous quotes from the Brown corpus [16], with varying data length in bits along the x-axis.  Figure V.2 shows the difference between σ α for plaintext and random data using bit-and octet-entropy respectively for varying input data lengths in bits. Shannon bit-entropy is the metric that distinguishes best between cleartext and encrypted data for data lengths greater than 400 bits (50 bytes). Figure V.4 shows that Shannon octet entropy is able to distinguish reliably between cleartext and encrypted data over a sample of 50 IDS alarms within a 95% confidence interval from 5 octets (40 bits) and onwards, despite the poor convergence properties for random traffic in the range [5,131] octets.
However, due to the slightly hourglassed shape of the entropy difference, it is not possible to achieve any larger precision between 40 and 3000 bits (375 bytes), unless the sample size is increased to narrow the confidence band sufficiently. Plaintext data is 11 times larger than encrypted data  at 5 octets (40 bits), whereas at around 128 octets (1024 bits), is down to 1.8 times larger than the encrypted data, before the random data reaches its knee point where the octet-based metric again improves.
Shannon bit-entropy is more well-behaved than Shannon octet entropy, in that the difference in entropy seems to be a strictly convex function, as opposed to the octet-based entropies. Min-bit-entropy also seems to be well behaved, and has the advantage that the 95% confidence band for Min-bitentropy is narrower than for Shannon bit-entropy. However it is still overall a much poorer measure of entropy difference than Shannon bit-entropy, since it requires at least 6000 bits (750 octets) to reliably distinguish between plaintext and encrypted data. Octet-based Min-entropy, , as shown in Figure V.3, behaves extremely poorly, and is not usable for distinguishing between plaintext and encrypted text.
Overall, this strengthens the conclusion that Shannon entropy is the best metric, regardless of symbol definition since it converges faster than the other alternatives and it distinguishes better between cleartext and encrypted data as long as the payload is longer than the minimum threshold of 5 octets for octet-based entropy or 50 octets for bit-entropy for minimum 50 samples.

D. Payload Length Correction for Bit-entropy
A deficiency with the entropy standard deviation metrics, is that they decrease as the data length increases. This is the desired behaviour for random uniform data, however it is not necessarily desirable for plaintext data, since this means that the metric can not be considered incentive compatible: it will then pay off for an adversary to match as large plaintext data packets as possible, since this in effect reduces the measured information leakage. An obvious way to mitigate this problem might be to multiply the entropy values with the length n i = |y i | of the IDS alarm, i.e. n i H α (y i ), and then take the standard deviation of the length corrected entropy values. This  correction will however be too strong, since the expected bias for random uniform data of length n i then would be constant: σ bias 1 ≈ γ1ni ni = γ 1 . This means that the metric would not converge to zero for encrypted traffic.
This problem can be mitigated by multiplying the entropy values with the square root of the payload length n i . This means that the length corrected entropy values for bit-entropy can be described as H α (y i ) = √ n i H α (y i ).
The length-corrected privacy leakage metric π L R , can be expressed as: whereμ k is the median from the LMM. The payload length corrected Shannon bit-entropy standard deviation function is shown in Figure V.5. It can be observed that the term √ n i H α (y i ) essentially reduces the convergence speed to detect random uniform traffic for Shannon entropy by a factor of O(n − 1 2 ) to σ bias 1 ≈ γ1 √ n , similar to Min-entropy originally. However random uniform traffic will still converge towards 0, as required, although somewhat more slowly. Furthermore, the measured privacy leakage for plaintext data will now increase exponentially as a function of payload length, instead of decreasing, as long as the payload length is larger than the required 100 bytes (800 bits). These modifications avoids the incentive incompatibility for Shannon bit-entropy, since the metric now increases with increasing payload length.

E. Payload Length Correction for Shannon Octet-based Entropy
Shannon octet-based entropy has the same convergence speed as Min-entropy after an initial transient phase, as shown in Figure V.1. This means that √ n i can be used as a length correction factor also for Shannon octet-entropy for large entropy values (¿200 octets or 1600 bits), to ensure that the measured privacy leakage increases with the payload length for plaintext data, and decreases with the payload length for random data. This length correction does however not work well below 200 octets, since Shannon octet entropy initially rises quicly until a knee point at 50 bits for plaintext data and 150 bits for random data, and then starts falling, as shown in Figure V.4. It is desirable to reduce the effect of this knee point, in order to have an easier functional relationship between plaintext and random data, so that a fixed threshold can be used to distinguish between cleartext and random traffic. Introducing an additional length correction factor of 1 log2(ni) where n i is the length of the payload y i can be used to reduce the effect of this knee point, as shown in Figure V.6. This means that the payload length correction function for Shannon octet-based entropy is H α (y i ) = √ ni log2(ni) . Payload length corrected Shannon octet-entropy standard deviation as a function of payload length is shown in Figure  V.6. The initial slightly hour-glassed shape of the standard deviation functions means that the octet-based function despite the payload correction still is reduced slightly for plaintext data between 48 and 800 bits (5 and 100 bytes) payload length. This means that the metric is not entirely incentive compatible in this range, since it is slightly decreasing for plaintext istead of increasing, however the deviation is not very large. The octetbased metric is however incentive compatible beyond 100 bytes, since the metric then increases with increasing payload length for plaintext data. An advantage with Shannon octetentropy, is that it is able to detect whether short strings of data is encrypted or cleartext, for example from pseudonymisation schemes, assuming that the data is at least 5 octets and encrypted using a perfect encryption scheme.
Another advantage with the payload length corrected entropy metrics, is that a fixed threshold can be used to distinguish between plaintext and random data, regardless of payload length for a sufficiently large sample (minimum 50 samples). For Shannon bit-entropy this threshold is 0.028, whereas Shannon octet-entropy has a threshold of 0.14 (five times larger).
It must be noted that it is possible to construct data that falls between the two example entropies used here. The first example that comes to mind, is partially encrypted IDS alarms, where for example a header part is nonencrypted and a payload part is encrypted or coded (e.g. compressed). In these cases, some IDS alarms would be interpreted as encrypted, whereas others may be interpreted as nonencrypted. However, an advantage with the octet-based metric, is that relatively few octets are required to calculate it, which means that the header and remaining payload in such cases can be calculated separately.

F. Standard Deviation of Entropy for Base64-encoded Data
Another interesting case is how σ α copes with quoting techniques used to transfer binary data on transport protocols that are not 8-bit clean. A common encoding technique is Base64-encoding, which can be used to transfer binary information in SMTP and XML-based formats like HTML or SOAP. Figure V.7 shows the standard deviation of Shannon octet-entropy for plaintext and Base64 encoded random data. The Base64-encoding adds redundancy, which means that the encoded data is closer to plaintext data. This can be seen from the Figure, since the confidence bands now overlap for less than 800 bit (100 bytes). However, for longer input data, the Base64-encoded random data behaves in a similar way like plain random data, since the standard deviation goes towards 0.
This means that at least 100 bytes are required to reliably distinguish between Base64-encoded random data and plaintext data. If it is known that the information is Base64encoded, then it will be possible to decode the information before the entropy is calculated. This may be useful if the information leakage of shorter Base64-encoded strings are being measured. However this decoding will add additional parsing overhead, which may not be desirable from a performance perspective. This is however avoidable, as long as the payload is larger than 100 bytes as shown above.

G. Semantic Information of Symbols
The symbol definition for the entropy algorithms will also need to take into account the semantic information that symbols convey. The definition of bytes (or more precisely octets) is in particular important for computer systems, since this is used to define the basic character set used for communicating both text and binary codes. Octet-based symbol definition is also important for many of the attack vectors discussed in the introduction. Buffer overflow attacks for example frequently use the single octet NOP instruction (0x90 on Intel machines) for the NOP sled. There also exist multi-octet NOP variants and other techniques for generating an obfuscated sled [1]. However for now consider single byte based NOP sleds, which are common, not the least because they are easier to exploit. Using this strategy means that the shellcode does not need to be placed on an exact 32-or 64 bits word boundary, as compilers typically enforce for normal programs [1].
The single-byte NOP sled (0x90) is a unique symbol for octet-based entropy, however for bit entropy, this represents the binary string 10010000, which has two out of eight bit set. The problem is that this value is not unique. There will in general be 8!/((8 − 2)! · 2!) = 28 different octets, where any combination of these can produce the same two-bit based entropy value as this NOP opcode. In fact, bit-entropy means that 256 different octet values are mapped down to only 9 different bit-entropies. Furthermore, whereas the octet entropy of a list of NOP opcodes will be zero, the bit-entropy will be greater than zero, except if all bits are '1' or '0'. The Shannon bit-entropy of the NOP sled is 0.81, which is very different from the octet-entropy (0). Furthermore, if one octet of information is changed, this means that somewhere between one and eight bits will change. There is in other words a less clear correlation between the change in information and change in entropy for bit-entropy than for octet-based entropy.
This means that octet-based entropy is closer to representing the meaning of the information being exchanged, and therefore should be the preferred symbol definition for the privacy metrics. The discussion above has also identified that the standard deviation of Shannon octet-entropy is the metric that overall has the best properties for distinguishing between cleartext and encrypted data, despite its poor convergence properties over part of the usable range. Octet-based entropy is furthermore able to uniquely identify that a sequence of the same octet has zero entropy, something bit-entropy does not identify. This means that Shannon octet-entropy will provide the largest possible difference in entropy between plaintext and strings consisting of sequences of the same character. Shannon octet-entropy is in other words a better privacy leakage metric than Shannon bit-entropy with better distinguishing capability according to our requirements and needs within the operating range. Min-entropy is not usable for our purpose.

VI. EXPERIMENTAL RESULTS
The experimental results are based on IDS alarms from my own home network between 2009 and 2011. Some of the IDS alarms are also from the KDD-Cup'99 data set. We included the 32 most noisy IDS rules with at least 50 IDS alarms per cluster in the measurements. The threshold of 50 IDS alarms per cluster is chosen to stay within the 95% confidence bands discussed in the simulations in Section V-C. This is a limited data set that will not reflect the privacy leakage measured at a professional MSS provider doing large-scale measurements. The main difference that can be expected from a larger MSS provider, is that there would be a greater selection of IDS alarms with more than 50 alarms per cluster, and that the number of attack clusters would be greater. Furthermore, a larger set of IDS alarms may be enabled by commercial MSS providers to counter for emerging threats that are not yet in the Snort VRT ruleset, which we used. Furthermore, traffic However, despite these deficiencies, there are also some advantages by using our own data. One of the main advantages, is that this allows for discussing the IDS rules that may be leaking private or confidential information in detail, something that it according to our experience would be difficult or impossible to do for a commercial MSS provider due to business confidentiality and repudiation concerns. We have attempted to get agreement for such measurements for commercial MSS providers, however this is only possible if the IDS ruleset is not revealed, which makes it difficult to discuss in a convincing way that the proposed privacy leakage metrics work as intended. More elaborate tests at a commercial MSS provider is therefore left as future work. We decided to use a privacy impact factor I = 1 to only show the information leakage part of the privacy leakage metrics.
The experiment includes an IDS rule that we created (sid:1:1394000) which tests the worst-case scenario from a privacy perspective. This is a threshold-based IDS rule that essentially samples every 10th packet from the network. This is intended to show the maximum value that the privacy metric typically is able to detect, which is useful to see how far away the IDS rules in the measurements are from a worstcase scenario.

A. Number of Attack Vectors
The number of attack vectors per IDS rule for the given experiment is summarised in Figure VI.1. For this experiment, 53% (17 rules) have one attack vector, 31% (10 rules) have two clusters identifying attack vectors, 13% (4 rules) have three clusters and 3% (1 rule) have 4 clusters identifying attack vectors. Please note that these numbers are specific to the given experiment. A preliminary experiment at a commercial MSS provider indicates that large-scale operations can expect the distribution to be shifted somewhat towards more attack vectors. It is in other words common that IDS rules may trigger on more than one attack vector, which means that clustering must be used to calculate the entropy of each underlying attack vector. In all these cases, the Laplacian standard deviation will give a more realistic estimate of the privacy leakage than the Normal standard deviation. The Laplacian standard deviation is only significantly larger than the Normal standard deviation for SID 1:402 ICMP Destination Port unreachable. This IDS rule has a left skewed noisy distribution, with several peaks reflecting the servers that were attempted contacted, but did not respond. We interpreted this as one cluster, since the failed services strictly speaking cannot be considered attack vectors. The median for this IDS rule (at 7.5) deviates somewhat from the mean (at 7.2), which gives more weight to the leftmost peaks for the Laplacian standard deviation than the Normal standard deviation does in this case, causing the Laplacian standard deviation to be larger than the Normal standard deviation. This is a pathological case where the normal standard deviation may give a better estimate than the Laplacian standard deviation. However, overall the Laplacian standard deviation σ L 1 should be used to calculate the privacy leakage metric, since this in most cases is the more robust statistic.

A. Measured Information Leakage
Figure VII.1 shows the measured privacy leakage for the experiment using length corrected standard deviation (Normal σ 1 and Laplacian σ L 1 ) of normalised Shannon octet-entropy as a function of Snort IDS rule. Further details can be found in Table I. This discussion is based on the Laplacian standard deviation, since the previous section shows that the Normal standard deviation has problems with outliers in the dataset. First, it can be observed that the metric works as expected for the extreme cases. The IDS rule that performs random sampling of payload (SID 1:1394000) has the highest privacy leakage. On the other hand, there also exist 5 IDS rules that are very precise at matching the attack vector, and behaves like the perfect model IDS rule R P with zero privacy leakage. IDS rules that fall into this category are attack vectors like SID 1:2050 SQL Version Overflow attempt, SID 1:2003 SQL Worm Propagation attempt, SID 105:2 BO traffic and SID 106:4 spp rpc decode preprocessor which detect amongst others incomplete RPC segments. All these IDS rules indicate possibly malicious activities, and are precise at detecting the attack. SID 1:382 which detects ICMP Echo requests (Ping) for Windows also behaves like a perfect IDS rule. It typically sends the alphabet in the payload.
There are furthermore 9 additional IDS rules with privacy leakage lower than the threshold of 0.14 for distinguishing between plaintext and encrypted traffic that was identified in Section V-D. Rules in this category can be considered to have insignificant privacy leakage, since it is not distinguishable from encrypted traffic. These include ICMP rules matching ICMP Echo Request and Reply for various platforms (SIDs 1:384, 1:408 and 1:368) and ICMP traceroute (SID 1:385). These ICMP protocols are part of the TCP/IP protocol suite and are benign in themselves, however the Ping protocol is also frequently used for malicious activities like Denial of Service attacks or Ping scans. Furthermore pre-attack activities like portscanning (SIDs 122:1 and 122:3), and unauthorised inbound SIP calls (SID 1:11969) are potentially malicious activities that fall into this category. Last, SID 1:1437 detects download of Windows media files. This would normally be considered a benign activity, and it may also be concerning from a privacy perspective if this IDS rule is activated, since it could be used to monitor user activities. This rule detects download of Windows media files as two narrow clusters, where the upper cluster at an entropy close to 1 probably indicates download of the compressed media file. This is an example of a pathological case where the entropy standard deviation in itself, as an indirect measure of privacy leakage, does not match the perceived privacy leakage. The data controller may in this case consider whether the privacy impact I of this IDS rule should be increased.
The privacy leaking IDS rules can broadly be subdivided into two groups: IDS rules with large privacy leakage (σ L 1 > 1) and IDS rules with medium privacy leakage (σ L 1 ∈< 0.14, 1]). There are 13 IDS rules with medium privacy leakage. The most privacy leaking of these IDS rules, is SID 1:1394 "SHELLCODE x86 inc ecx NOP" which triggers on any packet that contains a sequence of 31 'A' characters (σ L 1 = 0.97). The problem is that this sometimes occurs in hexencoded URLs or hex-encoded data in web pages. It may also occur in non-compressed images, as well as for other protocols. This means that the rule most likely will trigger on a lot of random traffic, which is problematic from a privacy perspective.
Many of the rules with medium privacy leakage may be triggered by normal user behaviour, for example SID 1:486 ICMP Destination Unreachable, SID 1:402 ICMP Destination Port Unreachable and SID 1:399 ICMP Host unreachable. These can be problematic from a privacy perspective, since the ICMP error message often contains the payload of the original request, and these error messages can for example be triggered by high traffic volume (or DoS attacks) towards a server. This means that these ICMP messages essentially sample random user traffic. There are also other IDS rules in this category that will sample random traffic from users,  These may indicate attacks, but will in most cases probably be false alarms that essentially sample random user traffic, something that may be problematic from a privacy perspective. 1:1852 robots.txt access, which normally indicates indexing of a web server by a web crawler, also falls into this category. There are also some other attack rules with medium privacy leakage that do not target ICMP or web traffic. SID 128:4 detects non-SSH traffic on an SSH port, or a protocol mismatch (e.g. SSH1 traffic on an SSH2 port). This rule triggers on the initial key negotiation phase, where some information in the SSH protocol goes in cleartext. This can probably not be considered a significant primary source of privacy leakage, since no sensitive information is transferred in the packets. The data controller may consider reducing the privacy impact for this IDS rule. SID 1:12592 detects SMTP command injection attempts, that aims at exploiting a bug in the ClamAV antivirus system. The rule definition is a very simple regular expression which is likely to have false alarms. This rule may therefore be concerning from a privacy perspective, although it mostly triggered on spam. Rule 1:1463 triggers on IRC chat traffic, which also may be concerning from a privacy perspective. The reason for implementing this rule, is that IRC bots also often have been used to control botnets of compromised hosts. However, the rule does not check whether the traffic is benign or not.
There are four IDS rules with high privacy leakage, not including the test rule that samples random traffic. Three of these trigger on web traffic: SIDs 119:14, 119:15 and 1:1201. The most privacy leaking ordinary IDS rule (SID 119:14, σ L 1 = 3.49) triggers on non-standard character encodings in HTTP requests, which are getting increasingly common, especially after IANA allowed non-ASCII domain names. The second most privacy leaking IDS rule is SID 1:402 ICMP Destination Port Unreachable with σ L 1 = 2.73. This protocol typically copies the failed request in the ICMP message, and therefore samples random traffic requests. On third place is SID 1:1201 HTTP 403 Forbidden (σ L 1 = 1.77), which also is quite common also for benign traffic, for example on web sites referring to internal material that require subscription. On fourth place is SID 119:15 that tests for over-long URL's (σ L 1 = 1.02), something that frequently happens for blogs or search engines that use URL referencing. All of these rules may be problematic from a privacy perspective, since they in many cases will trigger on normal user behaviour. It is especially problematic if the IDS rules monitoring web services are set up in an uncritical way, so that these rules trigger for any web server accesses and not only for relevant web servers (e.g. the company's own web servers).
This discussion shows that the privacy leakage metric is able to distinguish between IDS rules that most likely may trigger on ordinary user activities, and therefore may be problematic from a privacy perspective, from the IDS rules that are precise at detecting the underlying attack vector, or that perform a very specific task without leaking any significant amount of data about user behaviour. However there were also two pathological cases where it may make sense to adjust the privacy impact, since using entropy as an indirect measure of privacy leakage not always will gives a true picture of whether the underlying information is sensitive from a privacy/confidentiality perspective or not. Overall, this demonstrates that the privacy leakage metric works as intended. However larger studies involving commercial MSS providers will be needed in the future to confirm these results.

B. The Effect of Anonymisation
The resulting privacy leakage over all IDS alarms in the experiment, weighted according to number of alarms, is 0.31. However, if the test IDS rule with SID 1:1394000 that samples random data is removed, then the resulting privacy leakage is reduced to 0.16. If all the IDS rules with high privacy leakage are removed, then the resulting leakage is reduced by 0.02 to 0.14.
Surprisingly, it is then more efficient to anonymise all ICMP Destination Host unreachable alarms, since there are many of them (631840) in the data set, and each of them has a significant measured privacy leakage (σ L 1 = 0.58). Anonymising ICMP Destination Host unreachable alarms would reduce the overall privacy leakage by 0.07 to 0.07. This can probably be done without reducing the usability for the security analyst significantly, since it still would be known which host that was attempted contacted from the IP-address element of the IDS alarm. SID 1:402 ICMP Destination Port unreachable also triggers quite often (32360 times) and has the second highest measured privacy leakage (σ L 1 = 2.73). Anonymising this rule reduces the privacy leakage by 0.02 to 0.05, and can probably also be done without reducing the possibility to do root cause analysis significantly, since the number of services running on a server normally is limited. Classification based on the EMclustering can if necessary be used to indicate which server that failed without revealing the original user request. These examples show that the total privacy leakage, calculated as the product of number of IDS alarms N R for the given rule R and the entropy standard deviation σ L 1,R , must be used as the optimisation criterion to reduce the overall privacy leakage. The total privacy leakage is calculated as L tot = N R σ L 1,R . Another IDS rule, that either benefits from anonymisation, alternatively by setting the privacy impact to zero, is SID 128:4 which detects ssh anomalies. This rule triggers quite often (306616 times) with σ L 1 = 0.27, which means that the overall privacy leakage can be reduced by 0.02 to 0.03 if this rule is anonymised. If the IDS rules with low privacy leakage, that are not relevant from a privacy perspective (all with privacy leakage less than 0.14, except SID 1:1437), are either anonymised or removed by setting the privacy impact to zero, then the resulting privacy leakage index is reduced from 0.03 to 0.011.
If the two IDS rules from the http inspect preprocessor with largest total leakage (SID 119:14 and 119:2) also are anonymised, then the measured privacy leakage is reduced to 0.005. This illustrates how a structured method can be used to reduce the privacy leakage of the IDS ruleset based on measured privacy leakage and number of IDS alarms. It is furthermore also clear that many of the IDS rules can be anonymised without significantly reducing the usability for the security analysts. Especially since the clustering model used to identify attack vectors in many cases can be used to help the security analysts in identifying the necessary properties of the underlying data without having to reveal the user payload.

VIII. RELATED WORKS
The research area of quantitative information flow based on information theory adds a comprehensive theoretical framework for analysing privacy leakage based on entropies [34,33]. Our research is based on this, and extends the theory to cover privacy leakage in IDS alarms. There is as far as we are aware of no other research that proposes a comprehensive model of privacy leakage in IDS alarms based on quantitative information flow analysis.
Quantitative information flow analysis that in a similar way uses information entropy has however been proposed used to derive an intrusion detection capability metric in [20]. This metric aims at modelling the uncertainty about the input given the IDS output. The uncertainty as it is termed in this paper is the same as the information leakage defined here based on [34], which in turn is based on the notion of mutual information from [32]. The IDS capability metric is defined as the mutual information between the IDS input and output to the entropy of the input: The numerator is the same as the information leakage defined in [34], however these data are normalised with respect to the entropy of the input data, something our model does not do. This model assumes that the input data H(X) is the labels (attack or not) from a labeled IDS test set, and the output data H(X|Y ) is the classification by the IDS, which also is different from our conceptual model of an IDS rule. It is from this clear that the proposed metric is different from the privacy leakage metric proposed here, since it assumes different input data, a different information model and normalises the indicator to the input data. However an interesting similarity is that the effect of false positives in Figure 3b) in this paper follows a similar falling exponential curve as Figure VII.1, as can be expected, since the false alarms here will increase the entropy up to the point where the classifier is not better than random decisions. However this paper does not make the connection to privacy leakage metrics for IDS rules.
There are also some similarities between the proposed approach and the concept of Differential Privacy in statistical databases [10,11,12]. Both methods use a Maximum Likelihood (ML) estimate, however the estimate is interpreted differently. Differential Privacy uses the ML estimate to indicate the aggregate value of underlying perturbed data, whereas we use the ML estimate as a measure of underlying attack vectors. Both methods use robust statistics (first norm) for calculating aggregated values. However, Differential Privacy typically adds Laplacian noise to hide individual elements of privacy sensitive information, whereas our privacy leakage metric works in the opposite way -assumed Laplacian noise from an IDS rule is used as an indication of IDS privacy leakage. So although there are similarities, our proposed metric is clearly different to Differential Privacy.
Entropy has previously been proposed as a measure of privacy [5,3]. Claude Shannon's seminal paper on information theory was the first publication where entropy was proposed to measure the level of ambiguity or equivocation in transferred information [32]. Min-entropy has been proposed as a metric of anonymity that in particular considers local aspects, i.e. the worst case scenario for the user [38]. The more general Rnyi entropy has been proposed as a metric of anonymity in [31,3]. Neither of these have used entropy to measure privacy leakage in IDS alarms.
The paper is also related to field of privacy-preserving intrusion detection systems [36,14,35,29,26,15], however neither of these solutions focus on privacy metrics.

IX. CONCLUSIONS
In this paper we propose an entropy-based privacy leakage metric founded on quantitative information flow analysis. An advantage is that this metric can be calculated based on already existing information in the IDS alarm database. From a privacy perspective, it provides a structured approach to identify which IDS rules that may be leaking sensitive information and also for handling such privacy leakages.
An advantage with the metric, is that it also is a measure of IDS rule precision. This is clearly desirable, since the objective is to tune the IDS ruleset to reduce the leakage of private or confidential information over time, for example through improving the precision of the IDS rule or by applying anonymisation techniques. This is also an advantage from a security perspective, since more precise IDS rules mean less effort spent on false alarm handling.
We have demonstrated that the proposed approach is feasible based on a set of real IDS alarms. It is furthermore shown that different entropy algorithms and ways to calculate the standard deviation have different strengths and weaknesses. Not surprisingly, the Laplacian standard deviation based on the L 1 norm provides the most robust statistic to avoid problems with outliers, a problem that has been shown to occur in the experimental data. The experiments have shown that Shannon octet-entropy is the best entropy metric with fastest convergence speed for reliably detecting encrypted traffic, and it is also the entropy metric that is is best at distinguishing between plaintext and encrypted traffic. It is also shown how the metric can avoid being incentive incompatible by taking into account the length of the input data.
The Laplacian Mixture Model of the underlying data will in itself be useful for classification purposes. If a given model of the data has been identified, then this can be used for subsequent classification of the underlying samples, for example to anonymise IDS alarms from data clusters that may contain sensitive information about user transactions, or to further classify the attack vectors of the IDS alarms, for example to detect Denial of Service attacks. The clustering can therefore be used as a post-processing step to modify the IDS alarms according to cluster, which means acting as a higher order IDS solution.
A possible attack on the clustering method, is an overfitting attack where a MSS provider decides to shirk by deliberately overfitting the attack vectors. The proposed method to avoid this, is to ensure separation of duties between privacy and security interests and also that third party certification organisations oversee the operation.
The proposed privacy leakage metric only measures the primary privacy leakage sources in IDS alarms. It does not consider secondary sources of information leakage, like correlation of different information sources. However, being able to measure the primary sources of privacy leakage in IDS alarms is at least an initial approach that can and should be considered before more elaborate analyses of the anonymity set are performed. Furthermore, the ability to verify that the anonymisation policies reduce measured information leakages means that policy verification, in the form of a privacy leakage gap analysis, will be possible in order to provide incremental reductions of privacy leakage in IDS alarms over time.
X. FUTURE WORK Future work includes doing comparative studies of the performance of different MSS providers from a privacy perspective. Adapting the privacy leakage metric to support anomalybased IDS is also left as future work. This will amongst others require subdivision of the alarms, for example based on service etc., to avoid that the entropy space becomes too crowded by attack vectors.
Investigating possible secondary privacy leakages that may occur due to inference or cross correlation between different information sources both within the IDS alarm and outside is also left as future research. This would require taking the privacy leakage metrics and evaluation even further in order to evaluate the anonymity set that can be expected for private or sensitive information, using metrics like differential privacy [10,11,12], k-anonymity [9], or l-diversity [24].