Views
No views yet
342395fc0d6bf29e2ea939ef0a7eced18d677f81CIR0)Operator.outputs contains model-controlled tensor indexes. The importer uses
those indexes against containers sized from SubGraph.tensors without first
checking that each index is non-negative and less than tensors.size().OpLoc():1for (auto tensor_index : op.outputs)
2 locations.push_back(TensorLoc(*tensors[tensor_index], builder, base));is_op_output:1llvm::SmallVector<bool, 16> is_op_output(subgraph.tensors.size(), false);
2for (auto &op : subgraph.operators)
3 for (auto output : op->outputs)
4 is_op_output[output] = true;poc.circle is derived from the repository's official 672-byte
tools/model_explorer_circle/tests/test.circle fixture. It changes one byte:
the first operator's first output index is changed from 2 to 5, exactly one
past the model's five-element tensor table.CIR06f90d118c04722677e5425abd9eb8fe095a5dc618f53624d88bfd57214ecaa78mutate-circle-output-index.mjs deterministically recreates the artifact from
the upstream fixture without third-party packages.1Control model, import-only: exit 0
2PoC model, import-only: exit 1
3
4ERROR: AddressSanitizer: heap-buffer-overflow
5READ of size 8
6#3 OpLoc .../CircleImport.cpp:126
7#4 ConvertSubgraph .../CircleImport.cpp:902
8#5 FlatBufferToMlir .../CircleImport.cpp:1059
9#6 circleImportExport .../circleimpexp.cpp:127
10
110x604000002478 is located 0 bytes to the right of 40-byte region
12[0x604000002450,0x604000002478)std::vector<std::unique_ptr<circle::TensorT>> allocated while unpacking the
model.nnfw/circle-mlir-build:jammy image, digest
sha256:412acf7b0c91694db5997bfd9597c16e4ed98ff0e3237dff06243a8e9769269d.flat_hash_map::contains() when the signature map is empty.FlatBufferToMlir() when running the
import-only test.OpLoc(), the operator-output loop, model unpacking, or
the candidate data flow. The clean model completes the same import-only path;
the one-byte-mutated model crashes before the test-only exit.subgraph.tensors.size(). Retain checks at dereference sites
as defense in depth, and add a regression test with an output index equal to
the tensor count.-1 tensor index. This finding concerns the
Circle-MLIR importer, a positive index equal to the tensor count, and the
OpLoc() dereference of the unpacked tensor vector.