CVE-2025-12781
cpython: base64.b64decode() always accepts "+/" characters, despite setting altchars
Severity
ModerateRed Hat Product Security
CVSS 3.1
Review impact separately from score.
Published · January 22, 2026
Updated · June 26, 2026
Description
A flaw was found in the base64 module in the Python standard library. The b64decode, standard_b64decode and urlsafe_b64decode functions will always accept the '+' and '/' characters even when an alternative base64 alphabet is specified via the altchars parameter that excludes them. This input validation bypass allows malformed or unexpected data to pass through decoding filters, potentially causing logical errors or data integrity issues in applications relying on strict character sets.
Statement
This issue can only be exploited by Python applications that use the base64 functions to validate if a string is safe for a URL or filename without additional input validation. Additionally, this flaw affects only the base64 functions when an alternative alphabet is specified via the altchars parameter, limiting its exposure. This issue can cause logical errors and integrity issues but it does not allow direct access to system data or critical files, as the exploitation depends on how the application processes the decoded data. Due to these reasons, this vulnerability has been rated with a moderate severity.
CVSS score applicability
The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Mitigation
To mitigate this issue, implement manual input validation before calling the base64 functions with an alternative alphabet, ensuring to reject any string containing the standard base64 characters, such as '+' and '/', that are not part of the expected alphabet.
CVSS / CWE
CVSS 3.1 · 5.3CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
CWE-20 · Improper Input Validation