Executive brief
PyTorch, a popular machine learning library, is vulnerable to a memory corruption issue when processing specific data sequences. An attacker with local access to a system running PyTorch could provide specially crafted empty data structures to trigger a crash or potentially execute unauthorized code. This could lead to service interruptions or a compromise of the system's integrity and data.
Technical details
A memory corruption vulnerability (CWE-119) exists in PyTorch versions up to and including 2.6.0 within the torch.nn.utils.rnn.pad_packed_sequence and torch.nn.utils.rnn.unpack_sequence functions. The root cause is improper handling of empty tensors and batch sizes within PackedSequence objects, which leads to a segmentation fault. An attacker with local access and low privileges can exploit this by passing malformed input to these functions. While primarily resulting in a crash (Denial of Service), memory corruption bugs of this class can sometimes be leveraged for arbitrary code execution. A fix has been committed to the PyTorch repository.
Affected products
- PyTorch PyTorch <= 2.6.0
Timeline
- 2025-03-20: disclosed: Issue reported on GitHub
- 2025-03-31: advisory: NVD and GitHub Advisory published