mirror of
https://github.com/gin-gonic/gin.git
synced 2026-04-29 23:23:18 +08:00
fix: sanitize Proxy-Authorization header in recovery panic logs
secureRequestDump only masks the Authorization header but not Proxy-Authorization, which also carries credentials (used by gin's own BasicAuthForProxy middleware). When a panic occurs behind proxy auth, credentials are logged in plaintext.
This commit is contained in:
parent
cf3be80b0e
commit
08e51b48be
@ -99,8 +99,8 @@ func secureRequestDump(r *http.Request) string {
|
|||||||
httpRequest, _ := httputil.DumpRequest(r, false)
|
httpRequest, _ := httputil.DumpRequest(r, false)
|
||||||
lines := strings.Split(bytesconv.BytesToString(httpRequest), "\r\n")
|
lines := strings.Split(bytesconv.BytesToString(httpRequest), "\r\n")
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
if strings.HasPrefix(line, "Authorization:") {
|
if strings.HasPrefix(line, "Authorization:") || strings.HasPrefix(line, "Proxy-Authorization:") {
|
||||||
lines[i] = "Authorization: *"
|
lines[i] = strings.SplitN(line, ":", 2)[0] + ": *"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strings.Join(lines, "\r\n")
|
return strings.Join(lines, "\r\n")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user