CVE-2020-26267: TensorFlow - Unvalidated DataFormatVecPermute API
Summary
CVE-2020-26267: Lack of validation in data format attributes in TensorFlow. Affects tensorflow across 5 version ranges.
< 1.15.5
>= 2.0.0, < 2.0.4
>= 2.1.0, < 2.1.3
>= 2.2.0, < 2.2.2
>= 2.3.0, < 2.3.2
Fixed in 5 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · PyPI
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
- tensorflow · PyPI
The same CVE-2020-26267 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and community resources for building and deploying machine learning models. The tf.raw_ops.DataFormatVecPermute API is a function in TensorFlow that allows users to permute the data format of tensors. This API is used to manipulate the order of dimensions in a tensor, typically used for data preprocessing or model optimization. However, in certain versions of TensorFlow, the src_format and dst_format attributes of this API are not properly validated, leading to potential security vulnerabilities.
Vulnerability Detail
The vulnerability in TensorFlow's tf.raw_ops.DataFormatVecPermute API arises from the lack of validation for the src_format and dst_format attributes. The code assumes that these two arguments define a permutation of NHWC (representing the dimensions of a tensor: batch size, height, width, and channels). However, due to the absence of proper validation, it is possible to provide invalid or malicious values for these attributes. This can result in uninitialized memory accesses, reading outside of bounds, and even crashes. An attacker could exploit this vulnerability to execute arbitrary code, leak sensitive information, or cause denial-of-service attacks.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 1.15.51.15.5 -
>= 2.0.0, < 2.0.42.0.4 -
>= 2.1.0, < 2.1.32.1.3 -
>= 2.2.0, < 2.2.22.2.2 -
>= 2.3.0, < 2.3.22.3.2
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, users can avoid using the tf.raw_ops.DataFormatVecPermute API or ensure that the src_format and dst_format attributes are properly validated before calling the function. This can be done by implementing custom validation logic or using helper functions provided by the TensorFlow community. Here is an example of how to validate the attributes before calling the API:
import tensorflow as tf
def permute_data_format(src_format, dst_format):
valid_formats = ['NHWC', 'NCHW', 'HWCN', 'CHWN']
if src_format not in valid_formats or dst_format not in valid_formats:
raise ValueError('Invalid data format')
tf.raw_ops.DataFormatVecPermute(src_format=src_format, dst_format=dst_format)
Conclusion
In conclusion, the vulnerability in TensorFlow's tf.raw_ops.DataFormatVecPermute API can lead to serious security issues if not addressed. It is crucial to update TensorFlow to one of the fixed versions and follow the recommended upgrade instructions. Additionally, users can implement the provided workaround or custom validation logic to mitigate the risk. For further support on vulnerability remediation, contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides tools and libraries for building and deploying machine learning models.
The tf.raw_ops.DataFormatVecPermute API is a function in TensorFlow that allows users to permute the data format of tensors, manipulating the order of dimensions.
This vulnerability can lead to uninitialized memory accesses, reading outside of bounds, and crashes. It can be exploited by attackers to execute arbitrary code, leak sensitive information, or cause denial-of-service attacks.
To fix this vulnerability, update TensorFlow to one of the fixed versions: 1.15.5, 2.0.4, 2.1.3, 2.2.2, 2.3.2, or 2.4.0. Follow the official upgrade instructions provided by the TensorFlow project.
As a temporary workaround, avoid using the tf.raw_ops.DataFormatVecPermute API or ensure proper validation of the src_format and dst_format attributes before calling the function.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.