Skip to content

Commit a7ac10d

Browse files
committed
Upped the max_depth value to 400
1 parent 54c8ed5 commit a7ac10d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cbor2/_decoder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(
7474
str_errors: Literal["strict", "error", "replace"] = "strict",
7575
read_size: int = 1,
7676
*,
77-
max_depth: int = 100,
77+
max_depth: int = 400,
7878
):
7979
"""
8080
:param fp:
@@ -832,7 +832,7 @@ def loads(
832832
str_errors: Literal["strict", "error", "replace"] = "strict",
833833
read_size: int = 1,
834834
*,
835-
max_depth: int = 100,
835+
max_depth: int = 400,
836836
) -> Any:
837837
"""
838838
Deserialize an object from a bytestring.
@@ -881,7 +881,7 @@ def load(
881881
str_errors: Literal["strict", "error", "replace"] = "strict",
882882
read_size: int = 1,
883883
*,
884-
max_depth: int = 100,
884+
max_depth: int = 400,
885885
) -> Any:
886886
"""
887887
Deserialize an object from an open file.

docs/versionhistory.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This library adheres to `Semantic Versioning 2.0 <http://semver.org/>`_.
88
**UNRELEASED**
99

1010
- Added the ``max_depth`` decoder parameter to limit the maximum allowed nesting level of
11-
containers, with a default value of 100 levels (CVE-2026-26209)
11+
containers, with a default value of 400 levels (CVE-2026-26209)
1212
- Changed the default ``read_size`` from 4096 to 1 for backwards compatibility.
1313
The buffered reads introduced in 5.8.0 could cause issues when code needs to
1414
access the stream position after decoding. Users can opt-in to faster decoding

source/decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Default readahead buffer size for streaming reads.
77
// Set to 1 for backwards compatibility (no buffering).
88
#define CBOR2_DEFAULT_READ_SIZE 1
9-
#define CBOR2_DEFAULT_MAX_DEPTH 100
9+
#define CBOR2_DEFAULT_MAX_DEPTH 400
1010

1111
// Forward declaration for function pointer typedef
1212
struct CBORDecoderObject_;

tests/test_decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ class TestMaximumDepth:
142142
def test_default(self, impl) -> None:
143143
with pytest.raises(
144144
impl.CBORDecodeError,
145-
match="maximum container nesting depth \\(100\\) exceeded",
145+
match="maximum container nesting depth \\(400\\) exceeded",
146146
):
147-
impl.loads(b"\x81" * 101 + b"\x80")
147+
impl.loads(b"\x81" * 401 + b"\x80")
148148

149149
def test_explicit(self, impl) -> None:
150150
with pytest.raises(

0 commit comments

Comments
 (0)