# CVE-2023-41334: astropy vulnerable to RCE in TranformGraph().to_dot_graph function

> A command injection vulnerability in the astropy library allows attackers to execute arbitrary code via the to_dot_graph function.

- **Severity:** High 8.4 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 18 Mar 2024
- **Updated:** 2 Aug 2024
- **Also known as:** DEBIAN-CVE-2023-41334, DLA-3803-1, GHSA-h2x6-5jx5-46hf, MGASA-2024-0313, PYSEC-2026-1199, UBUNTU-CVE-2023-41334, openSUSE-SU-2024:13797-1, openSUSE-SU-2026:11353-1

## What is CVE-2023-41334?

CVE-2023-41334 is a high-severity command injection vulnerability in astropy, published on 18 Mar 2024. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

Astropy is a project for astronomy in Python that fosters interoperability between Python astronomy packages. Version 5.3.2 of the Astropy core package is vulnerable to remote code execution due to improper input validation in the `TranformGraph().to_dot_graph` function. A malicious user can provide a command or a script file as a value to the `savelayout` argument, which will be placed as the first value in a list of arguments passed to `subprocess.Popen`.  Although an error will be raised, the command or script will be executed successfully. Version 5.3.3 fixes this issue.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command)

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

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `astropy` | PyPI | All versions | 5.3.3 |
| `astropy` | PyPI | All versions | 5.3.3 |
| `astropy` | PyPI | All versions | 5.3.3 |
| `python-astropy` | openSUSE:Tumbleweed | All versions | 8.0.1-1.1 |

Products: Astropy Astropy.

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

Upgrade astropy to 5.3.3 or later.

## Is CVE-2023-41334 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2023-41334 is a high-severity command injection vulnerability in astropy, published on 18 Mar 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-41334 exists.

Affected packages and fixed versions:
- astropy (PyPI): affected all versions; fixed in 5.3.3
- astropy (PyPI): affected all versions; fixed in 5.3.3
- astropy (PyPI): affected all versions; fixed in 5.3.3

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-41334/ (Markdown: https://insights.sbomify.com/CVE-2023-41334/index.md)
```

## Sources

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

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