Downloads · 30 days
0
ericblackgachara/coreml-uncontrolled-mem-poc
coreml-uncontrolled-mem-poc is a machine learning model from ericblackgachara. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
- Repo: apple/coremltools - Platform: huntr.com - Format: .mlpackage (MIL protobuf)
Downloads · 30 days
0
Access
Public
Updated May 10, 2026
Repo size
163 KB
Likes
0
Public
Click a slice to open those files.
.pdf163 KB · 93%
From the Hugging Face model README
.mlpackage (MIL protobuf)get_proto_dim() in milproto/helper.py returns dim.constant.size (a uint64
from attacker-controlled protobuf) with zero bounds validation. This flows directly
into np.array(value).reshape(shape) with no interposing check.
# helper.py — get_proto_dim() — NO bounds check:
def get_proto_dim(dim):
if dim.WhichOneof("dimension") == "constant":
return dim.constant.size # uint64, attacker-controlled
# load.py:309-330 — shape applied to numpy allocation:
shape = valuetype.get_shape() # attacker value, no check
value = np.array(value).reshape(shape) # OOM when shape=(2147483647,)
All call _convert_model_spec_to_pymil_prog() → milproto.load.load():
ct.optimize.coreml.get_weights_metadata(mlmodel)ct.optimize.coreml.linear_quantize_weights(mlmodel)ct.optimize.coreml.palettize_weights(mlmodel)ct.optimize.coreml.prune_weights(mlmodel)| File | Line | Issue |
|---|---|---|
coremltools/converters/mil/frontend/milproto/helper.py | get_proto_dim() | Returns dim.constant.size with no upper-bound check |
coremltools/converters/mil/frontend/milproto/load.py | 309 | shape = valuetype.get_shape() — no validation |
coremltools/converters/mil/frontend/milproto/load.py | 330 | np.array(value).reshape(shape) — unchecked allocation |
poc_coremltools_cwe789.py — builds malicious .mlpackage and triggers OOMpip install coremltools
python poc_coremltools_cwe789.py
# helper.py — get_proto_dim():
MAX_DIM = 1 << 31 # 2 billion elements
if size > MAX_DIM:
raise ValueError(f"Tensor dimension {size} exceeds maximum {MAX_DIM}")
return size