Skip to content

Commit ce58b85

Browse files
Potential fix for code scanning alert no. 11: Clear-text logging of sensitive information
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 8605ae8 commit ce58b85

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

third-party/github.com/letsencrypt/boulder/akamai/cache-client.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,9 @@ func CheckSignature(secret string, url string, r *http.Request, body []byte) err
331331
h.Write(input)
332332
expectedSignature := base64.StdEncoding.EncodeToString(h.Sum(nil))
333333
if signature != expectedSignature {
334-
return fmt.Errorf("expected signature %q, got %q in %q",
335-
signature, authorization, expectedSignature)
334+
sanitizedAuth := sanitizeAuthorizationHeader(authorization)
335+
return fmt.Errorf("expected signature %q, got sanitized authorization header %q in %q",
336+
signature, sanitizedAuth, expectedSignature)
336337
}
337338
return nil
338339
}
@@ -344,6 +345,14 @@ func reverseBytes(b []byte) []byte {
344345
return b
345346
}
346347

348+
// sanitizeAuthorizationHeader obfuscates sensitive parts of the Authorization header.
349+
func sanitizeAuthorizationHeader(authHeader string) string {
350+
if len(authHeader) > 10 {
351+
return authHeader[:5] + "..." + authHeader[len(authHeader)-5:]
352+
}
353+
return "REDACTED"
354+
}
355+
347356
// makeOCSPCacheURLs constructs the 3 URLs associated with each cached OCSP
348357
// response.
349358
func makeOCSPCacheURLs(req []byte, ocspServer string) []string {

third-party/github.com/letsencrypt/boulder/test/akamai-test-srv/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func main() {
6161
}
6262
if err = akamai.CheckSignature(*secret, "http://"+*listenAddr, r, body); err != nil {
6363
w.WriteHeader(http.StatusUnauthorized)
64-
fmt.Println("Bad signature:", err)
64+
fmt.Println("Bad signature error:", err)
6565
return
6666
}
6767
if err = json.Unmarshal(body, &purgeRequest); err != nil {

0 commit comments

Comments
 (0)