<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Enforcing Mobile Application Security Through Probabilistic Contracts</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Fabio Martinelli</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ilaria Matteucci</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andrea Saracino</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Daniele Sgandurra</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Dipartimento di Ingegneria dell'Informazione, Universita` di Pisa</institution>
          ,
          <addr-line>Pisa</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Istituto di Informatica e Telematica, Consiglio Nazionale delle Ricerche</institution>
          ,
          <addr-line>Pisa</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Security for mobile devices is a problem of capital importance, especially due to new threats coming from malicious applications. Though several security solutions have already been proposed, security requirements have been always considered as binary: allow or deny. We argue that a more realistic vision of security can be given using probabilistic and quantitative requirements. In this paper, we introduce a probabilistic description of the behavior of an application that a user is going to execute. We also allow the definition of finer grained user security requirements, by introducing probabilistic clause modifiers. Later, we present a probabilistic version of the Security-by-Contract framework to guarantee probabilistic security requirements.</p>
      </abstract>
      <kwd-group>
        <kwd>Probabilistic Contract</kwd>
        <kwd>Probabilistic Policy Compliance</kwd>
        <kwd>Contract-based Security approaches</kwd>
        <kwd>Run-Time Enforcement</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>New generation mobile devices (e.g., smartphones and tablets) are becoming
day-byday more powerful and popular. The growth in computing power, ubiquitousness and
capabilities of these devices has been paralleled by the growth of available applications,
specifically developed for smartphones and tablets. However, these applications may
be not completely secure. In fact, malicious developers strive to design and deliver
applications that may damage both users and devices. In particular some applications
may hide a Trojan horse that, even if it looks unharmful, in background it performs
malicious actions that the users did not expect to happen.</p>
      <p>The current security model, which rules (i) if an application can be safely installed
on the device, (ii) what kind of actions the application may execute once installed,
still suffers from several weaknesses, in particular in its capacity of expressing proper
contracts. Semantics of current security models is too na¨ıve since it is either based upon
trust relationships or upon statements of purpose. In the first case, users accept to run
an application if they trust the provider. In the second one, providers state the security
relevant actions performed by an application and it is up to the users to decide whether
run the application if they consider these operations safe. In the former case the trust
level of the trusted entity also determines the code privileges, essentially relegating an
application into the “all or nothing” policy, while in the latter case the semantics is
too-coarse grained (e.g., Android permissions) or hardly usable. For example, in the
Android system, security relevant actions are declared through permissions, which are
difficult to understand for average users.</p>
      <p>
        In this paper, we introduce probability aspects into the workflow of a contract-based
approach developed for mobile devices: the Security-by Contract [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] (S C) framework.
This approach integrates several security techniques to build a chain of trust, which, in
the end, ensures that the downloaded application will execute only security actions that
are allowed by the user’s policy. To this end, we introduce a probabilistic description
of the behavior of an application and a more expressive version of the user’s security
requirements. Indeed, the current models only permit the definition of a set of allowed
actions, e.g., the Android permission system (first box of Figure 1). More expressive
policies which take in account a possible action history are modelled through automata
that represent allowed executions.
We propose a probabilistic automata-based model that enables the developers to
define more expressive contracts through probabilistic clauses, e.g., how often a
securityrelevant action may happen. The same expressiveness is given to users to specify
security policies. Since we include probabilistic clauses in the specification of contracts and
policies, the security mechanisms involved into the workflows of S C has to be
redefined. Hence, we present a new workflow for the S C framework in which each module
is updated to support probabilistic functions. The advantage of using probabilities is the
possibility of describing more realistic usage scenarios for an application. In fact, many
applications depend on user inputs or context information and it is difficult to define
realistic policies based upon boolean conditions only. In these models, all the possible
execution paths are considered legal. Hence, a low-probability operation is considered
valid even if performed several times. For this reason, we introduce probabilities in the
definition of security clauses to define more fine-grained contracts and policies. These
descriptions better fit real application use cases and can be defined without alteration of
the Security-By-Contract-with-Trust workflow.
      </p>
      <p>The paper is structured as follows. Section 2 introduces the main concepts of
contractbased approaches and briefly recalls the Security-by-Contract framework. In Section 3,
we propose a probabilistic version of Security-by-Contract. Section 4 briefly concludes
proposing a future working line.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Contract-based Approaches</title>
      <p>
        Contract-based approaches have been developed for mobile devices, such as the
Securityby-Contract [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] (S C) and the Security-by-Contract-with-Trust [
        <xref ref-type="bibr" rid="ref2 ref3">2,3</xref>
        ] (S C T)
frameworks. They integrate several security techniques to build a chain of trust by
sequentially applying them to safely execute applications. The three cornerstones of these
security frameworks are application code A, application contract C, and client policy P ,
where a contract is a formal, complete, and correct specification of an application
security relevant behavior, e.g., security critical virtual machine API call, or critical system
calls [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. A policy is a formal complete specification of the acceptable security-relevant
behavior allowed to applications executed on the platform [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. We assume that both
contract and policy are syntactically described by exploiting the same language.
      </p>
      <p>The basic idea of a contract-based approach is the usage of the contract for
guaranteeing that security aspects are satisfied. More in detail, using the contract, it is possible
to check at deploy time, i.e., before the application execution, if the application
satisfies the user policy or not. Let denote the compliance between two of the previous
elements. A contract-based approach guarantees that</p>
      <p>A</p>
      <p>C</p>
      <p>P ) A</p>
      <p>P
(1)</p>
      <p>In the following, we describe the Security-by-Contract (S C) framework as
approach that integrates the described techniques to guarantee security at application
execution time.
2.1</p>
      <sec id="sec-2-1">
        <title>Security-by-Contract</title>
        <p>The Security-by-Contract paradigm provides a full characterization of the
contractbased interaction. It combines different functionalities in an integrated way (see Figure
2). In particular, it includes a module for automatically checking the formal
correspondence between code and contract (Application-Contract matching). If the result is
negative, then the monitor is run to enforce the policy (Policy Enforcement), otherwise a
matching between the contract and the policy (Contract-Policy Matching) is performed
to establish if the contract is compliant with the policy. In this case, the code is
executed without overhead (Safe Execution), otherwise the policy is enforced again (Policy
Enforcement).</p>
        <p>The advantages of contract-based frameworks are that they are able to identify
unsafe applications before and without running them. In particular, using the
contractpolicy matching functionality, it checks at deploy-time if the declared behavior of the
application is compliant with the required policy. This check, along with the assurance
that the application code is compliant with the application contract, which is obtained
through the application-contract matching module, guarantees that the application
satisfies the user requirements. Anytime the contract-policy matching finds that a contract
is not compliant with the policy, the application is run in a controlled way through the
enforcement module. It is worth noticing that the cost, in terms of energy, of running a
contract policy matching is much lower than performing the enforcement. Hence,
unsafe applications are not run at all by the user and possible unsafe application are run in
a controlled way. This leads to an attack risk reduction.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Probabilistic Security-by-Contract</title>
      <p>In this section, we describe a probabilistic version of the S C architecture. It is worth
noticing that, in both cases the original workflow is not changed. Only the components
are modified in such a way that, on one hand, they are able to cope with probability
metrics and, on the other hand, Equation 1 still holds for an appropriate choice of the
notion of compliance.</p>
      <p>Let us assume that both probabilistic contract and probabilistic policy are expressed
through the same formalism.</p>
      <p>
        Probabilistic contract and policy will be modelled as (substochastic) generative
probabilistic automata [
        <xref ref-type="bibr" rid="ref5 ref6">5,6</xref>
        ].
      </p>
      <p>Definition 1. A fully probabilistic or generative automata is a tuple (S; Act; P )
consisting of a finite set S of states, a set of actions Act, and a transition probability
function</p>
      <p>P : S</p>
      <p>Act</p>
      <p>S ! [0; 1]
for all s 2 S for all a 2 Act. On the other hand, a generative automata is said to be
semistochastic or substochastic if</p>
      <p>X X P (s; a; t) = 1
a2Act t2S
X X P (s; a; t) &lt; 1
a2Act t2S
for all s 2 S for all a 2 Act. For C S, we put P (s; a; C ) = Pt2C P (s; a; t). A state
s 2 S is said to be terminal iff Pa;t P (s; a; t) = 0.</p>
      <p>Hereafter, we consider generative automata such that for each action there is only one
possible transition for each action a 2 Act.
3.1</p>
      <sec id="sec-3-1">
        <title>Probabilistic Security-by-Contract Workflow</title>
        <p>Being the Security-By-Contract framework modular, introducing probability metrics
implies the substitution of some components with their probabilistic counterpart. The
Probabilistic Security-by-Contract workflow is depicted in Figure 3.</p>
      </sec>
      <sec id="sec-3-2">
        <title>Probabilistic application contract matching is verified using some static validation</title>
        <p>techniques able to deal with probabilistic description of behavior. For instance,
as proof carrying code [7] is used in S C, here we can use the Probabilistic
Proof Carrying Code, e.g., [8,9]. In particular, this method guarantees that, for
all possible k-length execution traces whose probability is calculated as Pk =
Qik=1 P (si; ai; ti), the application is considered compliant if Pk &gt; k, where k
is a given threshold value 0 &lt; k &lt; 1 dependent from the length of the execution
trace.</p>
        <p>Probabilistic contract policy matching is performed by checking the compliance
between a contract and a policy. According to the level of required accuracy, several
relations can be considered in order to verify the compliance between probabilistic
contract and policy. In S C, the contract-policy matching function checks if the
contract and the policy are similar. This means that for each action described in the
contract, we check if there exists the same action described in the policy and the
description of the transition are similar again. Hence, we assume that the policy
specifies a rule for each security relevant action, which we call SecAction.
Referring to the notion of "-simulation given in [10], hereafter, we define a slightly
different "-simulation.</p>
        <p>Definition 2. A relation R S S is a relation of positive "-simulation, where
" 2 [0; 1] if whenever (s; s0) 2 R, then 8a 2 SecAction, 8W 2 S</p>
        <p>X P (s; a; t)
t2W</p>
        <p>X
t02R(W )</p>
        <p>P (s0; a; t0)</p>
        <p>X (P (s; a; t) + ")
t2W
where R(W ) is the set of all states that are in relation with states in W trough R.
We say that s is "-simulated by s0, written s " s0, if (s; s0) 2 R for some relation
of "-simulation R on S.</p>
        <p>The idea is that, while the "-simulation allows a deviation of a values " 2 [ 1; 1],
here, we are only interested in positive values of ". Hence, the probabilistic
distribution of the contract have to be less that the probability distribution of the policy
of, at most, a value ".</p>
        <p>It is worth noticing that, according to our assumptions, having a positive "-simulation
R means that whether (s; s0) 2 R then, for each action a 2 SecAction,
P (s; a; t)</p>
        <p>P (s0; a; t0)</p>
        <p>P (s; a; t) + "
and (t; t0) 2 R.</p>
        <p>Enforcement of Probabilistic Policies is performed when either the application is not
compliant with the contract or the contract is not compliant with the policy.
At each step, the enforcement computes the probability that the application
performs a specific security relevant action a, starting from the current state s, P p(s; a; t),
where t is the destination state of the transition and p is the expected one stated
by the policy. This computation exploits history-based concerning the current
execution of the application. The computation of the probability of the execution
trace is similar to the one described in the application-contract matching module
Pkp = Qik=1 P p(si; ai; ti). The application is considered compliant if Pkp &gt; k,
where k is the same considered in the application-contract module. The
enforcement denies the non compliant operation sequence, ensuring that the policy is
correctly enforced.</p>
        <p>Pk</p>
        <p>It is worth noticing that Equation 1 holds. Indeed, the fact that C</p>
        <p>Pkp because
" P means that
k
Pk = Y P (si; ai; ti)
i=1
k
Y P p(si; ai; ti) = Pkp
i=1
Hence, k &lt; Pk Pkp Let be the compliance relation used in both
applicationcontract matching and enforcement mechanisms, where denotes the set of threshold
values k for any k-length execution trace, and let us consider to use the positive
"simulation for the contract-policy matching then the following holds</p>
        <p>A</p>
        <p>C
" P
) A</p>
        <p>P
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Conclusion and Future Work</title>
      <p>In this paper, we have discussed the current limitations of the semantics of the security
models for mobile applications. To this end, we have presented a probabilistic version
of the Security-by-Contract, which is able to guarantee probabilistic requirements. We
have discussed the advantages in terms of expressiveness achieved including
probability in the S C framework. Future extensions to this work will be the definition of
probabilistic formalisms and languages, which should be used to programmatically
define probabilistic contracts and policies, then to verify their compliance. This languages
should be equivalent in expressiveness to the probabilistic automata that we have used
to express policies and contracts. Furthermore, we are going to include the presented
framework in real mobile devices, investigating if it is possible to distribute it as
common mobile application, which can give users a way to better control their mobile
devices.
7. Necula, G.C.: Proof-carrying code. In: Proceedings of the 24th ACM SIGPLAN-SIGACT</p>
      <p>Symposium on Principles of Programming Langauges (POPL ’97). (1997) 106–119
8. Sharkey, M.I.: Probabilistic Proof-carrying Code. PhD thesis, Carleton University (2012)
9. Tsukada, Y.: Interactive and probabilistic proof of mobile code safety. Automated Software</p>
      <p>Engineering 12(2) (2005) 237–257
10. Desharnais, J., Laviolette, F., Tracol, M.: Approximate analysis of probabilistic processes:
Logic, simulation and games. In: Proceedings of the 2008 Fifth International Conference
on Quantitative Evaluation of Systems. QEST ’08, Washington, DC, USA, IEEE Computer
Society (2008) 264–273</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Dragoni</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Martinelli</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Massacci</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mori</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schaefer</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Walter</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vetillard</surname>
          </string-name>
          , E.:
          <article-title>Security-by-contract (SxC) for software and services of mobile systems</article-title>
          . In:
          <article-title>At your service - Service-Oriented Computing from an EU Perspective</article-title>
          ., MIT Press (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Costa</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dragoni</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lazouski</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Martinelli</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Massacci</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Matteucci</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>Extending Security-by-Contract with quantitative trust on mobile devices</article-title>
          .
          <source>In: Proceeding of the Fourth International Conference on Complex, Intelligent and Software Intensive Systems, IEEE Computer Society</source>
          (
          <year>2010</year>
          )
          <fpage>872</fpage>
          -
          <lpage>877</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Costa</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dragoni</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Issarny</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lazouski</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Martinelli</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Massacci</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Matteucci</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Saadi</surname>
          </string-name>
          , R.:
          <article-title>Security-by-Contract-with-Trust for mobile devices</article-title>
          .
          <source>JOWUA</source>
          <volume>1</volume>
          (
          <issue>4</issue>
          ) (
          <year>2010</year>
          )
          <fpage>75</fpage>
          -
          <lpage>91</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Greci</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Martinelli</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Matteucci</surname>
            ,
            <given-names>I.:</given-names>
          </string-name>
          <article-title>A framework for contract-policy matching based on symbolic simulations for securing mobile device application</article-title>
          . In: ISoLA. (
          <year>2008</year>
          )
          <fpage>221</fpage>
          -
          <lpage>236</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Hermanns</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parma</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Segala</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wachter</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhang</surname>
          </string-name>
          , L.:
          <article-title>Probabilistic logical characterization</article-title>
          .
          <source>Inf. Comput</source>
          .
          <volume>209</volume>
          (
          <issue>2</issue>
          ) (
          <year>2011</year>
          )
          <fpage>154</fpage>
          -
          <lpage>172</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Baier</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Engelen</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Majster-Cederbaum</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Deciding bisimilarity and similarity for probabilistic processes</article-title>
          .
          <source>Journal of Computer and System Sciences</source>
          <volume>60</volume>
          (
          <issue>1</issue>
          ) (
          <year>2000</year>
          )
          <fpage>187</fpage>
          -
          <lpage>231</lpage>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>