# CVE-2023-26145: pydash Command Injection vulnerability

> Attackers can execute arbitrary code via command injection in pydash invoke methods if they control path strings and arguments.

- **Severity:** High 7.4 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N/E:P`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 28 Sep 2023
- **Updated:** 23 Sep 2024
- **Also known as:** GHSA-8mjr-6c96-39w8, PYSEC-2023-179

## What is CVE-2023-26145?

CVE-2023-26145 is a high-severity code injection vulnerability in pydash, published on 28 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-94 (Improper Control of Generation of Code), CWE-77 (Improper Neutralization of Special Elements used in a Command), CWE-78 (Improper Neutralization of Special Elements used in an OS Command)

## Which versions are affected by CVE-2023-26145?

3 open source packages ship an affected version, including pydash. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pydash` | PyPI | All versions | 6.0.0 |
| `pydash` | PyPI | All versions | 6.0.0 |
| `pydash` | PyPI | All versions | 6.0.0 |

Products: Derrickgilland Pydash.

## How do I fix CVE-2023-26145?

Upgrade pydash to 6.0.0 or later.

## Is CVE-2023-26145 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-26145 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-26145 and fix it if it is affected.

What it is: CVE-2023-26145 is a high-severity code injection vulnerability in pydash, published on 28 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-26145 exists.

Affected packages and fixed versions:
- pydash (PyPI): affected all versions; fixed in 6.0.0
- pydash (PyPI): affected all versions; fixed in 6.0.0
- pydash (PyPI): affected all versions; fixed in 6.0.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-26145/ (Markdown: https://insights.sbomify.com/CVE-2023-26145/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-26145
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-26145
- OSV: https://osv.dev/vulnerability/CVE-2023-26145

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-26145/
Summaries are generated and may contain mistakes; the official description above is the record.
