You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
Minimal reproduction of problem: https://go.dev/play/p/z-sitms7DpF
Returning http.DefaultClient, programmers can sometimes pollute global variable unintentionally. It's because http.DefaultClient is a pointer. Recently, a similar mistake caused a vulnerability https://pkg.go.dev/vuln/GO-2024-2618.
Description
Currently, function ContextClient() in internal package returns http.DefaultClient under some situation.
ifhc, ok:=ctx.Value(HTTPClient).(*http.Client); ok {
returnhc
}
}
returnhttp.DefaultClient
}
Some functions that utilize internal.ContextClient(), like oauth2.NewClient(), can also return http.DefaultClient. Since http.DefautClient is a pointer, modifying returned default client cause change in global variable and possibly break entire application randomly.
I suggest returning a new instance &http.Client{}, that is same as a definition of http.DefaultClient.
The text was updated successfully, but these errors were encountered:
Problem
Minimal reproduction of problem: https://go.dev/play/p/z-sitms7DpF
Returning
http.DefaultClient
, programmers can sometimes pollute global variable unintentionally. It's becausehttp.DefaultClient
is a pointer. Recently, a similar mistake caused a vulnerability https://pkg.go.dev/vuln/GO-2024-2618.Description
Currently, function
ContextClient()
ininternal
package returnshttp.DefaultClient
under some situation.oauth2/internal/transport.go
Lines 21 to 28 in d0e617c
Some functions that utilize
internal.ContextClient()
, likeoauth2.NewClient()
, can also returnhttp.DefaultClient
. Sincehttp.DefautClient
is a pointer, modifying returned default client cause change in global variable and possibly break entire application randomly.I suggest returning a new instance
&http.Client{}
, that is same as a definition ofhttp.DefaultClient
.The text was updated successfully, but these errors were encountered: