The analysis of the security advisory and the associated commit c724f4bd6fd88e9a599af1668bf7af9487155b62 reveals two distinct memory consumption vulnerabilities in the OpenTelemetry Zipkin exporter for .NET. The root cause for both is the allocation of resources without proper limits.
-
Unbounded Endpoint Cache: The primary vulnerability, as described in the advisory, is an unbounded cache for remote service endpoints. The function OpenTelemetry.Exporter.Zipkin.Implementation.ZipkinActivityConversionExtensions.ToZipkinSpan is responsible for processing telemetry data. It extracts a peer.service attribute and uses it as a key for a cache. The original implementation used a standard ConcurrentDictionary, which has no built-in size limit. An attacker or a high-cardinality workload could supply a stream of spans with unique peer.service values, causing the cache to grow indefinitely and leading to excessive memory usage and potential process termination. The patch replaces the ConcurrentDictionary with a custom, bounded LRU cache (ZipkinEndpointLruCache) to cap its size.
-
Unbounded MemoryStream Capacity: A secondary issue was fixed in the same patch within the OpenTelemetry.Exporter.Zipkin.Implementation.JsonStringArrayTagWriter.JsonArrayTagWriter.Write function. This function uses a ThreadStatic MemoryStream for performance when serializing array tags. If a very large array was serialized, the underlying MemoryStream would allocate a large buffer. This buffer's capacity was never reduced, so the memory remained allocated for the thread's lifetime, even if subsequent uses were small. The patch hardens this by checking the stream's capacity after use and resetting it if it exceeds a defined maximum, thus releasing the excess memory.
Both functions are directly involved in processing potentially untrusted or high-cardinality telemetry data, and the modifications in the patch directly address the uncontrolled resource allocation that leads to the vulnerability.