CVE-2025-12781: Python Software Foundation CPython · CWE-704
Affects Python Software Foundation CPythonSource CVE Database V5
Not known to be exploited · CVSS 6.3 Medium · fixed in 3.15.0a2 : update Python Software Foundation CPython when convenient.
Data as of 26 Oct 2026, 08:30 UTC
- EPSS
- 0.8% chance of exploitation in 30 days – higher than 58% of CVEsExploit Prediction Scoring System: the likelihood attackers will use this flaw soon.
- Patch
- Available – fixed in 3.15.0a2, 3.14.1, 3.13.10
CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:NExploitation evidence
Disclosed: evidence found.
CVE published 21 Jan 2026
Detectable: no evidence on record.
No public nuclei template indexed
Weaponised: no evidence on record.
No public exploit code indexed in Metasploit or Exploit-DB
Exploited in the wildExploited: no evidence on record.
Not in CISA KEV and no source reports exploitation
Observed by OffSeq MirageSeen by Mirage: no evidence on record.
No attack traffic recorded by OffSeq Mirage sensors
A missing step is not evidence of safety. Sources: cve.org (opens in a new tab), the Metasploit, Exploit-DB and nuclei-templates index as of 26 Oct 2026.
What to do
Upgrade Python Software Foundation CPython to 3.15.0a2, 3.14.1 or 3.13.10.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
| Python Software FoundationCPython | Affected
| Fixed in
|
PyPIcpythonpkg:pypi/cpythonOther threats | Affected
| Fixed in– |
GitHubCPythonpkg:github/CPythonOther threats | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
AI-suggested
European organizations should implement the following specific mitigations: 1) Audit all Python applications and libraries to identify usage of the base64 module's b64decode(), standard_b64decode(), and urlsafe_b64decode() functions, especially where the altchars parameter is used to specify alternate alphabets. 2) Implement strict input validation to ensure that any base64-encoded data strictly conforms to the expected alphabet, rejecting or sanitizing inputs containing '+' or '/' when these are not part of the intended encoding scheme. 3) Where possible, refactor applications to avoid reliance on alternate base64 alphabets or to handle decoding explicitly and safely. 5) Incorporate static and dynamic code analysis tools to detect improper base64 decoding usage patterns. 6) Educate developers and security teams about the implications of this vulnerability and the importance of encoding validation. 7) For critical systems, consider implementing additional data integrity checks post-decoding to detect corrupted or malformed data early. These steps go beyond generic advice by focusing on code auditing, input validation, and proactive patch management tailored to the specifics of this vulnerability.
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.
References
- github.com/python/cpython/pull/141128 (opens in a new tab)
- github.com/python/cpython/issues/125346 (opens in a new tab)
- mail.python.org/archives/list/security-announce@python.org/thread/KRI7GC6S27YV5NJ4FPDALS2WI5ENAFJ6/ (opens in a new tab)
- github.com/python/cpython/commit/13360efd385d1a7d0659beba03787ea3d063ef9b (opens in a new tab)
- github.com/python/cpython/commit/1be80bec7960f5ccd059e75f3dfbd45fca302947 (opens in a new tab)
- github.com/python/cpython/commit/9060b4abbe475591b6230b23c2afefeff26fcca5 (opens in a new tab)
- github.com/python/cpython/commit/e95e783dff443b68e8179fdb57737025bf02ba76 (opens in a new tab)
- github.com/python/cpython/commit/fd17ee026fa9b67f6288cbafe374a3e479fe03a5 (opens in a new tab)