<div dir="ltr"><div>Package: libxml2</div><div><br></div><div>Vulnerability class: Null deref, Denial of Service.</div><div><br></div><div>Description:</div><div>There are two bugs in the xpath implementation in libxml2 in the file:</div><div><a href="https://github.com/GNOME/libxml2/blob/master/xpath.c">https://github.com/GNOME/libxml2/blob/master/xpath.c</a></div><div><br></div><div>function name:</div><div>xmlXPathCompOpEval (2 bugs in this function)</div><div><br></div><div>inside the big switch clause there are 2 bugs:</div><div>1. in case XPATH_OP_AND - there is no check in the following code:</div><div> arg1 = valuePop(ctxt); //this could result in null.</div><div> arg1->boolval &= arg2->boolval; //and then the application</div><div>is crashing here resulting in a Denial of Service condition.</div><div><br></div><div>2. in case XPATH_OP_OR: - there is no check in the following code:</div><div> arg1 = valuePop(ctxt); //can result in null</div><div> arg1->boolval |= arg2->boolval; //crashing here due to null</div><div>deref.</div><div><br></div><div>
<span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Exploitability:</span><br style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">The complexity is fairly low, as the following xpath expressions are likely to be easily given by attackers remotely:</span><br style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">1. true() and format-number(1, "", "")</span><br style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">2. false() or format-number(1, "", "")</span>
<br></div><div><br></div><div>Proposed Fix:</div><div>The fix should be easy, just check for null values in arg1 before dereferencing in both cases.</div><div><br></div><div>I've verified this bug is affecting latest PHP 5.6 with xml module which can cause a denial of service for applications accepting xpath/xslt.</div><div>It also affects chrome (and I assume safari too), but it's only a client side tab crash for browsers.</div><div><br></div><div>I've added reproducers for both bugs in browsers and in php.</div><div><br></div><div>For browser reproduction open the html reproducers with your target browser (chrome/safari).</div><div><br></div><div>For php reproduction run the following (php needs the xml module for DOM):</div><div>make sure the php files and .xsl files reside in same directory and run the following commands:</div><div>php -f xpath_or.php</div><div>php -f xpath_and.php</div><div><br></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Guy Inbar.</div></div>