[CVE-2018-1000180, CVE-2018-1000613] Upgrade Bouncycastle to 1.60

This upgrade fixes CVE-2018-1000180 [1]:

  Bouncy Castle BC 1.54 - 1.59, BC-FJA 1.0.0, BC-FJA 1.0.1 and earlier
  have a flaw in the Low-level interface to RSA key pair generator,
  specifically RSA Key Pairs generated in low-level API with added
  certainty may have less M-R tests than expected. This appears to be
  fixed in versions BC 1.60 beta 4 and later, BC-FJA 1.0.2 and later.

and CVE-2018-1000613 [2]:

  Bouncy Castle Java Cryptography APIs version prior to version 1.60
  contains a CWE-470: Use of Externally-Controlled Input to Select
  Classes or Code ('Unsafe Reflection') vulnerability in XMSS/XMSS^MT
  private key deserialization that can result in Deserializing an
  XMSS/XMSS^MT private key can result in the execution of unexpected
  code. This attack appear to be exploitable via a handcrafted private
  key can include references to unexpected classes which will be picked
  up from the class path for the executing application. This
  vulnerability appears to have been fixed in 1.60 and later.

Bouncycastle 1.57 introduced generics in its APIs. Remove the casts
and @SuppressWarnings("unchecked") annotations that are not necessary
any more.

[1] https://nvd.nist.gov/vuln/detail/CVE-2018-1000180
[2] https://nvd.nist.gov/vuln/detail/CVE-2018-1000613

Bug: Issue 9952
Change-Id: I9b25b1568ac7da555de96d82c597b3dff47966c6
This commit is contained in:
David Pursehouse
2018-11-02 09:21:59 +09:00
parent 5980f9d707
commit 6f97ef16b3
9 changed files with 8 additions and 14 deletions

View File

@@ -585,24 +585,25 @@ maven_jar(
sha1 = "bb562ee73f740bb6b2bf7955f97be6b870d9e9f0",
)
BC_VERS = "1.56"
# When updating Bouncy Castle, also update it in bazlets.
BC_VERS = "1.60"
maven_jar(
name = "bcprov",
artifact = "org.bouncycastle:bcprov-jdk15on:" + BC_VERS,
sha1 = "a153c6f9744a3e9dd6feab5e210e1c9861362ec7",
sha1 = "bd47ad3bd14b8e82595c7adaa143501e60842a84",
)
maven_jar(
name = "bcpg",
artifact = "org.bouncycastle:bcpg-jdk15on:" + BC_VERS,
sha1 = "9c3f2e7072c8cc1152079b5c25291a9f462631f1",
sha1 = "13c7a199c484127daad298996e95818478431a2c",
)
maven_jar(
name = "bcpkix",
artifact = "org.bouncycastle:bcpkix-jdk15on:" + BC_VERS,
sha1 = "4648af70268b6fdb24674fb1fd7c1fcc73db1231",
sha1 = "d0c46320fbc07be3a24eb13a56cee4e3d38e0c75",
)
# TODO(davido): Remove exlusion of file system provider, when this issue is fixed:

View File

@@ -963,7 +963,6 @@ public class AccountIT extends AbstractDaemonTest {
assertThat(actual.fingerprint)
.named(id)
.isEqualTo(Fingerprint.toString(expected.getPublicKey().getFingerprint()));
@SuppressWarnings("unchecked")
List<String> userIds = ImmutableList.copyOf(expected.getPublicKey().getUserIDs());
assertThat(actual.userIds).named(id).containsExactlyElementsIn(userIds);
assertThat(actual.key).named(id).startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----\n");

View File

@@ -176,7 +176,6 @@ public class GerritPublicKeyChecker extends PublicKeyChecker {
private boolean hasAllowedUserId(PGPPublicKey key, Set<String> allowedUserIds)
throws PGPException {
@SuppressWarnings("unchecked")
Iterator<String> userIds = key.getUserIDs();
while (userIds.hasNext()) {
String userId = userIds.next();

View File

@@ -381,7 +381,6 @@ public class PublicKeyChecker {
}
List<CheckResult> signerResults = new ArrayList<>();
@SuppressWarnings("unchecked")
Iterator<String> userIds = key.getUserIDs();
while (userIds.hasNext()) {
String userId = userIds.next();

View File

@@ -398,7 +398,6 @@ public class PublicKeyStore implements AutoCloseable {
}
public static String keyToString(PGPPublicKey key) {
@SuppressWarnings("unchecked")
Iterator<String> it = key.getUserIDs();
return String.format(
"%s %s(%s)",

View File

@@ -230,7 +230,6 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
if (key != null) {
info.id = PublicKeyStore.keyIdToString(key.getKeyID());
info.fingerprint = Fingerprint.toString(key.getFingerprint());
@SuppressWarnings("unchecked")
Iterator<String> userIds = key.getUserIDs();
info.userIds = ImmutableList.copyOf(userIds);

View File

@@ -373,7 +373,7 @@ public class GerritPublicKeyCheckerTest {
PGPPublicKeyRing keyRingB = keyB().getPublicKeyRing();
PGPPublicKey keyB = keyRingB.getPublicKey();
keyB = PGPPublicKey.removeCertification(keyB, (String) keyB.getUserIDs().next());
keyB = PGPPublicKey.removeCertification(keyB, keyB.getUserIDs().next());
keyRingB = PGPPublicKeyRing.insertPublicKey(keyRingB, keyB);
add(keyRingB, addUser("userB"));
@@ -391,8 +391,7 @@ public class GerritPublicKeyCheckerTest {
List<ExternalId> newExtIds = new ArrayList<>(2);
newExtIds.add(ExternalId.create(toExtIdKey(kr.getPublicKey()), id));
@SuppressWarnings("unchecked")
String userId = (String) Iterators.getOnlyElement(kr.getPublicKey().getUserIDs(), null);
String userId = Iterators.getOnlyElement(kr.getPublicKey().getUserIDs(), null);
if (userId != null) {
String email = PushCertificateIdent.parse(userId).getEmailAddress();
assertThat(email).contains("@");

View File

@@ -236,7 +236,6 @@ public class PublicKeyStoreTest {
private void assertUserIds(PGPPublicKeyRing keyRing, String... expected) throws Exception {
List<String> actual = new ArrayList<>();
@SuppressWarnings("unchecked")
Iterator<String> userIds =
store.get(keyRing.getPublicKey().getKeyID()).iterator().next().getPublicKey().getUserIDs();
while (userIds.hasNext()) {

View File

@@ -77,7 +77,7 @@ public class TestKey {
}
public String getFirstUserId() {
return (String) getPublicKey().getUserIDs().next();
return getPublicKey().getUserIDs().next();
}
public PGPPrivateKey getPrivateKey() throws PGPException {