CVE-2019-17596
authorGo Compiler Team <pkg-golang-devel@lists.alioth.debian.org>
Fri, 21 Jan 2022 18:45:18 +0000 (18:45 +0000)
committerSylvain Beucler <beuc@debian.org>
Fri, 21 Jan 2022 18:45:18 +0000 (18:45 +0000)
Origin: https://github.com/golang/go/commit/2017d88dbc096381d4f348d2fb08bfb3c2b7ed73
Reviewed-by: Sylvain Beucler <beuc@debian.org>
Last-Update: 2021-03-12

From 2017d88dbc096381d4f348d2fb08bfb3c2b7ed73 Mon Sep 17 00:00:00 2001
From: Katie Hockman <katie@golang.org>
Date: Mon, 14 Oct 2019 16:42:21 -0400
Subject: [PATCH] [release-branch.go1.12-security] crypto/dsa: prevent bad
 public keys from causing panic

dsa.Verify might currently use a nil s inverse in a
multiplication if the public key contains a non-prime Q,
causing a panic. Change this to check that the mod
inverse exists before using it.

Fixes CVE-2019-17596

Change-Id: I94d5f3cc38f1b5d52d38dcb1d253c71b7fd1cae7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/572809
Reviewed-by: Filippo Valsorda <valsorda@google.com>
(cherry picked from commit 9119dfb0511326d4485b248b83d4fde19c95d0f7)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/575232

Gbp-Pq: Name CVE-2019-17596.patch

src/crypto/dsa/dsa.go

index e9b6a0c25328a000a24066de31a1d7588e426754..dcd58eae47bd5b9e8b9e9c15f6b241247bcf69f5 100644 (file)
@@ -259,6 +259,9 @@ func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool {
        }
 
        w := new(big.Int).ModInverse(s, pub.Q)
+       if w == nil {
+               return false
+       }
 
        n := pub.Q.BitLen()
        if n&7 != 0 {