已关闭
[Bug]: converter_lite解析TFLITE模型时堆缓冲区溢出 #472
lizhixuan创建于  7 天前关闭于  6 天前
lizhixuan
lizhixuan
7 天前 创建

Checklist

🐞 问题详细描述

漏洞描述

converter_lite 在将 TFLITE 模型转换到 MindSpore 格式时,常量折叠(constant folding)优化阶段存在堆缓冲区溢出漏洞,可被恶意构造的 TFLITE 模型文件触发。

崩溃点位于 mindspore-lite/src/tensor.h:109Tensor::shape()

std::vector<int> shape() const {
  return std::vector<int>(tensor_c_.shape_, tensor_c_.shape_ + tensor_c_.shape_size_);
}

Tensor 的shape元数据存储在定长C结构 TensorC 中(shape_ 是定长数组,MAX_SHAPE_SIZE = 16),shape_size_ 表示shape的元素个数。正常情况下 shape_size_Tensor 构造函数和 set_shape() 中的 shape.size() > MAX_SHAPE_SIZE 防护限制(≤16)。

恶意TFLITE模型导致某算子的中间 tensor 的 shape_size_ 被污染为巨大值(本PoC中为2^32,即4G个int,对应memmove READ 16GB)。shape() 直接用 shape_ + shape_size_ 构造 std::vector<int>,从 shape_(实际只分配了正常大小)越界读取4G个int,触发heap-buffer-overflow。

根因是Tensor::shape() 在读取时未对 shape_size_ 做合法性校验。虽然写侧(构造函数、set_shape)已有防护,但存在绕过写侧防护、直接污染 tensor_c_ 的路径(如 CopyTensor 对整个 TensorCmemcpy 等),导致 shape_size_ 巨大时 shape() 仍会越界读取。

复现步骤

git clone --depth 1 https://atomgit.com/mindspore/mindspore-lite.git
cd mindspore-lite
git submodule update --init --depth 1 mindspore

用官方 build.sh 编译,开启 ASAN(-a on)和 Debug(-d),指定 clang 编译器:

cd mindspore-lite

export CC=clang CXX=clang++ LDFLAGS="-latomic"
bash build.sh -I x86_64 -d -a on -S on -j$(nproc) -n off

产物:build/tools/converter/converter_lite/converter_lite

# 触发
export ASAN_OPTIONS=abort_on_error=1:symbolize=1:allocator_may_return_null=1:detect_leaks=0:detect_odr_violation=0:detect_container_overflow=0

./build/tools/converter/converter_lite/converter_lite \
  --fmk=TFLITE \
  --modelFile=MS-001_tflite_heap_buffer_overflow.poc \
  --outputFile=/dev/null

ASAN报错信息:

=================================================================
==3449567==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x51100004ab00 at pc 0x55d30c5addd7 bp 0x7ffe0fed6d40 sp 0x7ffe0fed6500
READ of size 17179869184 at 0x51100004ab00 thread T0
    #0 0x55d30c5addd6 in __asan_memmove (/src/test/results/fuzzing_mindspore/test/mindspore-lite/build/tools/converter/converter_lite/converter_lite+0x128dd6) (BuildId: c8c04f0461868e15a623a8d56c1ba087f653ba52)
    #1 0x7fc80cc6d5d2 in int* std::__copy_move<false, true, std::random_access_iterator_tag>::__copy_m<int const, int>(int const*, int const*, int*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:437:6
    #2 0x7fc80cc6d584 in int* std::__copy_move_a2<false, int const*, int*>(int const*, int const*, int*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:505:14
    #3 0x7fc80cc6d3f4 in int* std::__copy_move_a1<false, int const*, int*>(int const*, int const*, int*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:533:14
    #4 0x7fc80cd682ae in int* std::__copy_move_a<false, int const*, int*>(int const*, int const*, int*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:541:3
    #5 0x7fc80cd68199 in int* std::copy<int const*, int*>(int const*, int const*, int*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:632:14
    #6 0x7fc80cd68154 in int* std::__uninitialized_copy<true>::__uninit_copy<int const*, int*>(int const*, int const*, int*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_uninitialized.h:147:18
    #7 0x7fc80cd6811c in int* std::uninitialized_copy<int const*, int*>(int const*, int const*, int*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_uninitialized.h:184:14
    #8 0x7fc80cd67f08 in int* std::__uninitialized_copy_a<int const*, int*, int>(int const*, int const*, int*, std::allocator<int>&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_uninitialized.h:373:14
    #9 0x7fc80cd67c76 in void std::vector<int, std::allocator<int>>::_M_range_initialize<int const*>(int const*, int const*, std::forward_iterator_tag) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:1695:6
    #10 0x7fc80cd6791b in std::vector<int, std::allocator<int>>::vector<int const*, void>(int const*, int const*, std::allocator<int> const&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:711:4
    #11 0x7fc80cd6723a in mindspore::lite::Tensor::shape() const /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/src/tensor.h:109:12
    #12 0x7fc80d8b94b6 in mindspore::opt::(anonymous namespace)::CreateNewParamter(std::shared_ptr<mindspore::FuncGraph> const&, mindspore::lite::Tensor*) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/fold_utils.cc:56:34
    #13 0x7fc80d8b620c in mindspore::opt::(anonymous namespace)::ReplaceCNode(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::CNode> const&, std::vector<mindspore::lite::Tensor*, std::allocator<mindspore::lite::Tensor*>>) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/fold_utils.cc:176:30
    #14 0x7fc80d8b1436 in mindspore::opt::ConstFoldProcessor::DoConstantFold(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::CNode> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/fold_utils.cc:321:12
    #15 0x7fc80d8a47af in mindspore::opt::ConstFoldAlongInferShape::PostProcess(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::CNode> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/fold_along_infershape.cc:36:40
    #16 0x7fc80e012404 in mindspore::opt::InferShapePass::InferProcess(std::shared_ptr<mindspore::FuncGraph> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/graph/infershape_pass.cc:309:14
    #17 0x7fc80e00f31e in mindspore::opt::InferShapePass::Run(std::shared_ptr<mindspore::FuncGraph> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/graph/infershape_pass.cc:179:7
    #18 0x7fc80e35a9b8 in mindspore::opt::ConstFoldPass::Run(std::shared_ptr<mindspore::FuncGraph> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/constant_folding_fusion.h:47:26
    #19 0x7fc80d89eea7 in mindspore::opt::LitePassManager::RunPass(std::shared_ptr<mindspore::FuncGraph> const&, unsigned long, std::shared_ptr<mindspore::opt::Pass> const&) const/src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/common/pass_manager_extends.cc:80:13
    #20 0x7fc80d8a0089 in mindspore::opt::LitePassManager::Run(std::shared_ptr<mindspore::FuncGraph> const&, std::vector<std::shared_ptr<mindspore::opt::Pass>, std::allocator<std::shared_ptr<mindspore::opt::Pass>>> const&) const /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/common/pass_manager_extends.cc:109:18
    #21 0x7fc80d8a0c0e in mindspore::opt::LitePassManager::Run(std::shared_ptr<mindspore::FuncGraph> const&) const /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/common/pass_manager_extends.cc:134:14
    #22 0x7fc810799698 in mindspore::opt::GraphOptimizer::Optimize(std::shared_ptr<mindspore::FuncGraph> const&, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/ms_depend/graph_optimizer.cc:45:32
    #23 0x7fc80e2ffcad in mindspore::lite::AnfTransform::RunConstFoldPass(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:624:18
    #24 0x7fc80e30b794 in mindspore::lite::AnfTransform::RunPass(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:788:12
    #25 0x7fc80e30fc40 in mindspore::lite::AnfTransform::TransformFuncGraph(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:875:7
    #26 0x7fc80e315cdf in mindspore::lite::AnfTransform::Transform(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:985:17
    #27 0x7fc80e473ab7 in mindspore::lite::ConverterFuncGraph::Optimize(std::shared_ptr<mindspore::ConverterPara> const&, std::shared_ptr<mindspore::FuncGraph>) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter_funcgraph.cc:653:32
    #28 0x7fc80e4141df in mindspore::lite::ConverterImpl::HandleGraphCommon(std::shared_ptr<mindspore::ConverterPara> const&, void**, unsigned long*, bool, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter.cc:1188:13
    #29 0x7fc80e411a94 in mindspore::lite::ConverterImpl::Convert(std::shared_ptr<mindspore::ConverterPara> const&, void**, unsigned long*, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter.cc:1137:11
    #30 0x7fc80e41b9c3 in mindspore::lite::RunConverter(std::shared_ptr<mindspore::ConverterPara> const&, void**, unsigned long*, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter.cc:1326:29
    #31 0x7fc80e4abd98 in mindspore::Converter::Convert() /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/cxx_api/converter.cc:315:49
    #32 0x55d30c5f4427 in main /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter_lite/main.cc:105:31
    #33 0x7fc7fe63b1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)
    #34 0x7fc7fe63b28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)
    #35 0x55d30c50fd24 in _start (/src/test/results/fuzzing_mindspore/test/mindspore-lite/build/tools/converter/converter_lite/converter_lite+0x8ad24) (BuildId: c8c04f0461868e15a623a8d56c1ba087f653ba52)

0x51100004ab00 is located 0 bytes after 256-byte region [0x51100004aa00,0x51100004ab00)
allocated by thread T0 here:
    #0 0x55d30c5f11d1 in operator new(unsigned long) (/src/test/results/fuzzing_mindspore/test/mindspore-lite/build/tools/converter/converter_lite/converter_lite+0x16c1d1) (BuildId: c8c04f0461868e15a623a8d56c1ba087f653ba52)
    #1 0x7fc80e0687bf in std::__new_allocator<std::_Sp_counted_ptr_inplace<mindspore::lite::Tensor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>>::allocate(unsigned long, void const*) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/new_allocator.h:151:27
    #2 0x7fc80e0682d3 in std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<mindspore::lite::Tensor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>>>::allocate(std::allocator<std::_Sp_counted_ptr_inplace<mindspore::lite::Tensor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>>&, unsigned long) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/alloc_traits.h:482:20
    #3 0x7fc80e0682d3 in std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<mindspore::lite::Tensor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>>> std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<mindspore::lite::Tensor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>>>(std::allocator<std::_Sp_counted_ptr_inplace<mindspore::lite::Tensor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>>&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/allocated_ptr.h:98:21
    #4 0x7fc80e068017 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<mindspore::lite::Tensor, std::allocator<void>, mindspore::TypeId, std::vector<int, std::allocator<int>> const&, mindspore::Format, mindspore::lite::Category&>(mindspore::lite::Tensor*&, std::_Sp_alloc_shared_tag<std::allocator<void>>, mindspore::TypeId&&, std::vector<int, std::allocator<int>> const&, mindspore::Format&&, mindspore::lite::Category&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr_base.h:969:19
    #5 0x7fc80e067e14 in std::__shared_ptr<mindspore::lite::Tensor, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, mindspore::TypeId, std::vector<int, std::allocator<int>> const&, mindspore::Format, mindspore::lite::Category&>(std::_Sp_alloc_shared_tag<std::allocator<void>>, mindspore::TypeId&&, std::vector<int, std::allocator<int>> const&,mindspore::Format&&, mindspore::lite::Category&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr_base.h:1712:14
    #6 0x7fc80e067d53 in std::shared_ptr<mindspore::lite::Tensor>::shared_ptr<std::allocator<void>, mindspore::TypeId, std::vector<int, std::allocator<int>> const&, mindspore::Format, mindspore::lite::Category&>(std::_Sp_alloc_shared_tag<std::allocator<void>>, mindspore::TypeId&&, std::vector<int, std::allocator<int>> const&, mindspore::Format&&, mindspore::lite::Category&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr.h:464:4
    #7 0x7fc80e067958 in std::shared_ptr<std::enable_if<!is_array<mindspore::lite::Tensor>::value, mindspore::lite::Tensor>::type> std::make_shared<mindspore::lite::Tensor, mindspore::TypeId, std::vector<int, std::allocator<int>> const&, mindspore::Format, mindspore::lite::Category&>(mindspore::TypeId&&, std::vector<int, std::allocator<int>> const&, mindspore::Format&&, mindspore::lite::Category&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/shared_ptr.h:1009:14
    #8 0x7fc80e0532d4 in mindspore::opt::(anonymous namespace)::ConvertToLiteTensor(mindspore::lite::DataInfo const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/graph/lite_tensor_extractor.cc:86:14
    #9 0x7fc80e063058 in mindspore::opt::LiteTensorExtractor::GetCNodeOutputTensors(std::shared_ptr<mindspore::CNode> const&, std::vector<std::shared_ptr<mindspore::lite::Tensor>,std::allocator<std::shared_ptr<mindspore::lite::Tensor>>>*, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/graph/lite_tensor_extractor.cc:507:19
    #10 0x7fc80d8af33f in mindspore::opt::ConstFoldProcessor::DoConstantFold(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::CNode> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/fold_utils.cc:280:7
    #11 0x7fc80d8a47af in mindspore::opt::ConstFoldAlongInferShape::PostProcess(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::CNode> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/fold_along_infershape.cc:36:40
    #12 0x7fc80e012404 in mindspore::opt::InferShapePass::InferProcess(std::shared_ptr<mindspore::FuncGraph> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/graph/infershape_pass.cc:309:14
    #13 0x7fc80e00f31e in mindspore::opt::InferShapePass::Run(std::shared_ptr<mindspore::FuncGraph> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/graph/infershape_pass.cc:179:7
    #14 0x7fc80e35a9b8 in mindspore::opt::ConstFoldPass::Run(std::shared_ptr<mindspore::FuncGraph> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/const_fold/constant_folding_fusion.h:47:26
    #15 0x7fc80d89eea7 in mindspore::opt::LitePassManager::RunPass(std::shared_ptr<mindspore::FuncGraph> const&, unsigned long, std::shared_ptr<mindspore::opt::Pass> const&) const/src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/common/pass_manager_extends.cc:80:13
    #16 0x7fc80d8a0089 in mindspore::opt::LitePassManager::Run(std::shared_ptr<mindspore::FuncGraph> const&, std::vector<std::shared_ptr<mindspore::opt::Pass>, std::allocator<std::shared_ptr<mindspore::opt::Pass>>> const&) const /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/common/pass_manager_extends.cc:109:18
    #17 0x7fc80d8a0c0e in mindspore::opt::LitePassManager::Run(std::shared_ptr<mindspore::FuncGraph> const&) const /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/optimizer/common/pass_manager_extends.cc:134:14
    #18 0x7fc810799698 in mindspore::opt::GraphOptimizer::Optimize(std::shared_ptr<mindspore::FuncGraph> const&, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/ms_depend/graph_optimizer.cc:45:32
    #19 0x7fc80e2ffcad in mindspore::lite::AnfTransform::RunConstFoldPass(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:624:18
    #20 0x7fc80e30b794 in mindspore::lite::AnfTransform::RunPass(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:788:12
    #21 0x7fc80e30fc40 in mindspore::lite::AnfTransform::TransformFuncGraph(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:875:7
    #22 0x7fc80e315cdf in mindspore::lite::AnfTransform::Transform(std::shared_ptr<mindspore::FuncGraph> const&, std::shared_ptr<mindspore::ConverterPara> const&) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/anf_transform.cc:985:17
    #23 0x7fc80e473ab7 in mindspore::lite::ConverterFuncGraph::Optimize(std::shared_ptr<mindspore::ConverterPara> const&, std::shared_ptr<mindspore::FuncGraph>) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter_funcgraph.cc:653:32
    #24 0x7fc80e4141df in mindspore::lite::ConverterImpl::HandleGraphCommon(std::shared_ptr<mindspore::ConverterPara> const&, void**, unsigned long*, bool, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter.cc:1188:13
    #25 0x7fc80e411a94 in mindspore::lite::ConverterImpl::Convert(std::shared_ptr<mindspore::ConverterPara> const&, void**, unsigned long*, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter.cc:1137:11
    #26 0x7fc80e41b9c3 in mindspore::lite::RunConverter(std::shared_ptr<mindspore::ConverterPara> const&, void**, unsigned long*, bool) /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter.cc:1326:29
    #27 0x7fc80e4abd98 in mindspore::Converter::Convert() /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/cxx_api/converter.cc:315:49
    #28 0x55d30c5f4427 in main /src/test/results/fuzzing_mindspore/test/mindspore-lite/mindspore-lite/tools/converter/converter_lite/main.cc:105:31
    #29 0x7fc7fe63b1c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)
    #30 0x7fc7fe63b28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)

SUMMARY: AddressSanitizer: heap-buffer-overflow (/src/test/results/fuzzing_mindspore/test/mindspore-lite/build/tools/converter/converter_lite/converter_lite+0x128dd6) (BuildId: c8c04f0461868e15a623a8d56c1ba087f653ba52) in __asan_memmove
Shadow bytes around the buggy address:
  0x51100004a880: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x51100004a900: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x51100004a980: fd fd fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x51100004aa00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x51100004aa80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x51100004ab00:[fa]fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x51100004ab80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x51100004ac00: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa
  0x51100004ac80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x51100004ad00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
  0x51100004ad80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3449567==ABORTING
Aborted

详细的环境信息描述

硬件

  • CPU:Intel x86_64,96 核
  • 内存:818 GiB
  • 架构:x86_64(little-endian)

操作系统

  • Ubuntu 24.04.3 LTS
  • 内核版本:5.4.0-216-generic

软件工具链

  • 编译器:Clang/LLVM 19.1.1
  • 构建系统:CMake 3.28.3
  • Make:GNU Make 4.3
  • Ninja:1.11.1

关键依赖库

  • protobuf:33.1
  • flatbuffers:23.5.26(native flatbuffers)
  • nlohmann_json:3.12.0

构建配置

  • bash build.sh -I x86_64 -d -a on -S on -j$(nproc) -n off
  • 编译器环境变量:CC=clang CXX=clang++ LDFLAGS="-latomic"
  • 构建类型:Debug
  • ASAN:-a on 启用(自动加 -fsanitize=address -fno-omit-frame-pointer

其他辅助信息

版本信息

涉及两个仓库的master分支:

仓库 分支 版本 Commit(完整 hash)
mindspore-lite master v2.11.0 ae7d64408a7cf9c557dbb12d17083b7d0f314266
mindspore(submodule) master 78873729d699c64d0ee6d638e633edfd2df84e7e

Thanks for contributing 🎉!

likedislike
lizhixuanlizhixuan
7 天前 关联分支 由 [] 改变为 [master]
lizhixuanlizhixuan
7 天前 关联组件 由 [] 改变为 [B-SIG-Infer]
lizhixuanlizhixuan
7 天前 问题后端类型 由 [] 改变为 [CPU]
lizhixuan
lizhixuan
7 天前 评论:

poc(MS-001_tflite_heap_buffer_overflow.poc):
8b993ad5934b4c09a39b58b499a27bcc.zip

likedislike
lizhixuanlizhixuan
7 天前 关联了pull request:fix: Tensor::shape()增加shape_size_合法性校验,修复恶意模型导致的堆缓冲区溢出
MindSpore-BotMindSpore-Bot成员
6 天前 关闭了 issue
MindSpore-BotMindSpore-Bot成员
6 天前 issue状态由 TODO 改变为 DONE