trailofbits / manticore

Symbolic execution tool
https://blog.trailofbits.com/2017/04/27/manticore-symbolic-execution-for-humans/
GNU Affero General Public License v3.0
3.7k stars 470 forks source link

Uncaught `MemoryError` and `OverflowError` in `EXTRACT` #2657

Open sam-xif opened 4 months ago

sam-xif commented 4 months ago

Summary of the problem

Hello manticore community,

I am working as part of a research team developing a code analysis tool for Python. One of the issues the tool discovered in manticore's codebase is that core.smtlib.operators.EXTRACT has the potential to throw uncaught OverflowError and MemoryError. These errors are caused by large values for the size argument.

If you are interested in learning more about the tool and how it found this issue, let me know down in the comments, or you can contact me at xifaras.s@northeastern.edu. We are primarily curious about whether you find that this issue is legitimate and worth reporting and fixing. If not, we would be interested in understanding why.

Thank you for your consideration!

-Sam

Manticore version

Latest master (commit hash: 8861005396ed3e25ecef9cd229e5319ae2fe2612)

Python version

Python 3.8

OS / Environment

Linux (kernel version 5.10.218)

Dependencies

N/A

Step to reproduce the behavior

Call EXTRACT with a large value for the size argument.

Expected behavior

Magnitude of size is appropriately limited.

Actual behavior

Traceback:

Traceback (most recent call last):
  ...
  File ".../repos/manticore/manticore/core/smtlib/operators.py", line 134, in EXTRACT
    return (x >> offset) & ((1 << size) - 1)
MemoryError
Traceback (most recent call last):
  ...
  File ".../repos/manticore/manticore/core/smtlib/operators.py", line 134, in EXTRACT
    return (x >> offset) & ((1 << size) - 1)
OverflowError: too many digits in integer