[Bug 25742] New: Use After Free Vulnerability lldb_private::Debugger

Bug ID 25742
Summary Use After Free Vulnerability lldb_private::Debugger
Product lldb
Version 3.4
Hardware Macintosh
OS MacOS X
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter ichaithu@gmail.com
CC llvm-bugs@lists.llvm.org
Classification Unclassified

Created attachment 15398 [details]
Proof-of-Concept for the crash

A use after free vulnerability exists in com.apple.LLDB.framework on Apple Mac
OS X 10.11.1 in LLDB version 340.4.110.1, that on exploitation, would allow an
attacker to execute arbitrary code with the privileges of the user. 

Steps to reproduce:

~/D/A/t/lldbPython ❯❯❯ lldb
(lldb)script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> import lldb
>>> s=lldb.SBDebugger.Create()
>>> s.__swig_destroy__(s)
>>> print s

Backtrace of the crash:

0   com.apple.LLDB.framework          0x0000000105c0ae0a
lldb::SBDebugger::GetDescription(lldb::SBStream&) + 28
1   com.apple.LLDB.framework          0x0000000105c5be4c
_wrap_SBDebugger___str__(_object*, _object*) + 128
2   org.python.python                 0x0000000108ea0a0b PyEval_EvalFrameEx +
13400
3   org.python.python                 0x0000000108e9d3c1 PyEval_EvalCodeEx +
1583
4   org.python.python                 0x0000000108e422e5 0x108e1a000 + 164581
5   org.python.python                 0x0000000108e24202 PyObject_Call + 99
6   org.python.python                 0x0000000108e2eff5 0x108e1a000 + 86005
7   org.python.python                 0x0000000108e24202 PyObject_Call + 99
8   org.python.python                 0x0000000108ea2e83
PyEval_CallObjectWithKeywords + 165
9   org.python.python                 0x0000000108e6aa8f 0x108e1a000 + 330383
10  org.python.python                 0x0000000108e53e17 _PyObject_Str + 127
11  org.python.python                 0x0000000108e53eb0 PyObject_Str + 12
12  org.python.python                 0x0000000108e53b70 0x108e1a000 + 236400
13  org.python.python                 0x0000000108e3afb3 PyFile_WriteObject +
338
14  org.python.python                 0x0000000108e9fb01 PyEval_EvalFrameEx +
9550
15  org.python.python                 0x0000000108e9d3c1 PyEval_EvalCodeEx +
1583
16  org.python.python                 0x0000000108ea143e PyEval_EvalFrameEx +
16011
17  org.python.python                 0x0000000108e9d3c1 PyEval_EvalCodeEx +
1583
18  org.python.python                 0x0000000108ea34ae 0x108e1a000 + 562350
19  org.python.python                 0x0000000108ea030c PyEval_EvalFrameEx +
11609
20  org.python.python                 0x0000000108e9d3c1 PyEval_EvalCodeEx +
1583
21  org.python.python                 0x0000000108ea34ae 0x108e1a000 + 562350
22  org.python.python                 0x0000000108ea030c PyEval_EvalFrameEx +
11609
23  org.python.python                 0x0000000108ea3541 0x108e1a000 + 562497
24  org.python.python                 0x0000000108ea030c PyEval_EvalFrameEx +
11609
25  org.python.python                 0x0000000108e9d3c1 PyEval_EvalCodeEx +
1583
26  org.python.python                 0x0000000108ea34ae 0x108e1a000 + 562350
27  org.python.python                 0x0000000108ea030c PyEval_EvalFrameEx +
11609
28  org.python.python                 0x0000000108e9d3c1 PyEval_EvalCodeEx +
1583
29  org.python.python                 0x0000000108ea34ae 0x108e1a000 + 562350
30  org.python.python                 0x0000000108ea030c PyEval_EvalFrameEx +
11609
31  org.python.python                 0x0000000108ea3541 0x108e1a000 + 562497
32  org.python.python                 0x0000000108ea030c PyEval_EvalFrameEx +
11609
33  org.python.python                 0x0000000108e9d3c1 PyEval_EvalCodeEx +
1583
34  org.python.python                 0x0000000108e9cd8c PyEval_EvalCode + 54
35  org.python.python                 0x0000000108ebca42 0x108e1a000 + 666178
36  org.python.python                 0x0000000108ebcbff PyRun_StringFlags +
109
37  org.python.python                 0x0000000108ebcb53
PyRun_SimpleStringFlags + 69
38  com.apple.LLDB.framework          0x00000001079e1cef
IOHandlerPythonInterpreter::Run() + 245
39  com.apple.LLDB.framework          0x00000001078e7b43
lldb_private::Debugger::ExecuteIOHandlers() + 63
40  com.apple.LLDB.framework          0x00000001079c89cc
lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool,
lldb_private::CommandInterpreterRunOptions&) + 126
41  com.apple.LLDB.framework          0x0000000105c0ca80
lldb::SBDebugger::RunCommandInterpreter(bool, bool) + 68
42  lldb                              0x0000000105bdc05f Driver::MainLoop() +
2347
43  lldb                              0x0000000105bdc594 main + 268
44  libdyld.dylib                     0x00007fff9654e5ad start + 1

Please find the Proof-of-Concept attached as a python file.
Usage:
     ~/D/A/t/lldbPython ❯❯❯ python poc.py