# CVE-2025-12781: base64.b64decode() always accepts "+/" characters, despite setting altchars

> Python's base64 decoder accepts standard characters even when an alternative alphabet is specified, potentially causing data integrity issues in applications relying on strict validation.

- **Severity:** Medium 6.3 (`CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 21 Jan 2026
- **Updated:** 22 Jan 2026
- **Also known as:** AZL-109683, AZL-75225, AZL-75231, AZL-84287, BELL-CVE-2025-12781, BIT-libpython-2025-12781, BIT-python-2025-12781, BIT-python-min-2025-12781, DEBIAN-CVE-2025-12781, ECHO-f28e-a9d3-d8e5, GHSA-hfpw-x3fg-wmmg, MINI-4rp5-6j95-7fw4, MINI-m46w-6g95-3rfp, MINI-r2jq-j369-2r72, MINI-rv7h-86w8-4rmq, MINI-wcp7-6fr5-r7x8, PSF-2026-7, ROOT-OS-DEBIAN-11-CVE-2025-12781, ROOT-OS-DEBIAN-12-CVE-2025-12781, ROOT-OS-DEBIAN-13-CVE-2025-12781, UBUNTU-CVE-2025-12781

## What is CVE-2025-12781?

CVE-2025-12781 is a medium-severity vulnerability in Python Python, published on 21 Jan 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

When passing data to the b64decode(), standard_b64decode(), and urlsafe_b64decode() functions in the "base64" module the characters "+/" will always be accepted, regardless of the value of "altchars" parameter, typically used to establish an "alternative base64 alphabet" such as the URL safe alphabet. This behavior matches what is recommended in earlier base64 RFCs, but newer RFCs now recommend either dropping characters outside the specified base64 alphabet or raising an error. The old behavior has the possibility of causing data integrity issues.

This behavior can only be insecure if your application uses an alternate base64 alphabet (without "+/"). If your application does not use the "altchars" parameter or the urlsafe_b64decode() function, then your application does not use an alternative base64 alphabet.

The attached patches DOES NOT make the base64-decode behavior raise an error, as this would be a change in behavior and break existing programs. Instead, the patch deprecates the behavior which will be replaced with the newly recommended behavior in a future version of Python. Users are recommended to mitigate by verifying user-controlled inputs match the base64 
alphabet they are expecting or verify that their application would not be 
affected if the b64decode() functions accepted "+" or "/" outside of altchars.

Weakness: CWE-704 (Incorrect Type Conversion or Cast)

## Which versions are affected by CVE-2025-12781?

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 | All versions | 3.15.0 |
| `python` | Bitnami | All versions | 3.15.0 |
| `python-min` | Bitnami | All versions | 3.15.0 |

Products: Python Python.

## How do I fix CVE-2025-12781?

Upgrade libpython to 3.15.0 or later.

## Is CVE-2025-12781 being exploited?

There is no known exploitation of CVE-2025-12781 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-2025-12781 and fix it if it is affected.

What it is: CVE-2025-12781 is a medium-severity vulnerability in Python Python, published on 21 Jan 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-12781 in the wild and no public exploit code.

Affected packages and fixed versions:
- libpython (Bitnami): affected all versions; fixed in 3.15.0
- python (Bitnami): affected all versions; fixed in 3.15.0
- python-min (Bitnami): affected all versions; fixed in 3.15.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-2025-12781/ (Markdown: https://insights.sbomify.com/CVE-2025-12781/index.md)
```

## Sources

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

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