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

client, health/client: set dummy host header on unix:// local communication #26800

Merged
merged 1 commit into from Jul 13, 2023

Conversation

tklauser
Copy link
Member

@tklauser tklauser commented Jul 13, 2023

Go 1.20.6 added a security fix [1] which leads to stricter sanitization of the HTTP host header in the net/http client. Cilium's pkg/client currently sets the Host header to the UDS path (e.g. /var/run/cilium/cilium.sock), however the slashes in that Host header now lead net/http to reject it.

RFC 7230, Section 5.4 states [2]:

If the authority component is missing or undefined for the target URI,
then a client MUST send a Host header field with an empty field-value.

The authority component is undefined for the unix:// scheme. Thus, the correct value to use would be the empty string. However, this does not work due to OpenAPI runtime using the same value for the URL's host and the http client's host header. Thus, use a dummy value "localhost".

[1] https://go.dev/issue/60374
[2] https://datatracker.ietf.org/doc/html/rfc7230#section-5.4

(The same security fix was backported to Go 1.19.11, so requesting backport to v1.13 as well given that the branch uses Go 1.19)

@tklauser tklauser added release-note/bug This PR fixes an issue in a previous release of Cilium. needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch labels Jul 13, 2023
@tklauser tklauser requested a review from a team as a code owner July 13, 2023 07:57
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.14.0 Jul 13, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.13.5 Jul 13, 2023
@tklauser
Copy link
Member Author

/test

@tklauser tklauser marked this pull request as draft July 13, 2023 08:15
@tklauser tklauser force-pushed the pr/tklauser/client-http-header-go1.20.6 branch 2 times, most recently from 0ef7516 to 139661a Compare July 13, 2023 08:33
@tklauser tklauser changed the title client: set empty host header on unix:// local communication client: set dummy host header on unix:// local communication Jul 13, 2023
@tklauser tklauser marked this pull request as ready for review July 13, 2023 08:34
@tklauser
Copy link
Member Author

/test

@tklauser
Copy link
Member Author

From #26713 it looks like we'll use Go 1.19 or Go 1.20 on other stable branches as well, so marking this PR to be backported to all stable branches.

@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.12.12 Jul 13, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.11.19 Jul 13, 2023
…cation

Go 1.20.6 added a security fix [1] which leads to stricter sanitization
of the HTTP host header in the net/http client. Cilium's pkg/client
currently sets the Host header to the UDS path (e.g.
/var/run/cilium/cilium.sock), however the slashes in that Host header
now lead net/http to reject it.

RFC 7230, Section 5.4 states [2]:

> If the authority component is missing or undefined for the target URI,
> then a client MUST send a Host header field with an empty field-value.

The authority component is undefined for the unix:// scheme. Thus, the
correct value to use would be the empty string. However, this does not
work due to OpenAPI runtime using the same value for the URL's host and
the http client's host header. Thus, use a dummy value "localhost".

[1] https://go.dev/issue/60374
[2] https://datatracker.ietf.org/doc/html/rfc7230#section-5.4

Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser force-pushed the pr/tklauser/client-http-header-go1.20.6 branch from 139661a to dc0ee22 Compare July 13, 2023 08:53
@tklauser tklauser requested a review from a team as a code owner July 13, 2023 08:53
@tklauser tklauser changed the title client: set dummy host header on unix:// local communication client, health/client: set dummy host header on unix:// local communication Jul 13, 2023
@tklauser
Copy link
Member Author

/test

@tklauser
Copy link
Member Author

Conformance AWS-CNI failed with cilium/cilium-cli#1794: https://github.com/cilium/cilium/actions/runs/5541124605 re-triggering

@tklauser
Copy link
Member Author

/ci-awscni

@tklauser tklauser merged commit b9ec2aa into main Jul 13, 2023
182 of 183 checks passed
@gandro gandro added backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. and removed backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. labels Jul 17, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.14 to Backport done to v1.14 in 1.14.0 Jul 17, 2023
@gandro gandro mentioned this pull request Jul 17, 2023
6 tasks
@gandro gandro added backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. and removed needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch labels Jul 17, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from main to Backport pending to v1.13 in 1.13.5 Jul 17, 2023
@gandro gandro added backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. and removed backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. labels Jul 19, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.13 to Backport done to v1.13 in 1.13.5 Jul 19, 2023
@gandro gandro mentioned this pull request Jul 19, 2023
3 tasks
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from main to Backport pending to v1.12 in 1.12.12 Jul 19, 2023
@gandro gandro mentioned this pull request Jul 19, 2023
3 tasks
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from main to Backport pending to v1.11 in 1.11.19 Jul 19, 2023
@gandro gandro added backport-done/1.12 The backport for Cilium 1.12.x for this PR is done. and removed backport-pending/1.12 labels Jul 19, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.12 to Backport done to v1.12 in 1.12.12 Jul 19, 2023
@gandro gandro added backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. and removed backport-pending/1.11 labels Jul 19, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.11 to Backport done to v1.11 in 1.11.19 Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. backport-done/1.12 The backport for Cilium 1.12.x for this PR is done. backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
No open projects
1.11.19
Backport done to v1.11
1.12.12
Backport done to v1.12
1.13.5
Backport done to v1.13
1.14.0
Backport done to v1.14
Development

Successfully merging this pull request may close these issues.

None yet

3 participants