CVE-2023-26145
Description
This affects versions of the package pydash before 6.0.0. A number of pydash methods such as pydash.objects.invoke() and pydash.collections.invoke_map() accept dotted paths (Deep Path Strings) to target a nested Python object, relative to the original source object. These paths can be used to target internal class attributes and dict items, to retrieve, modify or invoke nested Python objects. Note: The pydash.objects.invoke() method is vulnerable to Command Injection when the following prerequisites are satisfied: 1) The source object (argument 1) is not a built-in object such as list/dict (otherwise, the __init__.__globals__ path is not accessible) 2) The attacker has control over argument 2 (the path string) and argument 3 (the argument to pass to the invoked method) The pydash.collections.invoke_map() method is also vulnerable, but is harder to exploit as the attacker does not have direct control over the argument to be passed to the invoked function.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
pydash versions before 6.0.0 allow command injection via dotted paths in invoke() and invoke_map() methods when attacker controls path and argument.
Overview
The pydash library (versions before 6.0.0) suffers from a command injection vulnerability in methods like pydash.objects.invoke() and pydash.collections.invoke_map(). These methods accept dotted path strings (Deep Path Strings) to navigate nested object attributes. By crafting a malicious path such as __init__.__globals__, an attacker can access the global namespace of a class and invoke arbitrary functions, including os.system [1], [2].
Exploitation
Exploitation of invoke() requires three conditions: (1) the first argument (source object) is not a built-in list/dict (which lack the __globals__ path), (2) the attacker controls the second argument (the path string), and (3) the attacker controls the third argument (the argument to the invoked method) [1], [3]. For invoke_map(), exploitation is more difficult as the attacker does not directly control the function argument, but it remains a vector if the collection can be manipulated [2].
Impact
Successful exploitation leads to arbitrary command execution on the host running the vulnerable pydash instance. An attacker can execute system commands, potentially leading to full compromise of the application and underlying system [1], [3].
Mitigation
The vulnerability has been fixed in pydash version 6.0.0 [4]. Users are advised to upgrade immediately. No workarounds are available for older versions [2].
AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
pydashPyPI | < 6.0.0 | 6.0.0 |
Affected products
3- pydash/pydashdescription
Patches
16ff0831ad285fix: don't allow object paths that reference dunder-method attributes for functions like get()
2 files changed · +33 −0
src/pydash/helpers.py+9 −0 modified@@ -178,6 +178,7 @@ def _base_get_item(obj, key, default=UNSET): def _base_get_object(obj, key, default=UNSET): value = _base_get_item(obj, key, default=UNSET) if value is UNSET: + _raise_if_restricted_key(key) value = default try: value = getattr(obj, key) @@ -186,6 +187,13 @@ def _base_get_object(obj, key, default=UNSET): return value +def _raise_if_restricted_key(key): + # Prevent access to dunder-methods since this could expose access to globals through leaky + # attributes such as obj.__init__.__globals__. + if len(key) > 4 and key.isascii() and key.startswith("__") and key.endswith("__"): + raise KeyError(f"access to restricted key {key!r} is not allowed") + + def base_set(obj, key, value, allow_override=True): """ Set an object's `key` to `value`. If `obj` is a ``list`` and the `key` is the next available @@ -213,6 +221,7 @@ def base_set(obj, key, value, allow_override=True): obj[:] = (obj + [None] * key)[:key] obj.append(value) elif (allow_override or not hasattr(obj, key)) and obj is not None: + _raise_if_restricted_key(key) setattr(obj, key, value) return obj
tests/test_objects.py+24 −0 modified@@ -380,6 +380,30 @@ def test_get__should_not_populate_defaultdict(): assert data == {} +@parametrize( + "obj,path", + [ + (helpers.Object(), "__init__"), + (helpers.Object(subobj=helpers.Object()), "subobj.__init__"), + (namedtuple("a", ["a"])(a=1), "__len__"), + ], +) +def test_get__raises_for_objects_when_path_restricted(obj, path): + with pytest.raises(KeyError, match="access to restricted key"): + _.get(obj, path) + + +@parametrize( + "obj,path", + [ + ({}, "__init__"), + ([], "__contains__"), + ], +) +def test_get__does_not_raise_for_dict_or_list_when_path_restricted(obj, path): + assert _.get(obj, path) is None + + @parametrize( "case,expected", [
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- github.com/advisories/GHSA-8mjr-6c96-39w8ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2023-26145ghsaADVISORY
- gist.github.com/CalumHutton/45d33e9ea55bf4953b3b31c84703dfcaghsaWEB
- github.com/dgilland/pydash/commit/6ff0831ad285fff937cafd2a853f20cc9ae92021ghsaWEB
- github.com/pypa/advisory-database/tree/main/vulns/pydash/PYSEC-2023-179.yamlghsaWEB
- security.snyk.io/vuln/SNYK-PYTHON-PYDASH-5916518ghsaWEB
News mentions
0No linked articles in our index yet.