The vulnerability lies in the unconditional preservation of unknown fields during the binary decoding of protobuf messages, which can lead to excessive memory allocation and a potential denial of service. The analysis of the patch between the vulnerable version 8.4.2 and the patched version 8.5.0 pinpointed the exact code changes made to address this issue.
The core of the vulnerability is in the decoder function within src/decoder.js. This function dynamically generates the source code for a message's decode method. The patch shows that prior to the fix, the generated code would always execute logic to store unknown fields. The fix wraps this logic in a conditional block: if(!r.discardUnknown). This directly addresses the vulnerability by allowing the caller to control whether unknown fields are stored.
The Reader class in src/reader.js was also modified to add the discardUnknown property. This property serves as the flag that the decoder-generated function checks. While the Reader itself isn't the source of the memory allocation, it's a key component of the exploitation and mitigation path, as it carries the state that determines the decoder's behavior.
Therefore, any runtime profile of an exploitation attempt would involve a call to a message-specific decode method (e.g., MyMessage.decode), which is the function generated by the vulnerable decoder factory. The decoder function is identified as the primary vulnerable function because it is the source of the flawed logic.