CVE-2025-12781
Python Interpreter vulnerability analysis and mitigation

Overview

CVE-2025-12781 is a data integrity vulnerability in Python's base64 standard library module, where the b64decode(), standard_b64decode(), and urlsafe_b64decode() functions unconditionally accept the characters + and / regardless of the altchars parameter value used to specify an alternative base64 alphabet. This behavior follows older base64 RFCs but conflicts with newer RFC recommendations that require rejecting or erroring on out-of-alphabet characters. The vulnerability was reported on October 12, 2024 (GitHub issue #125346), publicly disclosed on January 21, 2026, and affects all Python versions before 3.13.10, versions 3.14.0 through 3.14.1 (exclusive), and 3.15.0-alpha1. It carries a CVSS v3.1 score of 5.3 (Medium) and a CVSS v4.0 score of 6.3 (Medium) (Red Hat CVE, CPython Issue).

Technical details

The root cause is classified as CWE-704 (Incorrect Type Conversion or Cast): the base64 decoding functions perform an implicit character substitution step that maps altchars onto +/ before decoding, meaning the standard +/ characters remain valid even when a completely different alphabet is specified via altchars. An attacker who can supply user-controlled base64 input to an application using a custom alphabet (e.g., URL-safe -_ instead of +/) can craft input containing the standard +/ characters that will be silently accepted and decoded, producing output the application did not intend to process. The vulnerability is only exploitable in applications that explicitly use the altchars parameter or urlsafe_b64decode() with a non-standard alphabet; applications using the default base64 alphabet are unaffected. The fix, implemented in PR #141128 by Serhiy Storchaka, emits deprecation/future warnings rather than raising errors to avoid breaking existing programs (CPython PR, CPython Issue).

Impact

Successful exploitation can cause data integrity violations where decoded binary data differs from what the application expected based on its specified base64 alphabet, potentially allowing malformed or unintended data to pass through input validation. Applications relying on the custom alphabet as a security boundary (e.g., to distinguish URL-safe tokens from standard base64 tokens) may incorrectly accept and process attacker-supplied data. There is no confidentiality or availability impact; the scope is limited to integrity of decoded data within the affected application (Red Hat CVE, CPython Issue).

Exploitation steps

  1. Identify target application: Locate a Python application that uses base64.b64decode() with a custom altchars parameter (e.g., altchars='-_' for URL-safe encoding) or calls urlsafe_b64decode(), and accepts user-controlled base64 input.
  2. Craft malicious input: Construct a base64 string using the standard + or / characters that would normally be rejected by the custom alphabet. For example, if the application expects URL-safe base64 (-_ alphabet), submit a string like /+/+ instead of the expected -_-_.
  3. Submit input: Pass the crafted string to the vulnerable decode function. Due to the flaw, base64.b64decode('/+/+', altchars='-_') will silently decode the input as if +/ were valid, producing b'\xff\xef\xfe'.
  4. Achieve integrity bypass: The decoded output bypasses the application's assumed alphabet restriction, potentially causing the application to process data it was not designed to handle, circumventing token validation, signature checks, or other logic that depends on alphabet exclusivity (CPython Issue, CPython PR).

Mitigation and workarounds

Upgrade Python to version 3.13.10 or later, 3.14.1 or later, or 3.15.0-alpha1 or later, which introduce deprecation warnings when + or / characters appear in base64 data decoded with a non-standard alphabet. As an immediate workaround for applications that cannot upgrade, validate user-controlled base64 inputs against the expected alphabet before passing them to decode functions (e.g., reject inputs containing + or / when using a URL-safe alphabet). IBM has also released patches for affected watsonx Orchestrate with watsonx Assistant Cartridge products (Python Mailing List, IBM Advisory).

Community reactions

The Python Security team coordinated the fix through the standard CPython security process, with core developer Serhiy Storchaka authoring the patch and Seth Larson (PSF Security Developer-in-Residence) reviewing it. Reviewer commentary in the PR discussion highlighted concerns about subtle breakages from behavior changes, ultimately leading to a deprecation warning approach rather than an immediate error to preserve backward compatibility. IBM issued a security bulletin for downstream products (watsonx Orchestrate) affected by this CVE (CPython PR, IBM Advisory).

Additional resources


SourceThis report was generated using AI

Related Python Interpreter vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-15308HIGH8.7
  • Rocky Linux logoRocky Linux
  • tkinter
NoYesJul 09, 2026
CVE-2026-11972HIGH8.2
  • Python Interpreter logoPython Interpreter
  • python3.11
NoYesJun 23, 2026
CVE-2026-11940HIGH7.8
  • Python Interpreter logoPython Interpreter
  • python3-libs
NoYesJun 23, 2026
CVE-2026-0864MEDIUM4.1
  • Python Interpreter logoPython Interpreter
  • python3.13-idle
NoYesJun 23, 2026
CVE-2026-4360LOW2
  • Python Interpreter logoPython Interpreter
  • python3.10
NoYesJun 30, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management