The vulnerability lies in the lack of recursion depth control when converting protobuf messages to JSON or plain JavaScript objects. Specifically, when a message contains a google.protobuf.Any field, the library attempts to unpack and convert it recursively. An attacker could craft a message with deeply nested Any fields pointing to other Any messages, leading to an infinite recursion and causing a denial of service through a stack overflow.
The patch addresses this by introducing a recursion depth counter (depth or q) to the relevant conversion functions: wrappers['.google.protobuf.Any'].toObject, the dynamically generated toObject methods (created by converter.toObject), and the Type.prototype.toObject entry point. This counter is incremented with each level of recursion, and if it exceeds a predefined recursionLimit, the operation is aborted, preventing the stack overflow.