Views
No views yet
| Field | Value |
|---|---|
| Repository | google/flax |
| Version | v0.12.7 (latest) |
| Commit | 0f128b5141a7ab40df430d280bc86d3929ccb1ce |
| Platform | huntr.com |
| CWE | CWE-674 (Uncontrolled Recursion) |
| CVSS | 7.5 High |
_unchunk_array_leaves_in_place() in flax/serialization.py recurses without a depth limit. msgpack allows up to 1024 nesting levels (C-layer) but Python's recursion limit is 1000. A checkpoint with depth 1001–1024 decodes fine but crashes Python on traversal.1# flax/serialization.py
2def _unchunk_array_leaves_in_place(d):
3 if isinstance(d, dict):
4 if '__msgpack_chunked_array__' in d:
5 return _unchunk(d)
6 else:
7 for k, v in d.items():
8 elif isinstance(v, dict):
9 _unchunk_array_leaves_in_place(v) # ← NO DEPTH GUARDload checkpoint file
→ serialization.msgpack_restore()
→ _unchunk_array_leaves_in_place() ← RecursionError here1pip install flax msgpack
2python3 poc_flax.py
3# Expected: RecursionError in _unchunk_array_leaves_in_placemsgpack_restore(), from_bytes(), or restore_checkpoint()def _unchunk_array_leaves_in_place(d, _depth=0):ValueError when _depth > 500. Or convert to iterative traversal.