PyTorch Bernoulli Decomposition Vulnerability in Dropout Layers Allowing Arbitrary Code Execution

Vulnerability

A vulnerability exists in PyTorch versions through 2.6.0 in the handling of dropout layers. The issue arises from the bernoulli_p decomposition function, which is not fully consistent with the eager CPU implementation. This inconsistency affects the nn.Dropout1d, nn.Dropout2d, and nn.Dropout3d layers when the fallback_random option is enabled. As a result, a remote attacker could exploit this vulnerability to execute arbitrary code by manipulating the behavior of these dropout functions.

Impact

Exploitation of this vulnerability allows for arbitrary code execution on the system where the affected PyTorch version is running.

Reproduction

The vulnerability can be reproduced by setting the 'config.fallback_random' option to True and then using the 'torch.nn.Dropout' layers in a compiled PyTorch model. The output will be incorrect compared to the expected results, demonstrating the inconsistency introduced by the faulty decomposition.

Remediation

Users can upgrade to PyTorch version 2.7.0 or later, where this vulnerability has been fixed.

Added: Sep 25, 2025, 3:20 PM
Updated: Sep 25, 2025, 7:25 PM

Vulnerability Rating

Custom Algorithm
spread
6.6
impact
7.5
exploitability
5.0
remediation
7.7
relevance
0.5
threat
1.6
urgency
2.9
incentive
1.7

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.