Downloads · 30 days
0
tonydav41/caffe-poc-blobshape-int64-truncation-2026-05-12
caffe-poc-blobshape-int64-truncation-2026-05-12 is a machine learning model from tonydav41. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
PoC for huntr submission against BVLC/caffe + opencv/opencv (Caffe DNN importer).
Downloads · 30 days
0
Access
Public
Updated May 12, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.sh4.2 KB · 45%
From the Hugging Face model README
PoC for huntr submission against BVLC/caffe + opencv/opencv (Caffe DNN importer).
BlobShape.dim is a protobuf int64 in Caffe's model schema, but both BVLC/caffe and OpenCV DNN narrow it to C++ int before range validation. A serialized dimension like 4294967297 (2^32 + 1) is silently truncated to 1 and the forward pass succeeds — the model executes with a topology different from what the serialized model declares.
AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N)9b89154 (master, 2020-02-13)e640a9b (4.x, 2026-05-12)src/caffe/blob.cpp L48-L54 — Blob::Reshape(const BlobShape&)src/caffe/blob.cpp L466-L484 — Blob::FromProto()modules/dnn/src/caffe/caffe_importer.cpp L82-L89 — parseBlobShape()modules/dnn/src/caffe/caffe_importer.cpp L251-L264, L281-L310 — blobShapeFromProto() / blobFromProto()modules/dnn/src/caffe/caffe_importer.cpp L393-L400, L438-L443 — text .prototxt input_shapebash repro.sh
cat /tmp/CAFFE_AUDIT.txt
Expected output:
OpenCV commit: e640a9bfb8649df98903f0165991683a14f605a4
prototxt overflow forward output: 1 7
caffemodel overflow forward output: 1 7
Both malicious models declare dim: 4294967297 but execute with dimension 1.
repro.sh — full reproducer: clones OpenCV, builds DNN module, compiles driver, generates malicious files, runs forward pass, asserts overflow truncationprototxt-overflow.prototxt — text .prototxt form of the malicious modelcaffemodel-overflow.prototxt — text deploy file for binary formcaffemodel-overflow.caffemodel — binary .caffemodel (31 bytes, valid protobuf)driver.cpp + driver-CMakeLists.txt — minimal cv::dnn::readNetFromCaffe() driverReject every BlobShape.dim before narrowing unless 0 <= dim <= INT_MAX, and perform tensor element-count checks in a type wide enough for the serialized dimensions.
Reported by lendtrain (huntr) / tonydav41 (HuggingFace). Filed 2026-05-12.