Skip to content

OSG-SEC-2023-06-30 CRITICAL Go programming language vulnerabilities

Dear OSG Security Contacts,

Red Hat released errata for multiple critical security vulnerabilities in the Go programming language [1][2]. For any systems or developers using Go we strongly recommend that the available patches be applied. The CVEs are as follows: CVE-2023-29402 (go command may generate unexpected code at build time when using cgo), CVE-2023-29403 (runtime: unexpected behavior of setuid/setgid binaries), CVE-2023-29404 (go command may execute arbitrary code at build time when using cgo), and CVE-2023-29405 (Arbitrary code execution triggered by linker flags).

IMPACTED VERSIONS:

CVE-2023-29402: RHEL 7,8,9 based distributions

CVE-2023-29403: RHEL 7,8,9 based distributions

CVE-2023-29404: RHEL 7,8,9 based distributions

CVE-2023-29405: RHEL 7,8,9 based distributions

Go 1.19.x versions before 1.19.10

Go 1.20.x versions before 1.20.5

WHAT ARE THE VULNERABILITIES:

CVE-2023-29402: The go command may generate unexpected code at build time when using cgo. This may result in unexpected behavior when running a go program which uses cgo. This may occur when running an untrusted module which contains directories with newline characters in their names. Modules which are retrieved using the go command, i.e. via "go get", are not affected (modules retrieved using GOPATH-mode, i.e. GO111MODULE=off, may be affected). [3][7]

CVE-2023-29403: On Unix platforms, the Go runtime does not behave differently when a binary is run with the setuid/setgid bits. This can be dangerous in certain cases, such as when dumping memory state, or assuming the status of standard i/o file descriptors. If a setuid/setgid binary is executed with standard I/O file descriptors closed, opening any files can result in unexpected content being read or written with elevated privileges. Similarly, if a setuid/setgid program is terminated, either via panic or signal, it may leak the contents of its registers. [4][8]

CVE-2023-29404: The go command may execute arbitrary code at build time when using cgo. This may occur when running "go get" on a malicious module, or when running any other command which builds untrusted code. This is can be triggered by linker flags, specified via a "#cgo LDFLAGS" directive. The arguments for a number of flags which are non-optional are incorrectly considered optional, allowing disallowed flags to be smuggled through the LDFLAGS sanitization. This affects usage of both the gc and gccgo compilers. [5][9]

CVE-2023-29405: The go command may execute arbitrary code at build time when using cgo. This may occur when running "go get" on a malicious module, or when running any other command which builds untrusted code. This is can be triggered by linker flags, specified via a "#cgo LDFLAGS" directive. Flags containing embedded spaces are mishandled, allowing disallowed flags to be smuggled through the LDFLAGS sanitization by including them in the argument of another flag. This only affects usage of the gccgo compiler. [6][10]

WHAT YOU SHOULD DO:

For RHEL 7 based distributions: golang comes from EPEL. It should be available in epel-testing by the weekend and in epel in about another week. Install these updates when they become available.

For RHEL 8 based distributions: An update for the go-toolset:rhel8 module is now available for Red Hat Enterprise Linux 8. Install these updates. You can find a full list of the updated packages in the RHEL 8 security announcement errata [1].

For RHEL 9 based distributions: An update for go-toolset and golang is now available for Red Hat Enterprise Linux 9. Install these updates. You can find a full list of the updated packages in the RHEL 8 security announcement errata [2].

If you are using your own builds of Go 1.19.x or 1.20.x, upgrade to versions 1.19.10 or 1.20.5 or higher respectively.

Software that has been compiled with the unpatched versions of the Go tools should be recompiled after the updated versions have been installed.

REFERENCES

[1] https://access.redhat.com/errata/RHSA-2023:3922

[2] https://access.redhat.com/errata/RHSA-2023:3923

[3] https://access.redhat.com/security/cve/CVE-2023-29402

[4] https://access.redhat.com/security/cve/CVE-2023-29403

[5] https://access.redhat.com/security/cve/CVE-2023-29404

[6] https://access.redhat.com/security/cve/CVE-2023-29405

[7] https://pkg.go.dev/vuln/GO-2023-1839

[8] https://pkg.go.dev/vuln/GO-2023-1840

[9] https://pkg.go.dev/vuln/GO-2023-1841

[10] https://pkg.go.dev/vuln/GO-2023-1842

Please contact the OSG security team at [email protected] if you have any questions or concerns. OSG Security Team