Skip to content

TensorFlow segfault TFLite converter on per-channel quantized transposed convolutions

Moderate severity GitHub Reviewed Published Sep 15, 2022 in tensorflow/tensorflow • Updated Jan 28, 2023

Package

pip tensorflow (pip)

Affected versions

< 2.7.2
>= 2.8.0, < 2.8.1
>= 2.9.0, < 2.9.1

Patched versions

2.7.2
2.8.1
2.9.1
pip tensorflow-cpu (pip)
< 2.7.2
>= 2.8.0, < 2.8.1
>= 2.9.0, < 2.9.1
2.7.2
2.8.1
2.9.1
pip tensorflow-gpu (pip)
< 2.7.2
>= 2.8.0, < 2.8.1
>= 2.9.0, < 2.9.1
2.7.2
2.8.1
2.9.1

Description

Impact

When converting transposed convolutions using per-channel weight quantization the converter segfaults and crashes the Python process.

import tensorflow as tf

class QuantConv2DTransposed(tf.keras.layers.Layer):
    def build(self, input_shape):
        self.kernel = self.add_weight("kernel", [3, 3, input_shape[-1], 24])

    def call(self, inputs):
        filters = tf.quantization.fake_quant_with_min_max_vars_per_channel(
            self.kernel, -3.0 * tf.ones([24]), 3.0 * tf.ones([24]), narrow_range=True
        )
        filters = tf.transpose(filters, (0, 1, 3, 2))
        return tf.nn.conv2d_transpose(inputs, filters, [*inputs.shape[:-1], 24], 1)

inp = tf.keras.Input(shape=(6, 8, 48), batch_size=1)
x = tf.quantization.fake_quant_with_min_max_vars(inp, -3.0, 3.0, narrow_range=True)
x = QuantConv2DTransposed()(x)
x = tf.quantization.fake_quant_with_min_max_vars(x, -3.0, 3.0, narrow_range=True)

model = tf.keras.Model(inp, x)

model.save("/tmp/testing")
converter = tf.lite.TFLiteConverter.from_saved_model("/tmp/testing")
converter.optimizations = [tf.lite.Optimize.DEFAULT]

# terminated by signal SIGSEGV (Address boundary error)
tflite_model = converter.convert()

Patches

We have patched the issue in GitHub commit aa0b852a4588cea4d36b74feb05d93055540b450.

The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, 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 Lukas Geiger via Github issue.

References

@pak-laura pak-laura published to tensorflow/tensorflow Sep 15, 2022
Published to the GitHub Advisory Database Sep 16, 2022
Reviewed Sep 16, 2022
Published by the National Vulnerability Database Sep 16, 2022
Last updated Jan 28, 2023

Severity

Moderate
5.9
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
High
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H

Weaknesses

CVE ID

CVE-2022-36027

GHSA ID

GHSA-79h2-q768-fpxr

Source code

Checking history
See something to contribute? Suggest improvements for this vulnerability.