On Mon, 16 Nov 2026 05:50:05 GMT, Timofei Fedotov <[email protected]> wrote:
>> PKCS12KeyStore.loadSafeContents() reads valSet[0] for friendlyName and >> localKeyId attributes without checking whether their DER SET contains any >> values. >> >> DerInputStream.getSet(1) accepts an empty SET; the argument controls initial >> collection capacity rather than a minimum element count. A malformed PKCS12 >> bag attribute containing SET encoding 3100 therefore produces a zero-length >> array and triggers ArrayIndexOutOfBoundsException during KeyStore.load(). >> The unencrypted content path can encounter the error with a null password. >> >> Expected behavior: invalid attribute encodings must produce the normal >> IOException parsing failure instead of an unchecked indexing exception. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Timofei Fedotov has updated the pull request incrementally with one > additional commit since the last revision: > > Limit empty attribute value checks to friendlyName and localKeyId test/jdk/sun/security/pkcs12/EmptyAttributeSet.java line 47: > 45: !message.contains("Empty attribute value set")) { > 46: throw new AssertionError("Unexpected exception", e); > 47: } We have some helper methods for the checks: IOException ioe = Asserts.assertThrows(IOException.class, () -> store.load(new ByteArrayInputStream(data), null)); Asserts.assertTrue(ioe.getMessage().contains(oid)); Asserts.assertTrue(ioe.getMessage().contains("Empty attribute value set")); ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/33864#discussion_r4586675214
