<!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>Security Analysis of the OWASP Benchmark with Julia</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Elisa Burato</string-name>
          <email>elisa.burato@juliasoft.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Pietro Ferrara</string-name>
          <email>pietro.ferrara@juliasoft.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Fausto Spoto</string-name>
          <email>fausto.spoto@juliasoft.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Julia Srl</institution>
          ,
          <addr-line>Verona</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Universit`a di Verona</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2017</year>
      </pub-date>
      <fpage>242</fpage>
      <lpage>247</lpage>
      <abstract>
        <p>Among the various facets of cybersecurity, software security plays a crucial role. This requires the assessment of the security of programs and web applications exposed to the external world and consequently potential targets of attacks like SQL-injections, crosssite scripting, boundary violations, and command injections. The OWASP Benchmark Project developed a Java benchmark that contains thousands of test programs, featuring such security breaches. Its goal is to measure the ability of an analysis tool to identify vulnerabilities and its precision. We present how the Julia static analyzer, a sound tool based on abstract interpretation, performs on this benchmark in terms of soundness and precision. We discuss the details of its security analysis over a taint analysis of data, implemented through binary decision diagrams.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>The OWASP Cybersecurity Benchmark</title>
      <p>with no guarantee of completeness but full guarantee of precision. In this scenario, establishing
a metric to compare different tools is problematic since there is no general agreement about
what factors (e.g., soundness or precision) one should take into account in the evaluation, and
why. In addition, it is not always clear what constitutes a threat, and how some attacks should
be formally defined.</p>
      <p>
        As far as we know, the OWASP Benchmark Project represents the most relevant attempt
to establish a universal security benchmark, i.e., a suite of thousands of small Java programs
containing security threats. According to their web page [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]:
      </p>
      <p>The OWASP Benchmark for Security Automation is a free and open test suite designed
to evaluate the speed, coverage, and accuracy of automated software vulnerability
detection tools and services. Without the ability to measure these tools, it is difficult to
understand their strengths and weaknesses, and compare them to each other.
The benchmark has benefited from the critical contribution of many organizations, so that it
has also served as a way of clarifying the actual nature of the threats. During the years, it
has emerged as the reference for the comparison of security analysis tools, and it is nowadays
a must-do for any tool that asserts to find software security vulnerabilities in Java code. Most
tests of the OWASP benchmark are servlets that might allow unconstrained information flow
from their inputs to dangerous routines. A few tests are not related to injections, but rather
to unsafe cookie exchange or to the use of inadequate cryptographic algorithms, hash functions
or random number generators. Injection attacks are however the most complex to spot and
have larger scientific interest. The benchmark sets traps for tools, i.e., it contains also harmless
servlets that seem to feature security threats, at least at a superficial analysis. In this way,
the benchmark measures the number of true positives (that is, real vulnerabilities reported
by the tool) and false positives (that is, vulnerabilities reported by the tool that are not real
issues). They represent a deep and wide stress test: a perfect analyzer should not be caught
in a trap while still reporting all the real vulnerabilities. In an ideal world, a tool would get
100% true positive and 0% false positives. However, to achieve such a result one should be able
to explore all possible executions of a program; therefore, existing tools make a compromise
between soundness, precision and efficiency of the analysis.</p>
      <p>
        An important feature of this benchmark is the automatic generation of reports to compare
different tools: there are several scripts to plot coverage and accuracy of the tools, inside
comparative scorecards. This gives an immediate graphical picture of the relative positioning
of the tools. Free tools are plotted in the scorecards. Commercial tools are anonymized into
their overall average [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Taint Analysis with the Julia Static Analyzer</title>
      <p>
        Julia [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] is a commercial static analyzer for Java bytecode, based on abstract interpretation [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
It performs static analysis based on denotational or constraint-based semantics. Julia currently
features 45 checkers, including the Injection checker based on the sound taint analysis defined
in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Julia has also checkers Cookie, Random and Cryptography that cover the other kinds of
threats considered in the OWASP benchmark.
      </p>
      <p>
        The idea of Julia’s taint analysis is to model explicit information flows through Boolean
formulas. Boolean variables correspond to program variables and the models of a Boolean
formula are a sound overapproximation of all taint behaviours for the variables in scope at a
given program point. For instance, the abstraction of the load k bytecode, that pushes on the
1 public void doPost(HttpServletRequest request , HttpServletResponse response) throws ... {
2 response .setContentType(”text/html;charset=UTF−8”);
3 String param = ””;
4 if ( request .getHeader(”Referer”) != null )
5 param = request.getHeader(”Referer”);
6 param = java.net.URLDecoder.decode(param, ”UTF−8”);
7 String bar = param;
8 if (param != null &amp;&amp; param.length() &gt; 1) {
9 StringBuilder sbxyz67327 = new StringBuilder(param);
10 bar = sbxyz67327.replace(param.length()−”Z”.length(), param.length (), ”Z”).toString ();
11 }
12 response .setHeader(”X−XSS−Protection”, ”0”);
13 Object [] obj = { ”a”, ”b” };
14 response . getWriter (). format(java . util .Locale.US,bar,obj );
15 }
operand stack the value of local variable k, is the Boolean formula (ˇlk ↔ sˆtop ) ∧ U , stating that
the taintedness of the topmost stack element after this instruction is equal to the taintedness
of local variable k before the instruction; all other local variables and stack elements do not
change (expressed by a formula U ); taintedness before and after an instruction is distinguished
by using distinct hats for the variables. There are such formulas for each bytecode instruction.
Instructions that might have side-effects (field updates, array writes and method calls) need
some approximation of the heap, to model the possible effects of the updates. The analysis
of sequential instructions is merged through a sequential composition of formulas. Loops and
recursion are saturated by fixpoint. The resulting analysis is a denotational, bottom-up taint
analysis, that Julia implements through efficient binary decision diagrams [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Julia uses a
dictionary of sources (for instance, servlets input and input methods) and sinks (such as SQL
query methods, command execution routines, session manipulation methods) of tainted data,
so that flows from sources to sinks can be established.
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Analysis of the OWASP Benchmark with Julia</title>
      <p>In this section, we give an overview of the results of Julia on three representative test cases
producing a true positive, a true negative, and a false positive. In addition, we present the
overall results of Julia on the OWASP Benchmark.</p>
      <p>True positive: A (simplified) example of OWASP benchmark test is shown in Fig. 1. Julia
warns about a possible XSS attack at the last line, since the bar parameter to format() (at line
14) is tainted. In fact, this parameter is built from the content of local variable param (line 9),
that received (line 5) an input that the user can control (the header of the connection). Note
that Julia correctly spots the information flow through the constructor of StringBuilder and
the call to replace().</p>
      <p>True negative: Consider the test in Fig. 2 now. Julia does not issue any warning here.
Actually, no XSS attack is possible this time, since variable param (tainted at line 6) is sanitized
into bar by Spring method htmlEscape() (line 8). Julia uses a dictionary of sanitizing methods
and others can be specified by the user.</p>
      <p>False positive: Consider the test in Fig. 3 now. This time Julia falls in the trap and issues
a spurious warning about a potential XSS attack at the call to format(), since it thinks that
1 public void doPost(HttpServletRequest request , HttpServletResponse response) throws ... {
2 response .setContentType(”text/html;charset=UTF−8”);
3 String param = ””;
4 java . util .Enumeration&lt;String&gt; headers = request.getHeaders(”Referer”);
5 if (headers != null &amp;&amp; headers.hasMoreElements())
6 param = headers.nextElement();
7 param = java.net.URLDecoder.decode(param, ”UTF−8”);
8 String bar = org.springframework.web. util . HtmlUtils .htmlEscape(param);
9 response .setHeader(”X−XSS−Protection”, ”0”);
10 response . getWriter (). print (bar );
11 }
bar (and hence obj) is tainted. But this is not actually the case, since this test manipulates a
valueList in such a way that the value finally stored into bar is untainted. This list
manipulation is too complex for the taint analysis of Julia, that cannot distinguish each single element
of the list and conservatively assumes all elements of the list to be tainted.</p>
      <p>Overall results: Fig. 4 shows, on the left, the scorecard generated by the OWASP benchmark,
that compares Julia to other free (explicitly) and commercial (anonymously) static analyzers.
Scorecards report soundness on the left and precision horizontally. Hence, a perfect (i.e., sound
and precise) tool should stay on the top left corner of the scorecard. Fig. 4 shows that Julia
is very close to that corner, much more than all free analyzers and of the anonymous average
of the commercial analyzers. Fig. 4, on the right, reports the results of Julia for the eleven
categories of threats considered by the OWASP benchmark. Julia is always close to the top left
corner of the scorecard and always finds all threats, since it is the only sound analyzer in this
comparison. Hence its results lie on the 100% line for soundness (true positive rate).</p>
      <p>Fig. 4 reports also the number of false negatives (FN), true positives (TP) and false positives</p>
      <p>Category
Command Injection
Cross-Site Scripting
Insecure Cookie
LDAP Injection
Path Traversal
SQL Injection
Trust Boundary Violation
Weak Encryption Algorithm
Weak Hash Algorithm
Weak Random Number
XPath Injection
(FP) obtained by Julia on the OWASP benchmark. For all categories Julia obtained zero false
negatives: this proves the (practical) soundness of the analysis, meaning that Julia is always able
to spot security vulnerabilities if the programs contain them. In addition, the number of false
positives is always a small percentage (below 20%) of the number of warnings produced: this
proves the (practical) precision of the analysis: a developer using Julia to identify vulnerabilities
will need to discard only a warning out of six, on this benchmark.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion</title>
      <p>In this demo, we presented the results of Julia on the OWASP Benchmark discussing the
details of three representative test cases. We showed how a sound semantic static analysis
can achieve better results in terms of true and false positives than existing commercial tools.
These results show the power of Julia’s analysis, but this is only a first step towards commercial
tools that catch security vulnerabilities in industrial software. Namely, the OWASP benchmark
project has been recognized by the security community as a comprehensive benchmark, but
still contains small case studies only, and industrial software is often far from these, even if the
patterns of security vulnerabilities are similar. Moreover, Julia uses a sound information flow
analysis that leads to a sound injection analysis only if the analyzer recognizes all sources and
sinks, which is a daunting task in the presence of the many programming frameworks for Java.
This is currently partially tested by the OWASP benchmark. Therefore, we plan to further
industrialize the checkers that we applied to the OWASP benchmark, identify their limitations,
refine our static analysis and its scalability and contribute new benchmarks to the community.
A</p>
    </sec>
    <sec id="sec-5">
      <title>Running Julia on the OWASP Benchmark</title>
      <p>The following is a walk-through of the actual demonstration, that analyzes the OWASP
Benchmark and generates the XML file with all warnings generated by Julia.</p>
      <p>1. Register to Julia’s online service of analysis at https://portal.juliasoft.com;
2. Install Julia’s Eclipse plugin and configure it with your credential information (instructions
and credentials available at login time to our service and under your user profile);
3. Set the maximum number of warnings shown to 5000;
4. Make sure you have enough credit to run the analysis (150,000 credits); otherwise please
contact us;
5. Select the OWASP benchmark project in Eclipse and analyze it with Julia’s Eclipse plugin:
in the first screen, flag both options Only main and Include .properties files. The latter is
needed since the benchmark assumes that the analyzer has access to property files, which
is normally turned off for privacy;</p>
      <p>After these steps, you will be able to navigate the results of the analysis of all the test cases of
the OWASP Benchmark.</p>
      <p>At the address http://www.juliasoft.com/eng/solutions/technical-documentation
one finds user manuals and short tutorials about the Eclipse plugin and the web interface.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>R.</given-names>
            <surname>Bryant</surname>
          </string-name>
          .
          <article-title>Symbolic Boolean Manipulation with Ordered Binary-Decision Diagrams</article-title>
          . ACM Computing Survey,
          <volume>24</volume>
          (
          <issue>3</issue>
          ):
          <fpage>293</fpage>
          -
          <lpage>318</lpage>
          ,
          <year>1992</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>P.</given-names>
            <surname>Cousot</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Cousot</surname>
          </string-name>
          .
          <article-title>Abstract Interpretation: A Unified Lattice Model for Static Analysis of Programs by Construction or Approximation of Fixpoints</article-title>
          . In POPL, pages
          <fpage>238</fpage>
          -
          <lpage>252</lpage>
          ,
          <year>1977</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M. D.</given-names>
            <surname>Ernst</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Lovato</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Macedonio</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Spiridon</surname>
          </string-name>
          , and
          <string-name>
            <given-names>F.</given-names>
            <surname>Spoto</surname>
          </string-name>
          .
          <article-title>Boolean Formulas for the Static Identification of Injection Attacks in Java</article-title>
          .
          <source>In Proc. of Logic for Programming</source>
          ,
          <source>Artificial Intelligence, and Reasoning (LPAR'20)</source>
          , volume
          <volume>9450</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>130</fpage>
          -
          <lpage>145</lpage>
          , Suva, Fiji,
          <year>November 2015</year>
          . Springer.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>OWASP.</given-names>
            <surname>Benchmark</surname>
          </string-name>
          . https://www.owasp.org/index.php/Benchmark. Checked on Oct 13,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>F.</given-names>
            <surname>Spoto</surname>
          </string-name>
          .
          <article-title>The Julia Static Analyzer for Java</article-title>
          .
          <source>In Proc. of Static Analysis (SAS'16)</source>
          , volume
          <volume>9837</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>39</fpage>
          -
          <lpage>57</lpage>
          , Edinburgh, UK,
          <year>September 2016</year>
          . Springer.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <article-title>6. In the next screen of Julia's Eclipse plugin, select only the Basic checkers Cryptography, Cookie and Random and the Advanced checker Injection;</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>Click</given-names>
            <surname>Finish</surname>
          </string-name>
          and
          <article-title>wait until the analysis terminates. This should take a few minutes, unless there are other analyses in the queue</article-title>
          .
          <article-title>You can check the progress of the analysis in the console view of Eclipse;</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <article-title>8. Once the analysis has terminated, you can see the warnings in the Eclipse view of Julia and export the XML file of the warnings with the icon of that view that looks like a downwards arrow</article-title>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>