The vulnerability (CVE-2025-4565, GHSA-8qvm-5x2c-j2w7) is a Denial of Service in the pure-Python implementation of Google's Protocol Buffers library. It arises from uncontrolled recursion when parsing protobuf messages containing an arbitrary number of recursive groups, recursive messages, or a series of SGROUP tags.
The root cause is the lack of recursion depth checking in the decoder functions responsible for parsing message fields. Specifically, the functions DecodeRepeatedField, DecodeField, and _DecodeUnknownField in python/google/protobuf/internal/decoder.py would make calls that could lead to further recursion (e.g., calling _InternalParse on a sub-message or _DecodeUnknownFieldSet for nested groups) without first checking the current recursion depth.
An attacker could craft a malicious protobuf message with excessively deep nesting. When parsed by the vulnerable pure-Python decoder, these functions would recurse deeply, eventually exceeding Python's default recursion limit, leading to a RecursionError (surfaced as a DecodeError by the library) and causing a Denial of Service for the application processing the malicious data.
The commit 17838beda2943d08b8a9d4df5b68f5f04f26d901 mitigates this vulnerability by introducing a recursion counter (current_depth) and a configurable limit (_recursion_limit) within these identified decoder functions. Before making a call that could deepen the recursion, the current depth is incremented and checked against the limit. If the limit is exceeded, a _DecodeError is raised, preventing the stack overflow.
The identified functions are precisely where these checks were missing and subsequently added, making them the locations containing the vulnerability. During exploitation, these functions, along with Message._InternalParse (which is called by DecodeField and DecodeRepeatedField), would appear in the stack trace as the recursion unfolds.