Critical severity9.8NVD Advisory· Published Aug 7, 2025· Updated Apr 15, 2026
CVE-2025-54949
CVE-2025-54949
Description
A heap buffer overflow vulnerability in the loading of ExecuTorch models can potentially result in code execution or other undesirable effects. This issue affects ExecuTorch prior to commit ede82493dae6d2d43f8c424e7be4721abe5242be
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
executorchPyPI | < 0.7.0 | 0.7.0 |
org.pytorch:executorch-androidMaven | < 0.7.0 | 0.7.0 |
github.com/pytorch/executorchSwiftURL | < 0.7.0 | 0.7.0 |
Patches
1ede82493dae6Check for buffer overflow in prim_ops::et_copy_index()
2 files changed · +14 −7
kernels/prim_ops/et_copy_index.cpp+13 −6 modified@@ -86,11 +86,9 @@ void et_copy_index(KernelRuntimeContext& context, EValue** stack) { // If we're copying past the first index then the shape of // copy_from and copy_to without the leading dimension should be // the same. i.e. copy_to.size[1:] == copy_from.size[:]. - if (index > 0) { - ET_CHECK_MSG( - copy_to.sizes()[i + 1] == copy_from.sizes()[i], - "Mismatch in shape between copy_to and copy_from tensors"); - } + ET_CHECK_MSG( + copy_to.sizes()[i + 1] == copy_from.sizes()[i], + "Mismatch in shape between copy_to and copy_from tensors"); expected_output_size[i + 1] = copy_from.sizes()[i]; } @@ -111,8 +109,17 @@ void et_copy_index(KernelRuntimeContext& context, EValue** stack) { // If we've reached here, it means the copy_to tensor has been // successfully resized so we can now copy over the data from // copy_from into the copy_to tensor. + + // Check that the destination has enough space for the copy. + size_t offset = index * size_copy_from; + size_t copy_to_size = copy_to.element_size() * copy_to.numel(); + ET_CHECK_MSG( + offset + size_copy_from <= copy_to_size, + "Buffer overflow: copy_to tensor is smaller than copy_from tensor."); + memcpy( - (void*)((uintptr_t)copy_to_ptr + index * size_copy_from), + // NOLINTNEXTLINE(performance-no-int-to-ptr) + (void*)((uintptr_t)copy_to_ptr + offset), copy_from_ptr, size_copy_from); }
kernels/prim_ops/test/prim_ops_test.cpp+1 −1 modified@@ -215,7 +215,7 @@ TEST_F(RegisterPrimOpsTest, TestETCopyIndex) { Tensor copy_to = tf.make({2, 2}, {0, 0, 0, 0}); #else std::vector<int> buf(4); - SizesType expected_output_size[2] = {0, 0}; + SizesType expected_output_size[2] = {0, 2}; Tensor copy_to = tf.make({2, 2}, {0, 0, 0, 0}, {}, TensorShapeDynamism::DYNAMIC_BOUND); // Resize the tensor to 0 size for the tests.
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
4News mentions
0No linked articles in our index yet.