Asakusa.go #7 - Go 1.26リリパ Appendix Goセキュリティ関連更...

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Asakusa.go #7 - Go 1.26リリパ Appendix Goセキュリティ関連更新キャッチアップ

tom twinkle

December 04, 2026

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

30 slides
  1. Goの哲学を形作った人たち • Rob Pike & Ken Thompson ◦ ◦ •

    Adam Langley & Filippo Valsorda ◦ • UNIXから受け継いだ「引き算の美学」 https://go.dev/talks/2012/splash.article Ken「自らが書いたコード以外を信用するな」 https://dl.acm.org/doi/10.1145/358198.358210 「デフォルトの動作は安全であるべき」 https://golang.org/design/cryptography-principles Russ Cox & Titus Winters ◦ 「ソフトウェアエンジニアリングとは、プログラミングに時間と他のプログラマーを加えたときに起こ る現象である」 https://research.swtch.com/vgo-principles
  2. Go 1.20,1.24 rand.Seedをユーザーに設定させない設計 Go 1.20 未満では math/rand のSeedのDefault値は "1" で固定されて

    おり、安全な疑似乱数を生成するためには rand.Seed() を利用者が明 示的に指定する必要がありました https://cs.opensource.google/go/go/+/refs/tags/go1.19.9:src/math/rand/rand.go;l=293;bpv=0
  3. Go 1.20,1.24 rand.Seedをユーザーに設定させない設計 // NG: time.Now().UnixNano() を利用する例 // Seedが予測可能、かつ重複の可能性がある rand.Seed(time.Now().UnixNano())

    // NG: UNIXの /dev/urandom を利用する例 // 読み取りタイミングによってデバイスやコンテナ内のエントロピー不足により同値になる可能性がある // Mining Your Ps and Qs: https://www.usenix.org/system/files/conference/usenixsecurity12/sec12-final228.pdf f, err := os.Open("/dev/urandom") var seed int64 err = binary.Read(f, binary.LittleEndian, &seed) rand.Seed(seed) // OK: crypto/rand#Reader を利用する例 これなら安全だが math/rand を誤って利用するケースがよく発生していた import “crypto/rand” var seed int64 err = binary.Read(rand.Reader, binary.LittleEndian, &seed) rand.Seed(seed)
  4. Go 1.20,1.24 rand.Seedをユーザーに設定させない設計 Go 1.20 では math/rand の Seed function

    が deprecated になりSeedは fastrand64(runtime.rand)により安全に決まるように変更 https://cs.opensource.google/go/go/+/refs/tags/go1.20:src/math/rand/rand.go;l=318-324;bpv=0 https://cs.opensource.google/go/go/+/refs/tags/go1.20:src/math/rand/rand.go;l=415;bpv=0
  5. Go 1.22 math.rand のデフォルト乱数生成器が ChaCha8に変更 Go 1.21まで math/rand デフォルト乱数生成器「加算ラグ付きフィボナッチ生成器 (ALFG)」

    tapとfeedのindexの移動 tap = 273個前, feed = 607個前 のindexをスライドさせる tapとfeedのindexの状 態ベクトルを足し合わせ てそのまま出力 https://cs.opensource.google/go/go/+/refs/tags/go1.21.9:src/math/rand/rng.go;l=238
  6. crypto/ellipticの実装ミスにより発生する代表的な脆弱 性 Small Subgroup Attack(小位数部分群攻撃) 「楕円曲線の点が無限遠点になっていないか」の確認を忘れた。 非常に小さな位数(例えばn=3 や n=17 など)を持つ点Pの場合、余剰から導き出せる

    秘密鍵のパターンが限られるので算出が可能。 x, y := curve.ScalarMult(pubX, pubY, privKey) // 結果が無限遠点(0,0)になっていないか確認していないとSmall Subgroup Attack の脆弱性あり if x == nil || (x.Sign() == 0 && y.Sign() == 0) { return nil, errors.New("shared secret is identity element") }
  7. Go 1.24 crypto/rsa 1024bit key の廃止 Go 1.24 では crypto/rsa

    で 1024bit未満の鍵を利用しようとするとエラーを返すように なりました。2030年まで安全とされる暗号強度の最低ラインは「AES 112bit相当(RSA 2048bit)」 https://cs.opensource.google/go/go/+/refs/tags/go1.24.0:src/crypto/rsa/rsa.go;l=246-259;bpv=0
  8. Go 1.24 ポスト量子暗号 crypto/mlkem Go 1.24 では ポスト量子暗号 crypto/mlkem (NIST

    FIPS 203) が実装 格子問題(LWE問題)をベースにした暗号 多次元空間に並んだ点の格子の中から、特定の条件を満たす点を見つける問題 https://cs.opensource.google/go/go/+/refs/tags/go1.24.0:src/crypto/mlkem/mlkem.go;bpv=0
  9. Go 1.24 ポスト量子暗号 crypto/mlkem おまけ “How to factor 2048 bit

    RSA integers in 8 hours using 20 million noisy qubits“ Gidney-Ekera arXiv:1905.09749 https://www.imes.boj.or.jp/jp/conference/citecs/26sympo/files/26sympo_file2%EF%BC%9A% E8%97%A4%E4%BA%95%E5%85%88%E7%94%9F.pdf https://www.imes.boj.or.jp/jp/conference/citecs/26sympo/files/26sympo_file8%EF%BC%9A% E8%A5%BF%E5%B7%BB%E6%A7%98.pdf
  10. #49702 crypto: use subtle.WithDataIndependentTiming for all constant-time APIs ARM64アーキテクチャ特有の「タイミング攻撃(Timing Attack)」を防ぐための重要な

    セキュリティ修正 ARM64の一部のプロセッサでは、掛け算(MUL)やメモリ読み込み(LOAD)などの命 令を実行する際、処理するデータによって処理にかかる時間が微小に変動する可能 性がある ARMにはDIT (Data Independent Timing) というCPUフラグが用意されており。有効に すると、常に一定の時間で命令が実行されることが保証される。 https://go.dev/issues/49702
  11. #65085 crypto/x509: potentially anomalous path building results Goの crypto/x509 パッケージが

    RFC 5280から逸脱しているため修正したい。 …が、Debian Bullseyeなどに含まれる古いルート証明書では負のシリアル番号を持つ ものが残っており、GoのアップデートによってTLS接続ができなくなるトラブルが発生し たため、それらの問題が解決するまでまだ時間がかかりそう。 https://go.dev/issues/65085
  12. #76485 proposal: cmd/go: support dependency cooldown in Go tooling サプライチェーン攻撃の対策としてgo

    get, go mod tidyなどにDependabotの Cooldownのような機能を追加しようという提案。 GoではGOPROXY=directでproxy.golang.orgをバイパス出来るため中央集権的なレ ジストリが存在しない。パッケージの公開日時を偽装出来る問題がある。 Goのセキュリティチームは、sumdbに「最初に観測されたタイムスタンプ」を強制的に 埋め込むべきと主張しています。 https://go.dev/issues/76485

More Decks by tom twinkle

Other Decks in Technology