The vulnerability exists in the swift-w3c-trace-context package, where improper input validation of the W3C traceparent HTTP header can lead to a denial-of-service. The root cause is in the Hex.convert function, which is responsible for converting hexadecimal strings to bytes. Prior to the patch, this function would only accept lowercase hexadecimal characters (0-9, a-f). If it encountered any other character, such as an uppercase letter, it would call preconditionFailure(), causing the entire service to crash.
The primary public-facing function that triggers this vulnerability is the TraceContext.init(traceParentHeaderValue:) initializer. This function takes the raw traceparent header value as input and passes substrings of it to the Hex.convert function to extract the traceID, spanID, and traceFlags. A remote attacker could craft a traceparent header with uppercase hexadecimal characters, which, when processed by a server using the vulnerable library (e.g., via Swift OTel), would trigger the crash.
The patch addresses this by modifying Hex.convert to throw a TraceParentDecodingError.invalidCharacter instead of crashing. Consequently, the TraceContext.init(traceParentHeaderValue:) initializer was updated to handle this potential error using try, thus preventing the denial-of-service.