Skip to content

Commit 0d07ec2

Browse files
authored
Merge commit from fork
Advisory fix 1
2 parents 60ac5b9 + 791f5aa commit 0d07ec2

File tree

13 files changed

+111
-10
lines changed

13 files changed

+111
-10
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 8.6.1
2+
current_version = 8.6.2
33
commit = True
44
tag = True
55
tag_name = {new_version}

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ Authors in order of the timeline of their contributions:
7676
- [Jim Cipar](https://github.com/jcipar) for the fix recursion depth limit when hashing numpy.datetime64
7777
- [Enji Cooper](https://github.com/ngie-eign) for converting legacy setuptools use to pyproject.toml
7878
- [Diogo Correia](https://github.com/diogotcorreia) for reporting security vulnerability in Delta and DeepDiff that could allow remote code execution.
79+
- [am-periphery](https://github.com/am-periphery) for reporting CVE-2026-33155: denial-of-service via crafted pickle payloads triggering massive memory allocation.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# DeepDiff Change log
22

3+
- v8-6-2
4+
- Security fix (CVE-2026-33155): Prevent denial-of-service via crafted pickle payloads that trigger massive memory allocation through the REDUCE opcode. Size-sensitive callables like `bytes()` and `bytearray()` are now wrapped to reject allocations exceeding 128 MB.
5+
36
- v8-6-1
47
- Patched security vulnerability in the Delta class which was vulnerable to class pollution via its constructor, and when combined with a gadget available in DeltaDiff itself, it could lead to Denial of Service and Remote Code Execution (via insecure Pickle deserialization).
58

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ authors:
55
given-names: "Sep"
66
orcid: "https://orcid.org/0009-0009-5828-4345"
77
title: "DeepDiff"
8-
version: 8.6.1
8+
version: 8.6.2
99
date-released: 2024
1010
url: "https://github.com/seperman/deepdiff"

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DeepDiff v 8.6.1
1+
# DeepDiff v 8.6.2
22

33
![Downloads](https://img.shields.io/pypi/dm/deepdiff.svg?style=flat)
44
![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat)
@@ -17,12 +17,15 @@
1717

1818
Tested on Python 3.9+ and PyPy3.
1919

20-
- **[Documentation](https://zepworks.com/deepdiff/8.6.1/)**
20+
- **[Documentation](https://zepworks.com/deepdiff/8.6.2/)**
2121

2222
## What is new?
2323

2424
Please check the [ChangeLog](CHANGELOG.md) file for the detailed information.
2525

26+
DeepDiff 8-6-2
27+
- **Security (CVE-2026-33155):** Fixed a memory exhaustion DoS vulnerability in `_RestrictedUnpickler` by limiting the maximum allocation size for `bytes` and `bytearray` during deserialization.
28+
2629
DeepDiff 8-6-1
2730
- Patched security vulnerability in the Delta class which was vulnerable to class pollution via its constructor, and when combined with a gadget available in DeltaDiff itself, it could lead to Denial of Service and Remote Code Execution (via insecure Pickle deserialization).
2831

deepdiff/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""This module offers the DeepDiff, DeepSearch, grep, Delta and DeepHash classes."""
22
# flake8: noqa
3-
__version__ = '8.6.1'
3+
__version__ = '8.6.2'
44
import logging
55

66
if __name__ == '__main__':

deepdiff/serialization.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,35 @@ def pretty(self, prefix: Optional[Union[str, Callable]]=None):
331331
return "\n".join(f"{prefix}{r}" for r in result)
332332

333333

334+
# Maximum size allowed for integer arguments to constructors that allocate
335+
# memory proportional to the argument (e.g. bytes(n), bytearray(n)).
336+
# This prevents denial-of-service via crafted pickle payloads. (CVE-2026-33155)
337+
_MAX_ALLOC_SIZE = 128 * 1024 * 1024 # 128 MB
338+
339+
# Callables where an integer argument directly controls memory allocation size.
340+
_SIZE_SENSITIVE_CALLABLES = frozenset({bytes, bytearray})
341+
342+
343+
class _SafeConstructor:
344+
"""Wraps a type constructor to prevent excessive memory allocation via the REDUCE opcode."""
345+
__slots__ = ('_wrapped',)
346+
347+
def __init__(self, wrapped):
348+
self._wrapped = wrapped
349+
350+
def __call__(self, *args, **kwargs):
351+
for arg in args:
352+
if isinstance(arg, int) and arg > _MAX_ALLOC_SIZE:
353+
raise pickle.UnpicklingError(
354+
"Refusing to create {}() with size {}: "
355+
"exceeds the maximum allowed size of {} bytes. "
356+
"This could be a denial-of-service attack payload.".format(
357+
self._wrapped.__name__, arg, _MAX_ALLOC_SIZE
358+
)
359+
)
360+
return self._wrapped(*args, **kwargs)
361+
362+
334363
class _RestrictedUnpickler(pickle.Unpickler):
335364

336365
def __init__(self, *args, **kwargs):
@@ -355,7 +384,11 @@ def find_class(self, module, name):
355384
module_obj = sys.modules[module]
356385
except KeyError:
357386
raise ModuleNotFoundError(MODULE_NOT_FOUND_MSG.format(module_dot_class)) from None
358-
return getattr(module_obj, name)
387+
cls = getattr(module_obj, name)
388+
# Wrap size-sensitive callables to prevent DoS via large allocations
389+
if cls in _SIZE_SENSITIVE_CALLABLES:
390+
return _SafeConstructor(cls)
391+
return cls
359392
# Forbid everything else.
360393
raise ForbiddenModule(FORBIDDEN_MODULE_MSG.format(module_dot_class)) from None
361394

docs/authors.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ and polars support.
118118
- `Enji Cooper <https://github.com/ngie-eign>`__ for converting legacy
119119
setuptools use to pyproject.toml
120120
- `Diogo Correia <https://github.com/diogotcorreia>`__ for reporting security vulnerability in Delta and DeepDiff that could allow remote code execution.
121+
- `am-periphery <https://github.com/am-periphery>`__ for reporting CVE-2026-33155: denial-of-service via crafted pickle payloads triggering massive memory allocation.
121122

122123

123124
.. _Sep Dehpour (Seperman): http://www.zepworks.com

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Changelog
55

66
DeepDiff Changelog
77

8+
- v8-6-2
9+
- Security fix (CVE-2026-33155): Prevent denial-of-service via crafted pickle payloads that trigger massive memory allocation through the REDUCE opcode. Size-sensitive callables like ``bytes()`` and ``bytearray()`` are now wrapped to reject allocations exceeding 128 MB.
10+
811
- v8-6-1
912
- Patched security vulnerability in the Delta class which was vulnerable to class pollution via its constructor, and when combined with a gadget available in DeltaDiff itself, it could lead to Denial of Service and Remote Code Execution (via insecure Pickle deserialization).
1013

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
# built documents.
6565
#
6666
# The short X.Y version.
67-
version = '8.6.1'
67+
version = '8.6.2'
6868
# The full version, including alpha/beta/rc tags.
69-
release = '8.6.1'
69+
release = '8.6.2'
7070

7171
load_dotenv(override=True)
7272
DOC_VERSION = os.environ.get('DOC_VERSION', version)

0 commit comments

Comments
 (0)