The vulnerability CVE-2024-6104 states that go-retryablehttp prior to 0.7.7 did not sanitize URLs when writing them to its log file, potentially leaking basic auth credentials. The provided commit a99f07beb3c5faaa0a283617e6eb6bcf25f5049a addresses this issue.
By examining the diff of this commit, specifically in the client.go file, all modifications related to logging or formatting error messages that include the request URL are within the (*Client).Do method.
For example, the line:
- v.Debug("performing request", "method", req.Method, "url", req.URL)
+ v.Debug("performing request", "method", req.Method, "url", redactURL(req.URL))
and other similar changes for v.Printf, v.Error, and fmt.Sprintf / fmt.Errorf calls clearly show that req.URL was previously used directly for logging and error reporting within the Do method. The patch introduces the redactURL function to sanitize the URL before it's logged or included in error messages.
Therefore, the (*Client).Do function is identified as the vulnerable function because it handled the request URL and, in its unpatched state, passed it directly to logging mechanisms, causing the credential leak.