Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for auth bypass via X-Fowarded-For and X-Real-IP #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ func (c *httpClient) RequestURL(u *url.URL) (*http.Response, error) {
if err != nil {
return resp, err
}
// Check if we can bypass auth checks via X-Forwarded-For & X-Real-IP
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add a flag to enable/disable this, as it could greatly increase number of requests.

if (resp.StatusCode>= 400) && (resp.StatusCode <600){
switch resp.StatusCode{
case 401,403,504,511:
req = c.makeRequest(u, method)
req.Header.Add("X-Forwarded-For","127.0.0.1")
req.Header.Add("X-Real-IP" ,"127.0.0.1")
resp_temp, err := c.Client.Do(req)
if (err == nil) && (resp_temp.StatusCode>=200) && (resp_temp.StatusCode<400){

logging.Logf(logging.LogWarning,"Pontential AUTH BYPASS in " + u.String() + " via X-Forwarded-For/X-Real-IP: 127.0.0.1")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential.

}

default:

}
}
// Handle an authentication required response
if resp.StatusCode == 401 {
authHeader := resp.Header.Get("WWW-Authenticate")
Expand Down