fix: disable redirects to guard against possible SSRFs
This commit is contained in:
parent
b8fe446152
commit
f40135dbf2
@ -29,7 +29,14 @@ func GetWebfingerLinks(account string) ([]map[string]interface{}, error) {
|
|||||||
query.Add("resource", fmt.Sprintf("acct:%s", account))
|
query.Add("resource", fmt.Sprintf("acct:%s", account))
|
||||||
requestURL.RawQuery = query.Encode()
|
requestURL.RawQuery = query.Encode()
|
||||||
|
|
||||||
response, err := http.DefaultClient.Get(requestURL.String())
|
// Do not support redirects.
|
||||||
|
client := &http.Client{
|
||||||
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := client.Get(requestURL.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,13 @@ func HandleCallbackCode(code, state string) (*Request, *Response, error) {
|
|||||||
data.Set("redirect_uri", request.Callback.String())
|
data.Set("redirect_uri", request.Callback.String())
|
||||||
data.Set("code_verifier", request.CodeVerifier)
|
data.Set("code_verifier", request.CodeVerifier)
|
||||||
|
|
||||||
client := &http.Client{}
|
// Do not support redirects.
|
||||||
|
client := &http.Client{
|
||||||
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
r, err := http.NewRequest("POST", request.Endpoint.String(), strings.NewReader(data.Encode())) // URL-encoded payload
|
r, err := http.NewRequest("POST", request.Endpoint.String(), strings.NewReader(data.Encode())) // URL-encoded payload
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user