CVE-2025-12781 Details
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.
A vulnerability exists in the base64 module of Python's CPython implementation, specifically in the b64decode(), standard_b64decode(), and urlsafe_b64decode() functions. When using the altchars parameter to define an alternative base64 alphabet, these functions still accept the standard base64 characters '+' and '/', regardless of the specified alternative. This behavior, which aligns with older base64 RFCs, can lead to data integrity issues, as newer RFCs recommend either removing characters not in the specified alphabet or raising an error. The vulnerability is only a concern if an application uses an alternative base64 alphabet that excludes '+' and '/'.
Users are advised to manually check that inputs to the base64 decoding functions conform to the expected base64 alphabet, especially when using alternative alphabets. In Python 3.15 and later, the base64.b64decode() function will reject invalid characters by default, but this change is not yet in effect for urlsafe_b64decode().
Metrics
CVSS 4.0 Severity and Vector Strings:
CVSS 3.x Severity and Vector Strings:
No data available for CVSS Version 2.0 on this CVE.
CISA-ADP
Assessed Jan 22, 2026References to Advisories, Solutions, and Tools
By selecting these links, you will be leaving this site. These are references gathered from the official CVE record and are not endorsed by Volerion.
Weakness Enumeration
| CWE-ID | CWE Name | Source |
|---|---|---|
| CWE-704 | Incorrect Type Conversion or Cast | CISA-ADP |
Affected Products
| Product | Versions |
|---|---|
| python python | < 3.13.10 >= 3.14.0, < 3.14.1 3.15.0 alpha1 |
CPE
Remediation
| |
Change History
6 change records found show changes
| Date | Action | Recorded By |
|---|---|---|
| Jun 17, 2026 | CVE Modified | [email protected] |
| Jun 17, 2026 | CVE Modified | CISA-ADP |
| Feb 2, 2026 | Initial Analysis | [email protected] |
| Jan 22, 2026 | CVE Modified | [email protected] |
| Jan 22, 2026 | CVE Modified | CISA-ADP |
| Jan 21, 2026 | New CVE Received | [email protected] |