Uncontrolled resource consumption (memory-exhaustion DoS) in jax.export.deserialize via unbounded symbolic-shape power expression
Summary
jax.export.deserialize() parses a serialized Exported object from an untrusted flatbuffer.
During deserialization it passes attacker-controlled per-dimension shape strings straight into
JAX's symbolic-shape polynomial parser. The parser's ^ (power) operator reads an unbounded
integer exponent and eagerly evaluates factor ** exponent. When the base factor is a constant
(e.g. 2), a single tiny shape string such as "2^2000000000" forces Python to materialize a
multi-gigabit bignum (2 ** 2_000_000_000) at the very first deserialization step, exhausting
memory and triggering an OOM-kill. The exponent is fully attacker-controlled, so the memory cost
scales linearly to arbitrary GB.
- Target:
jax(google/jax) — PyPIjax/jaxlib0.10.2 (current latest at time of report) - Sink module:
jax/_src/export/shape_poly.py(_Parser.term), reached viajax/_src/export/serialization.py(_deserialize_aval/_deserialize_exported) - Public entry point:
jax.export.deserialize(blob) - Impact: Denial of Service (memory exhaustion / OOM). Not RCE.
- CWE: CWE-400 (Uncontrolled Resource Consumption) / CWE-1284 (Improper Validation of Specified Quantity in Input)
Threat model
Exported blobs are the on-disk / on-wire serialization format for JAX exported functions and are
shared, downloaded, and loaded as untrusted model artifacts. This is the same untrusted-model-file
threat model under which the previously-filed jax.export pickle bug in this same module was filed.
Harm here is a DoS (OOM), not RCE, so severity is lower.
Reviewer note (disclosed up front):
deserialize()'s docstring states its input "must be trusted." A reviewer could contest the report on that trust-boundary docstring. The counter-argument is that the format is a model-distribution format and this is the identical threat model already accepted for the pickle finding in this module; the fix (bounding the parsed exponent) is cheap and local regardless.
Root cause
1. Untrusted shape strings flow into the symbolic-shape parser
jax/_src/export/serialization.py, _deserialize_aval (~line 821). The per-dimension shape entries
from the flatbuffer are joined and handed directly to shape_poly.symbolic_shape:
def _deserialize_aval(aval: ser_flatbuf.AbstractValue, *,
scope: shape_poly.SymbolicScope,
sharding: named_sharding.NamedSharding | None,
) -> core.ShapedArray:
dtype = _dtype_kind_to_dtype[aval.Dtype()]
shape = shape_poly.symbolic_shape(
",".join(
aval.Shape(i).decode("utf-8") for i in range(aval.ShapeLength())
),
scope=scope, ...)
_deserialize_exported (~line 284) iterates every entry in UniqueAvals and calls
_deserialize_aval, so the parse happens eagerly and early — before most other validation.
2. Unbounded integer exponent evaluated eagerly
jax/_src/export/shape_poly.py, _Parser.term (~line 1653-1657):
# A term is product of factors. Each factor may be raised to an integer power.
acc: DimSize | None = None
while True:
f: DimSize
f, tok = self.factor(tok)
if tok.exact_type == tokenize.CIRCUMFLEX:
tok = self.next_tok()
self.expect_token(tok, [tokenize.NUMBER])
power, tok = self.integer(tok) # int() of a NUMBER token — NO upper bound
f = f ** power # eagerly computes constant ** power (bignum)
self.integer(tok) is just int() of the token text with no upper bound, and f = f ** power
immediately materializes the result. With f == 2 and power == 2_000_000_000, this allocates a
~2-billion-bit (~250 MB per copy, multiple GB peak) Python integer synchronously during
deserialization.
Proof of Concept
A minimal but real malicious Exported flatbuffer (116 bytes) is built with the real
jaxlib-shipped flatbuffers builder (jax._src.export.serialization_generated): one AbstractValue
in UniqueAvals whose single Shape entry is the string "2^2000000000", dtype f32. Feeding this
to the public API jax.export.deserialize(bytearray(blob)) drives the shape_poly parser to compute
2**2_000_000_000 at the first deserialization step.
craft_jax_export.py— builds the blob and calls the real public API, measuring peak RSS.malicious_exported.bin— the 116-byte maliciousExportedflatbuffer.
Run:
python craft_jax_export.py control # benign shape "3"
python craft_jax_export.py malicious 2000000000 # malicious shape "2^2000000000"
The negative control is an identical flatbuffer whose shape string is the benign constant "3".
Captured evidence (verbatim)
Environment: jax 0.10.2 jaxlib 0.10.2 flatbuffers 25.12.19 py 3.13.12, clean venv.
[control] benign shape '3':
[craft] shape='3' blob_size=104 bytes rss_before=193.5MB
[deserialize] AttributeError: 'NoneType' object has no attribute 'decode' after 0.000s rss_peak=193.5MB
[attack] shape '2^2000000000' from a 116-byte file:
[craft] shape='2^2000000000' blob_size=116 bytes rss_before=193.4MB
[deserialize] AttributeError: 'NoneType' object has no attribute 'decode' after 5.251s rss_peak=988.1MB
--- linear/unbounded scaling (peak RSS grows with attacker exponent) ---
2^100000000 -> rss_peak=234.9MB (0.19s)
2^500000000 -> rss_peak=403.1MB (1.19s)
2^1000000000 -> rss_peak=609.8MB (2.45s)
2^3000000000 -> rss_peak=1364.7MB (7.77s)
(control stays flat at 193.5MB)
Independently reproduced again at packaging time (same venv):
[craft] shape='3' blob_size=104 bytes rss_before=193.6MB
[deserialize] AttributeError: 'NoneType' object has no attribute 'decode' after 0.000s rss_peak=193.6MB
===
[craft] shape='2^1000000000' blob_size=116 bytes rss_before=193.7MB
[deserialize] AttributeError: 'NoneType' object has no attribute 'decode' after 2.500s rss_peak=607.0MB
On the incidental AttributeError
The AttributeError: 'NoneType' object has no attribute 'decode' is not the vulnerability. It is
an artifact of the deliberately minimal flatbuffer omitting the FunctionName field, and it fires
only after the multi-GB bignum has already been materialized at the aval-parse step. This is
proven by the control, which reaches the identical code path and returns instantly (0.000s) at
unchanged RSS (193.5MB) because its benign shape "3" requires no bignum. The measured quantity is
peak RSS and wall-clock time at the parse step, both of which scale with the attacker-controlled
exponent while the control stays flat. A more complete flatbuffer would let deserialization proceed
further, but the OOM already occurs at the shape-parse step regardless.
Suggested fix
Bound the exponent parsed by _Parser.term (e.g. reject powers above a small limit such as 128), or
bound the bit-length / magnitude of any constant produced during symbolic-shape parsing, before
evaluating f ** power. The DoS surface is the ^ operator applied to a constant factor with an
unbounded exponent.
Dedup / prior-work note
This is distinct from prior findings:
- Different module & sink from the previously-filed
jax.experimental.serialize_executablepicklefind_classRCE (that is a pickle reduction RCE; this is a flatbuffer + shape_poly integer-power parser DoS). - Different mechanism from the orbax msgpack/zarray HF PoCs (msgpack / zarray shape alloc).
- Sink here is specifically the
jax/_src/export/shape_poly.py_Parser.term^-power handler reached viajax.export.deserialize— a flatbuffer-format DoS, not pickle/msgpack. - No known CVE covers unbounded exponent evaluation in the JAX symbolic-shape parser at time of report.