The vulnerability is an out-of-bounds read in ExecuTorch caused by kernel functions not validating the number of arguments they receive on the execution stack. An attacker can craft a malicious ExecuTorch model that invokes these kernels with fewer arguments than they expect. When the kernel attempts to access the missing arguments from the stack, it reads out of bounds, leading to a process crash and potential for arbitrary code execution.
The analysis of the provided commits confirms this root cause. The patches consistently add checks at the beginning of kernel functions to validate the size of the stack argument before it is accessed. These changes were applied in two main areas:
-
Manually-written Primitive Kernels: Functions like et_copy_index, et_view, and numerous operators registered in register_prim_ops.cpp were patched to include ET_KERNEL_CHECK_MSG. This macro verifies the stack size against the expected number of arguments.
-
Generated Kernels: The Python-based code generator (codegen/gen.py) was updated to inject a similar stack size check into the C++ code it produces. This indicates that any custom kernel created using this tool was previously vulnerable.
-
Test code: The test code was also updated to include tests for the new checks.
The identified vulnerable functions are the C++ kernels that process the model's operations at runtime. During exploitation, a profiler would show these function names in the stack trace at the time of the crash.