Go 1.20.5 のリリース【セキュリティ・アップデート】

no extension

予告通り Go 1.20.5 がリリースされた。

今回は CVE ID ベースで4件の脆弱性修正を含んでいる。

CVE-2023-29402 cmd/go: cgo code injection

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).

  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • 深刻度: 緊急 (Score: 9.8)
基本評価基準 評価値
攻撃元区分 ネットワーク
攻撃条件の複雑さ
必要な特権レベル 不要
ユーザ関与レベル 不要
スコープ 変更なし
機密性への影響
完全性への影響
可用性への影響

CVE-2023-29403 runtime: unexpected behavior of setuid/setgid binaries

The Go runtime didn’t act any differently when a binary had the setuid/setgid bit set. On Unix platforms, if a setuid/setgid binary was executed with standard I/O file descriptors closed, opening any files could result in unexpected content being read/written with elevated prilieges. Similarly if a setuid/setgid program was terminated, either via panic or signal, it could leak the contents of its registers.
  • CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
  • 深刻度: 重要 (Score: 7.8)
基本評価基準 評価値
攻撃元区分 ローカル
攻撃条件の複雑さ
必要な特権レベル 不要
ユーザ関与レベル
スコープ 変更なし
機密性への影響
完全性への影響
可用性への影響

CVE-2023-29404, CVE-2023-29405 cmd/go: improper sanitization of LDFLAGS

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 by triggered by linker flags, specified via a “#cgo LDFLAGS” directive.

これについては追加情報があって

Due to an unfortunate mistake, this change will break the use of “#cgo LDFLAGS” directives when using -compiler=gccgo. Most people using gccgo or GoLLVM use the cmd/go that is distributed with those tools, and that is unaffected. Therefore, we will fix this in the next minor release. The current minor releases 1.20.5 and 1.19.10 are unfortunately broken for some cases when using gccgo or GoLLVM. Our apologies for the mishap. Thanks to Jeffrey Tolar for spotting the problem.

とのこと。 gccgo や GoLLVM を使っている人は要注意である。

  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (CVE-2023-29404)
  • 深刻度: 緊急 (Score: 9.8)
基本評価基準 評価値
攻撃元区分 ネットワーク
攻撃条件の複雑さ
必要な特権レベル 不要
ユーザ関与レベル 不要
スコープ 変更なし
機密性への影響
完全性への影響
可用性への影響
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (CVE-2023-29405)
  • 深刻度: 緊急 (Score: 9.8)
基本評価基準 評価値
攻撃元区分 ネットワーク
攻撃条件の複雑さ
必要な特権レベル 不要
ユーザ関与レベル 不要
スコープ 変更なし
機密性への影響
完全性への影響
可用性への影響

例によって…

Ubuntu の APT で管理している Go コンパイラは古いので,ダウンロードページからバイナリ(go1.20.5.linux-amd64.tar.gz)を取ってきてインストールすることを推奨する。 以下は完全手動での作業例。

$ cd /usr/local/src
$ sudo curl -L "https://go.dev/dl/go1.20.5.linux-amd64.tar.gz" -O
$ cd ..
$ sudo unlink go # 以前の Go が入っている場合
$ sudo tar xvf src/go1.20.5.linux-amd64.tar.gz
$ sudo mv go go1.20.5
$ sudo ln -s go1.20.5 go
$ go version # /usr/local/go/bin にパスが通っている場合
go version go1.20.5 linux/amd64

Windows はインストールパッケージを取ってきて直接インストールする。 Scoop 経由でも OK

複数バージョンの Go コンパイラを扱いたい場合は

$ go install golang.org/dl/go1.20.5@latest
$ go1.20.5 download
$ go1.20.5 version
go version go1.20.5 linux/amd64

てな感じで導入できる。

アップデートは計画的に。

参考図書

photo
プログラミング言語Go
アラン・ドノバン (著), ブライアン・カーニハン (著), 柴田芳樹 (著)
丸善出版 2016-06-20 (Release 2021-07-13)
Kindle版
B099928SJD (ASIN)
評価     

Kindle 版出た! 一部内容が古びてしまったが,この本は Go 言語の教科書と言ってもいいだろう。感想はこちら

reviewed by Spiegel on 2021-05-22 (powered by PA-APIv5)

photo
初めてのGo言語 ―他言語プログラマーのためのイディオマティックGo実践ガイド
Jon Bodner (著), 武舎 広幸 (翻訳)
オライリージャパン 2022-09-26
単行本(ソフトカバー)
4814400047 (ASIN), 9784814400041 (EAN), 4814400047 (ISBN)
評価     

2021年に出た “Learning Go” の邦訳版。私は版元で PDF 版を購入。 Go 特有の語法(idiom)を切り口として Go の機能やパッケージを解説している。 Go 1.19 対応。

reviewed by Spiegel on 2022-10-11 (powered by PA-APIv5)