# CVE-2023-6507: Groups not dropped before running subprocess when using empty 'extra_groups' parameter

> Attackers can retain original group privileges when spawning subprocesses with empty extra_groups in privileged Python applications.

- **Severity:** Medium 6.1 (`CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 8 Dec 2023
- **Updated:** 31 Jul 2026
- **Also known as:** AZL-35143, BIT-libpython-2023-6507, BIT-python-2023-6507, BIT-python-min-2023-6507, GHSA-4wxh-fpjf-c8wf, PSF-2023-12, PSF-CVE-2023-6507, openSUSE-SU-2024:13511-1

## What is CVE-2023-6507?

CVE-2023-6507 is a medium-severity vulnerability in Python Python, published on 8 Dec 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

An issue was found in CPython 3.12.0 `subprocess` module on POSIX platforms. The issue was fixed in CPython 3.12.1 and does not affect other stable releases.

When using the `extra_groups=` parameter with an empty list as a value (ie `extra_groups=[]`) the logic regressed to not call `setgroups(0, NULL)` before calling `exec()`, thus not dropping the original processes' groups before starting the new process. There is no issue when the parameter isn't used or when any value is used besides an empty list.

This issue only impacts CPython processes run with sufficient privilege to make the `setgroups` system call (typically `root`).

Weakness: CWE-269 (Improper Privilege Management)

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

3 open source packages ship an affected version, including libpython, python and python-min. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libpython` | Bitnami | From 3.12.0 | 3.12.1 |
| `python` | Bitnami | From 3.12.0 | 3.12.1 |
| `python-min` | Bitnami | From 3.12.0 | 3.12.1 |
| `python312` | openSUSE:Tumbleweed | All versions | 3.12.1-1.1 |

Products: Python Python.

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

Upgrade libpython to 3.12.1 or later.

## Is CVE-2023-6507 being exploited?

There is no known exploitation of CVE-2023-6507 in the wild and no public exploit code.

## Other vulnerabilities in Python Python

- [CVE-2008-5031](https://insights.sbomify.com/CVE-2008-5031/): Integer overflow in n/a (critical 10.0)
- [CVE-2014-4650](https://insights.sbomify.com/CVE-2014-4650/): Path traversal in n/a (critical 9.8)
- [CVE-2016-5636](https://insights.sbomify.com/CVE-2016-5636/): Integer overflow in n/a (critical 9.8)
- [CVE-2007-4559](https://insights.sbomify.com/CVE-2007-4559/): Path traversal in n/a (critical 9.8)
- [CVE-2017-17522](https://insights.sbomify.com/CVE-2017-17522/): Command injection in n/a (high 8.8)

## Fix prompt for AI coding agents

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

What it is: CVE-2023-6507 is a medium-severity vulnerability in Python Python, published on 8 Dec 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-6507 in the wild and no public exploit code.

Affected packages and fixed versions:
- libpython (Bitnami): affected from 3.12.0; fixed in 3.12.1
- python (Bitnami): affected from 3.12.0; fixed in 3.12.1
- python-min (Bitnami): affected from 3.12.0; fixed in 3.12.1

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

## Sources

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

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