]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.24] cmd/go: restore netrc preferences for GOAUTH and fix domain...
authorSam Thanawalla <samthanawalla@google.com>
Wed, 8 Jan 2025 20:38:32 +0000 (20:38 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 16 Jan 2025 19:36:07 +0000 (11:36 -0800)
commit8336dfde7096ff75c1ff256cb3079863cefac33a
tree52bcba0161451df1e51ba1aebcf6e9d6f07a5fcf
parent6b605505047416bbbf513bba1540220a8897f3f6
[release-branch.go1.24] cmd/go: restore netrc preferences for GOAUTH and fix domain lookup

Store netrc lines into the credential map backward so that earlier lines
take priority over later lines. This matches Go 1.23 netrc lookup which
stopped at the first match it found.
Additionally, this fixes a security issue related to domain parsing
which could have allowed servers to read credentials belonging to other
servers. The fix was to switch from using path.Dir(currentPrefix) to
strings.Cut(currentPrefix, "/")

Thanks to Juho Forsén of Mattermost for reporting this issue.

Fixes #71249
Fixes CVE-2024-45340

Change-Id: I175a00d6d7f4d31c9e4d79b7cf1c2a0ad35b2781
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1781
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 76833d221aa3ccc978b6f41bd24e26babf771375)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1840
Reviewed-on: https://go-review.googlesource.com/c/go/+/643101
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
src/cmd/go/internal/auth/auth.go
src/cmd/go/internal/auth/auth_test.go
src/cmd/go/testdata/script/goauth_netrc.txt