On Thu, 12 Nov 2026 07:57:26 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).

This pull request has now been integrated.

Changeset: 62e46443
Author:    Timofei Fedotov <[email protected]>
Committer: Artem Semenov <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/62e46443948e59b8ece3a0bd6f25d87afac95284
Stats:     72 lines in 2 files changed: 72 ins; 0 del; 0 mod

8397199: PKCS12KeyStore throws ArrayIndexOutOfBoundsException for empty 
attribute value sets

Reviewed-by: weijun, asemenov

-------------

PR: https://git.openjdk.org/jdk/pull/33864

Reply via email to