File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -219,10 +219,26 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
219
219
if err != nil {
220
220
return nil , err
221
221
}
222
+ if len (chain ) < 1 {
223
+ return nil , errors .New ("x509: internal error: system verifier returned an empty chain" )
224
+ }
222
225
223
- chains = append (chains , chain )
226
+ // Mitigate CVE-2020-0601, where the Windows system verifier might be
227
+ // tricked into using custom curve parameters for a trusted root, by
228
+ // double-checking all ECDSA signatures. If the system was tricked into
229
+ // using spoofed parameters, the signature will be invalid for the correct
230
+ // ones we parsed. (We don't support custom curves ourselves.)
231
+ for i , parent := range chain [1 :] {
232
+ if parent .PublicKeyAlgorithm != ECDSA {
233
+ continue
234
+ }
235
+ if err := parent .CheckSignature (chain [i ].SignatureAlgorithm ,
236
+ chain [i ].RawTBSCertificate , chain [i ].Signature ); err != nil {
237
+ return nil , err
238
+ }
239
+ }
224
240
225
- return chains , nil
241
+ return [][] * Certificate { chain } , nil
226
242
}
227
243
228
244
func loadSystemRoots () (* CertPool , error ) {
You can’t perform that action at this time.
0 commit comments