Stack Exhaustion In Tensorflow Serving
Description
Incorrect JSON input stringification in Google's Tensorflow serving versions up to 2.18.0 allows for potentially unbounded recursion leading to server crash.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected products
2<=2.18.0+ 1 more
- (no CPE)range: <=2.18.0
- (no CPE)range: 0
Patches
Vulnerability mechanics
Root cause
"Missing recursion/size limit in JSON stringification allows unbounded stack recursion on deeply nested JSON input."
Attack vector
An attacker sends a crafted JSON request to a TensorFlow Serving endpoint with deeply nested objects or arrays. When the server attempts to stringify the JSON value for error reporting or debugging (e.g., via `TypeError`, `Base64FormatError`, or `FormatError`), the original `JsonValueToString()` function recursively traverses the entire nested structure without a depth or size limit. This unbounded recursion can exhaust the call stack, causing the server process to crash (denial of service). No authentication is required if the serving endpoint is exposed [ref_id=1].
Affected code
The vulnerability resides in `tensorflow_serving/util/json_tensor.cc`. The original `JsonValueToString()` function (line ~169) called `val.Accept(writer)` on the raw `rapidjson::Value` without any size limit, allowing deeply nested JSON structures to cause unbounded recursion. The patch replaces this with `JsonValueToDebugString()` which uses a new `JsonWriterWithLimit` class that caps output at `kMaxJsonDebugStringBytes` (256 bytes). Additionally, `ParseJson()` was changed from recursive parsing to iterative parsing via `rapidjson::kParseIterativeFlag` [ref_id=1].
What the fix does
The patch introduces two defenses. First, a new `JsonWriterWithLimit` class wraps the rapidjson writer and checks `buffer_->GetSize() < max_bytes_` before writing any token, truncating output at 256 bytes to prevent deep recursion during stringification. Second, the `ParseJson()` function now uses `rapidjson::kParseIterativeFlag` instead of the default recursive parser, preventing stack overflow during the initial JSON parse of deeply nested input. The old `JsonValueToString()` is renamed to `JsonValueToDebugString()` and all call sites are updated [ref_id=1].
Preconditions
- networkThe TensorFlow Serving endpoint must be reachable by the attacker (network access).
- inputThe attacker must be able to send a POST request with a deeply nested JSON payload to a serving endpoint that triggers error-reporting code paths.
Generated on Jun 11, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
1News mentions
0No linked articles in our index yet.