fkie-cad / dewolf

A research decompiler implemented as a Binary Ninja plugin.
GNU Lesser General Public License v2.1
176 stars 9 forks source link

[TypeError@globals.py:141] TypeError: Type violation: 'unknown type' #442

Open bugfinder-bot opened 4 days ago

bugfinder-bot commented 4 days ago

What happened?


  File "/opt/dewolf/decompiler/util/bugfinder/bugfinder.py", line 201, in iter_function_reports
    task, code = self.decompile(function, task_options=options)
  File "/opt/dewolf/decompile.py", line 80, in decompile
    result = self.decompile_all([function_id], task_options)
  File "/opt/dewolf/decompile.py", line 64, in decompile_all
    self._frontend.lift(task)
  File "/opt/dewolf/decompiler/frontend/binaryninja/frontend.py", line 83, in lift
    raise e
  File "/opt/dewolf/decompiler/frontend/binaryninja/frontend.py", line 76, in lift
    task.cfg = parser.parse(function)
  File "/opt/dewolf/decompiler/frontend/binaryninja/parser.py", line 49, in parse
    index_to_BasicBlock[basic_block.index] = BasicBlock(basic_block.index, instructions=list(self._lift_instructions(basic_block)))
  File "/opt/dewolf/decompiler/frontend/binaryninja/parser.py", line 148, in _lift_instructions
    if lifted_instruction := self._lifter.lift(instruction):
  File "/opt/dewolf/decompiler/frontend/binaryninja/lifter.py", line 33, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/assignments.py", line 56, in lift_assignment
    self._lifter.lift(assignment.src, parent=assignment),
  File "/opt/dewolf/decompiler/frontend/binaryninja/lifter.py", line 33, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/constants.py", line 61, in lift_constant_pointer
    res = self._lifter.lift(variable, view=view, parent=pointer)
  File "/opt/dewolf/decompiler/frontend/binaryninja/lifter.py", line 33, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 182, in lift_global_variable
    return self._lift_datavariable_by_type[type(variable.type)](variable, parent, callers=callers)
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 254, in _lift_pointer_type
    return self._build_global_variable(
  File "/opt/dewolf/decompiler/frontend/binaryninja/handlers/globals.py", line 141, in _build_global_variable
    raise TypeError(f"Type violation: '{init_value}'")

Error class TypeError@globals.py:141 contains 92 cases.

How to reproduce?

python decompile.py 152ca60d8f08a435af165efbc31760dd2bd59c7b2eef8c6f0a71b9297a848d7d sub_402e6c --debug

sample: 152ca60d8f08a435af165efbc31760dd2bd59c7b2eef8c6f0a71b9297a848d7d case: https://bugfinder.seclab-bonn.de/case/86154/ dewolf commit: e18c9d35 Binaryninja version: 3.5.4526

NeoQuix commented 4 days ago

/cib

github-actions[bot] commented 4 days ago

Branch issue-442-_TypeError_globals_py_141_TypeError_Type_violation_unknown_type created!

NeoQuix commented 4 days ago

The PR does not cover all error cases as the trace is utilized to catch all errors in global variable lifting. However it should fix the problem of stdout/stderr lifting.