The analysis started by examining the security advisory GHSA-3cw6-2j68-868p, which describes a crash in Envoy when handling scoped IPv6 addresses. The advisory pointed to the function Utility::getAddressWithPort as the source of the crash, triggered by either the original_src filter or DNS resolution. To find the exact code changes, I identified the patched versions from the advisory and used the compare_two_commits tool to find the commits between the last vulnerable version (v1.34.12) and the first patched version (v1.34.13). This led to the identification of the fixing commit e1a7e0df7b78035f04204f49ff61371abecd8861.
Analyzing this commit's diff revealed the core of the vulnerability in source/common/network/utility.cc, within the Envoy::Network::Utility::getAddressWithPort function. The original code was losing the scope ID of IPv6 addresses by converting them to a string before creating a new address object. The fix involves copying the underlying socket address structure (sockaddr_in6) to preserve the scope ID.
The commit also included changes to test files, specifically test/extensions/filters/common/original_src/original_src_socket_option_test.cc. The new test case, SocketOptionFactoryTest.BuildOriginalSrcOptionsWithScopedIpv6, confirmed that the original_src filter, through the buildOriginalSrcOptions function, is a vector for this vulnerability. This provided a second, higher-level function that would appear in a profiler during exploitation via the original_src filter. While the advisory also mentions DNS resolution as a trigger, the provided patch did not contain enough information to pinpoint a specific function in the DNS filter's code.