High severityOSV Advisory· Published Jan 22, 2026· Updated Jan 22, 2026
CVE-2025-67221
CVE-2025-67221
Description
The orjson.dumps function in orjson thru 3.11.4 does not limit recursion for deeply nested JSON documents.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
orjsonPyPI | < 3.11.6 | 3.11.6 |
Affected products
1Patches
162bb185b7078Fix sporadic crash on serializing object close
3 files changed · +43 −2
src/ffi/bytes.rs+1 −1 modified@@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// Copyright ijl (2022-2025) +// Copyright ijl (2022-2026) use crate::ffi::{Py_ssize_t, PyObject}; use core::ffi::c_char;
src/serialize/writer/formatter.rs+1 −1 modified@@ -175,7 +175,7 @@ pub(crate) trait Formatter { where W: ?Sized + WriteExt + bytes::BufMut, { - debug_assert_has_capacity!(writer); + reserve_minimum!(writer); unsafe { writer.put_u8(b'}'); }
test/test_recursion.py+41 −0 added@@ -0,0 +1,41 @@ +# SPDX-License-Identifier: MPL-2.0 +# Copyright ijl (2026) + + +import pytest + +import orjson + + +def make_recursive_list_dict(limit: int, envelope_key: str, recurse_key: str): + i = 0 + root = [{envelope_key: i, recurse_key: []}] + i += 1 + while i < limit: + sub = [{envelope_key: i, recurse_key: []}] + sub[0][recurse_key] = root + root = sub + i += 1 + return root + + +class TestSerializeRecursion: + @pytest.mark.parametrize("i", range(1, 127)) + def test_dumps_recursion_valid_long(self, i): + root = make_recursive_list_dict(i, "🐈" * 512, "b" * 1024) + orjson.dumps(root) + + @pytest.mark.parametrize("i", range(1, 127)) + def test_dumps_recursion_valid_short_1(self, i): + root = make_recursive_list_dict(i, "a", "") + orjson.dumps(root) + + @pytest.mark.parametrize("i", range(1, 127)) + def test_dumps_recursion_valid_short_2(self, i): + root = make_recursive_list_dict(i, "level", "next") + orjson.dumps(root) + + def test_dumps_recursion_limit(self): + root = make_recursive_list_dict(128, "level", "next") + with pytest.raises(orjson.JSONEncodeError): + orjson.dumps(root)
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5News mentions
0No linked articles in our index yet.