The analysis is based on the provided commit 0e835663df32b09b828528c07a5507686e6d975e. The commit message explicitly states 'fix(compressor): fixing an overflow that could potentially smuggle query in from data'. The diff shows changes in compress/writer.go, specifically within the Compress method of the Writer struct. The added lines introduce a check to prevent an integer overflow when calculating the size of the compressed data (n + compressHeaderSize). This overflow, if it occurred, would affect how the w.Data slice is sized, which is critical for correctly framing the compressed data. An incorrect frame size could allow an attacker to append malicious data that gets misinterpreted as part of a subsequent query, leading to query smuggling. Therefore, the (*Writer).Compress function is identified as the vulnerable function because it's where the overflow could occur and where the fix was applied.
Based on the commit information, the vulnerable function is (*Writer).Compress in compress/writer.go. The patch introduces a check to prevent an integer overflow when calculating the compressed data size. Without this check, a large input could cause n + headerSize to wrap around, leading to a smaller-than-expected buffer allocation for w.Data. This could allow an attacker to write data beyond the intended buffer, potentially smuggling additional query packets into the stream. The function processes input (data to be compressed) and is directly involved in the size calculation that was flawed.
Runtime Indicators: During exploitation, a profiler would likely show (*Writer).Compress as a function being executed. If logging or detailed stack traces are available, this function would appear when the oversized malicious data is processed.
Precise Function Signature: github.com/ClickHouse/ch-go/compress.(*Writer).Compress (assuming the package structure and how Go profilers typically represent method calls on struct pointers). The file path is compress/writer.go.
Confidence: High, as the patch directly addresses the overflow in this specific function, and the commit message confirms the vulnerability context (query smuggling due to overflow).