The vulnerability lies in the processing of gzip-compressed streams from external sources (APK files and repository indexes) without proper size limits. The core issue is the use of io.Copy and gzip.NewReader on untrusted data, which can be exploited using "gzip bombs"—small, highly compressed files that decompress to a very large size. This leads to excessive CPU and memory usage, causing a denial of service.
The patch addresses this by introducing a new package, limitio, which provides a size-limited reader. This limited reader is then applied in all the functions that process external gzip streams:
expandapk.Split: The function that splits an APK into its components. The patch adds a limit when reading the signature and control data streams.
expandapk.ExpandApk: The function that expands an APK. The patch adds limits when reading both the control and data sections of the APK.
apk.IndexFromArchive: The function that parses repository indexes. The patch adds a limit to the size of the decompressed index.
By identifying these functions, we can pinpoint the exact locations in the code that would be exercised during an exploit. A runtime profiler would show these functions consuming significant resources when processing a malicious file.