CVE-2025-2999 Overview
A critical memory corruption vulnerability has been identified in PyTorch version 2.6.0 affecting the torch.nn.utils.rnn.unpack_sequence function. This vulnerability allows local attackers to manipulate inputs in a way that corrupts memory, potentially leading to application crashes, data corruption, or further exploitation scenarios. The exploit has been publicly disclosed, increasing the urgency for affected organizations to address this security issue.
Critical Impact
Local attackers can exploit the torch.nn.utils.rnn.unpack_sequence function to cause memory corruption, potentially compromising the integrity and availability of machine learning workloads running on affected PyTorch installations.
Affected Products
- PyTorch 2.6.0 (Python package)
- Linux Foundation PyTorch implementations using the affected RNN utility functions
- Machine learning pipelines and applications leveraging torch.nn.utils.rnn.unpack_sequence
Discovery Timeline
- 2025-03-31 - CVE-2025-2999 published to NVD
- 2025-05-29 - Last updated in NVD database
Technical Details for CVE-2025-2999
Vulnerability Analysis
This vulnerability is classified as CWE-119 (Improper Restriction of Operations within the Bounds of a Memory Buffer). The torch.nn.utils.rnn.unpack_sequence function is designed to reverse the packing operation performed by pack_sequence, converting packed sequence data back into a list of tensors. However, the implementation contains a flaw in how it handles memory operations during this unpacking process.
The vulnerability requires local access to exploit, meaning an attacker must have the ability to execute code on the target system or influence the inputs processed by the vulnerable function. When exploited, the memory corruption can affect the confidentiality, integrity, and availability of the affected system, though the impact scope is limited to the local context.
Root Cause
The root cause lies in improper bounds checking or memory management within the torch.nn.utils.rnn.unpack_sequence function. When processing specially crafted or malformed packed sequence data, the function fails to properly validate memory boundaries, leading to memory corruption conditions that fall under CWE-119 (Improper Restriction of Operations within the Bounds of a Memory Buffer).
Attack Vector
The attack vector is local, requiring an attacker to have the ability to supply malicious input to the vulnerable PyTorch function. This could occur in scenarios where:
- An attacker has local access to a machine learning server or workstation
- A machine learning pipeline processes untrusted input data that reaches the vulnerable function
- Shared computing environments where multiple users can execute PyTorch code
The vulnerability can be triggered through manipulation of the inputs passed to torch.nn.utils.rnn.unpack_sequence, causing the function to perform improper memory operations. Technical details and discussion can be found in the PyTorch GitHub Issue #149622.
Detection Methods for CVE-2025-2999
Indicators of Compromise
- Unexpected application crashes or segmentation faults in processes using PyTorch RNN utilities
- Memory access violation errors in logs related to torch.nn.utils.rnn.unpack_sequence operations
- Abnormal memory consumption patterns in PyTorch-based applications
- Core dumps indicating memory corruption in the PyTorch runtime
Detection Strategies
- Monitor system logs for segmentation faults or memory access violations originating from PyTorch processes
- Implement application-level logging to track calls to torch.nn.utils.rnn.unpack_sequence with input validation metrics
- Deploy runtime application self-protection (RASP) solutions capable of detecting memory corruption attempts
- Use memory sanitizers (AddressSanitizer, MemorySanitizer) during development and testing phases
Monitoring Recommendations
- Configure alerting for repeated crashes in machine learning pipeline components
- Monitor for unusual process behavior including unexpected memory allocation patterns
- Track PyTorch version deployments across your infrastructure to identify vulnerable installations
- Implement canary testing for production ML workloads processing external data
How to Mitigate CVE-2025-2999
Immediate Actions Required
- Audit all deployments to identify systems running PyTorch version 2.6.0
- Implement input validation for data processed by torch.nn.utils.rnn.unpack_sequence
- Consider isolating vulnerable PyTorch workloads using containerization or sandboxing
- Review and restrict local access to systems running affected PyTorch installations
- Monitor the PyTorch GitHub repository for official patch releases
Patch Information
As of the last modification date (2025-05-29), users should monitor the official PyTorch channels for security patches. The vulnerability has been reported via GitHub Issue #149622. Organizations are advised to:
- Subscribe to PyTorch security announcements
- Upgrade to patched versions when available
- Review the GitHub issue for updates and community-provided mitigations
Workarounds
- Implement strict input validation before calling torch.nn.utils.rnn.unpack_sequence to ensure data integrity
- Use alternative sequence processing methods if available and applicable to your use case
- Deploy the application in a restricted environment with limited privileges to reduce potential impact
- Consider using containerized environments with memory protection features enabled
# Configuration example - Verify PyTorch version in your environment
python -c "import torch; print(f'PyTorch Version: {torch.__version__}')"
# Check if the vulnerable function is used in your codebase
grep -r "unpack_sequence" --include="*.py" /path/to/your/project/
# Run with AddressSanitizer for detection during development
ASAN_OPTIONS=detect_leaks=1 python your_ml_script.py
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

