PT-2026-59739 · Pypi · Tensorflow
Published
2026-07-09
·
Updated
2026-07-09
CVSS v3.1
8.1
High
| Vector | AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H |
Impact
The [implementation of shape inference for
ReverseSequence](https://github.com/tensorflow/tensorflow/blob/5100e359aef5c8021f2e71c7b986420b85ce7b3d/tensorflow/core/ops/array ops.cc#L1636-L1671) does not fully validate the value of batch dim and can result in a heap OOB read:python
import tensorflow as tf
@tf.function
def test():
y = tf.raw ops.ReverseSequence(
input = ['aaa','bbb'],
seq lengths = [1,1,1],
seq dim = -10,
batch dim = -10 )
return y
test()There is a check to make sure the value of
batch dim does not go over the rank of the input, but there is no check for negative values:cc
const int32 t input rank = c->Rank(input);
if (batch dim >= input rank) {
return errors::InvalidArgument(
"batch dim must be < input rank: ", batch dim, " vs. ", input rank);
}
// ...
DimensionHandle batch dim dim = c->Dim(input, batch dim);Negative dimensions are allowed in some cases to mimic Python's negative indexing (i.e., indexing from the end of the array), however if the value is too negative then [the implementation of
Dim](https://github.com/tensorflow/tensorflow/blob/5100e359aef5c8021f2e71c7b986420b85ce7b3d/tensorflow/core/framework/shape inference.h#L415-L428) would access elements before the start of an array:cc
DimensionHandle Dim(ShapeHandle s, int64 t idx) {
if (!s.Handle() || s->rank == kUnknownRank) {
return UnknownDim();
}
return DimKnownRank(s, idx);
}
·
static DimensionHandle DimKnownRank(ShapeHandle s, int64 t idx) {
CHECK NE(s->rank , kUnknownRank);
if (idx < 0) {
return s->dims [s->dims .size() + idx];
}
return s->dims [idx];
}Patches
We have patched the issue in GitHub commit 37c01fb5e25c3d80213060460196406c43d31995.
The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.
For more information
Please consult our security guide for more information regarding the security model and how to contact us with issues and questions.
Attribution
This vulnerability has been reported by Yu Tian of Qihoo 360 AIVul Team.
Fix
Found an issue in the description? Have something to add? Feel free to write us 👾
Related Identifiers
Affected Products
Tensorflow