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

HTTP "Host" header incorrectly includes port, causes SNI to fail #133

Open
rocketmonkeys opened this issue Dec 13, 2018 · 0 comments
Open

Comments

@rocketmonkeys
Copy link

I've been having issues where using a clair URL like https://xxx.xxx.xxx.xxx (via IP name) works, but the same via domain name (https://clairserver) does not. The clairctl error I get is "503: requested access to the resource is denied". The 503 is coming from haproxy.

This happens when setting the port to anything (including 443). However, if I set port to 0, it works.

From what I can tell, clairctl is putting the port into the http HOST header (!), which causes it to fail.

// Bad, includes port:
eg. "Host: clairserver:443"

// Good, should not include port:
eg. "Host: clairserver"

The fix is that the http Host header should never contain the port. I see the code where the port is added for the clair URL, but I can't find in the code where the port is added to the host header. I suspect it might be something like this

// In server.go:
out, _ := url.Parse(host)
request.URL.Scheme = out.Scheme
request.URL.Host = out.Host  <<-- bad?

The docs for url.Parse() say:

Host       string    // host or host:port

(https://golang.org/pkg/net/url/#Parse)

If "request.URL.Host" is being used as the host header, and if url.Parse() is returning "host:port", then that would cause this issue. The fix would be to make sure that "request.URL.Host" only gets the actual host part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant