原文はこちら。
The original article was written by Sean Mullan (Java Security Tech Lead, Oracle).
https://seanjmullan.org/blog/2024/09/17/jdk23
2024年9月17日にJDK 23がリリースされました。
JDK 23
https://openjdk.org/projects/jdk/23/
以前のブログと同様、今回のリリースで最も興味深く、役に立つと思われるセキュリティ強化点のリストをまとめました。また、各分野で何が変わったのかを見つけやすくするために、適切なカテゴリー(暗号、TLSなど)に分類しました。JDK 23のリリースノートにも、これらの機能強化やその他の機能強化の詳細が記載されています。
Sean Mullan’s Blog
https://seanjmullan.org/blog/
JDK 23 Release Notes
https://jdk.java.net/23/release-notes
このリリースのハイライトには以下のようなものがあります。
- 新たな”threads”と”timestamp”デバッグオプション
- 暗号関連のパフォーマンス改善
- macOS KeyChainのルート証明書アクセスのための新たなKeyStore
また、他の重要なJDK 23機能として、セキュリティライブラリ関連ではありませんが重要なポイントとして
JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal
があります。このJEPはsun.misc.Unsafeのメモリアクセスメソッドが将来のリリースでの削除に向けて非推奨にするというものです。JEPから引用すると、
Removing the memory-access methods in
sun.misc.Unsafeis part of a long-term coordinated effort to ensure that the Java Platform has integrity by default.(sun.misc.Unsafeのメモリアクセスメソッドの削除は、Java Platformのintegrity by default (デフォルトの完全性) を保証するための長期的な協調努力の一環である)JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal https://openjdk.org/jeps/471
JEP draft: Integrity by Default https://openjdk.org/jeps/8305968
Table of Contents
Crypto
Increased CipherInputStream buffer size
javax.crypto.CipherInputStream のバッファサイズが512バイトから8192バイトに拡張されました。この変更により、パフォーマンスが改善され、java.io.FileInputStreamなどの他のAPIのバッファサイズとの整合性が高まります。
CipherInputStream (Java SE 23 & JDK 23)
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/javax/crypto/CipherInputStream.html
[JDK-8330108] Increase CipherInputStream buffer size
https://bugs.openjdk.org/browse/JDK-8330108
New SecureRandom() performance improved
SecureRandom() を使っての java.security.SecureRandom オブジェクト作成のパフォーマンスが改善されました。
SecureRandom (Java SE 23 & JDK 23)
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/security/SecureRandom.html
[JDK-8324646] Avoid Class.forName in SecureRandom constructor
https://bugs.openjdk.org/browse/JDK-8324646
[JDK-8324648] Avoid NoSuchMethodError when instantiating NativePRNG
https://bugs.openjdk.org/browse/JDK-8324648
New PKCS11 allowLegacy attribute
新たなPKCS11設定の属性である allowLegacy が導入されました。この値をtrueにすると、アプリケーションはレガシーなチェックをバイパスできます(デフォルト値はfalse)。
暗号化アルゴリズムが弱体化すると、PKCS11ライブラリの中にはこれらの アルゴリズムの使用を制限し始めるものが出てくる可能性があります。例えば、あるPKCS11ライブラリは、特定のアルゴリズムで署名された既存の署名を検証することをアプリケーションに許可する場合がありますが、そのアルゴリズムで新しい署名を生成することを禁止する場合があります。この属性により、アプリケーションは必要に応じて、自己責任でこれらの制限を回避できます。
[JDK-8293345] SunPKCS11 provider checks on PKCS11 Mechanism are problematic
https://bugs.openjdk.org/browse/JDK-8293345
PKI
New root CA certificates
cacertsキーストアに新たにルートCA証明書が追加されています。
2個のCertainlyルートCA証明書
これらのルート証明書は、以下のJDKリリースのcacertsキーストアにも追加されています。
Oracle JDK 22.0.1 / 21.0.3 / 17.0.11 / 11.0.23 / 8u411 / 7u421
| ルートCA証明書 | Distinguished name |
|---|---|
| Certainly Root R1 https://crt.sh/?id=1730333109 | CN=Certainly Root R1, O=Certainly, C=US |
| Certainly Root E1 https://crt.sh/?id=1730335161 | CN=Certainly Root E1, O=Certainly, C=US |
[JDK-8321408] Add Certainly roots R1 and E1
https://bugs.openjdk.org/browse/JDK-8321408
2個のGlobalSignルートCA証明書
これらのルート証明書は、以下のJDKリリースのcacertsキーストアにも追加されています。
Oracle JDK 22.0.2 / 21.0.4 / 17.0.12 / 11.0.24 / 8u421 / 7u431
| ルートCA証明書 | Distinguished name |
|---|---|
| GlobalSign Root R46 https://crt.sh/?id=5150405959 | CN=GlobalSign Root R46, O=GlobalSign nv-sa, C=BE |
| GlobalSign Root E46 https://crt.sh/?id=5150403703 | CN=GlobalSign Root E46, O=GlobalSign nv-sa, C=BE |
[JDK-8316138] Add GlobalSign 2 TLS root certificates
https://bugs.openjdk.org/browse/JDK-8316138
New KeyStore for MacOS root certificates
新たな java.security.KeyStore である KeychainStore-ROOT がAppleセキュリティプロバイダーに追加されました。
KeyStore (Java SE 23 & JDK 23)
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/security/KeyStore.html
このキーストアには、macOSシステムのシステムキーチェーンに格納されているルート証明書が含まれています。Appleプロバイダーはこれにより、2個のキーストアをサポートするようになりました。
KeychainStore-Root- KeychainStore(ユーザーのキーチェーン用の秘密鍵と証明書を含む既存のキーストア)
この機能強化により、JDKが相手の証明書チェーンの信頼を確立するためのルート証明書を見つけることができず、HTTP接続が失敗する、という問題が修正されます。この変更後、ユーザーはTLS接続作成時にシステムプロパティ javax.net.ssl.trustStoreType を KeychainStore-ROOT に設定する必要があります。以下はkeytoolユーティリティを使ってmacOSキーチェーンのルートを一覧表示する例です。
keytool -list -storetype KeychainStore-ROOT -keystore NONE
Enter keystore password:
***************** WARNING WARNING WARNING *****************
* The integrity of the information stored in your keystore *
* has NOT been verified! In order to verify its integrity, *
* you must provide your keystore password. *
***************** WARNING WARNING WARNING *****************
Keystore type: KEYCHAINSTORE-ROOT
Keystore provider: Apple
Your keystore contains 153 entries
aaa certificate services, Sep 20, 2024, trustedCertEntry,
Certificate fingerprint (SHA-256): D7:A7:A0:FB:5D:7E:27:31:D7:71:E9:48:4E:BC:DE:F7:1D:5F:0C:3E:0A:29:48:78:2B:C8:3E:E0:EA:69:9E:F4
ac raiz fnmt-rcm, Sep 20, 2024, trustedCertEntry,
Certificate fingerprint (SHA-256): EB:C5:57:0C:29:01:8C:4D:67:B1:AA:12:7B:AF:12:F7:03:B4:61:1E:BC:17:B7:DA:B5:57:38:94:17:9B:93:FA
accvraiz1, Sep 20, 2024, trustedCertEntry,
Certificate fingerprint (SHA-256): 9A:6E:C0:12:E1:A7:DA:9D:BE:34:19:4D:47:8A:D7:C0:DB:18:22:FB:07:1D:F1:29:81:49:6E:D1:04:38:41:13
actalis authentication root ca, Sep 20, 2024, trustedCertEntry,
Certificate fingerprint (SHA-256): 55:92:60:84:EC:96:3A:64:B9:6E:2A:BE:01:CE:0B:A8:6A:64:FB:FE:BC:C7:AA:B5:AF:C1:55:B3:7F:D7:60:66
...
[JDK-8320362] Load anchor certificates from Keychain keystore
https://bugs.openjdk.org/browse/JDK-8320362
New system property to use POST for all OCSP requests
JDK 17で、小さなOCSPリクエストにはHTTP GETメソッドを使用し、それ以外のリクエストにはPOSTメソッドを使用するというパフォーマンス向上が導入されました。しかし、一部のOCSPレスポンダーはGETリクエストをうまく処理できないため、簡単に回避できない問題が発生していました。
そこで、新たなシステムプロパティcom.sun.security.ocsp.usegetが導入されました。このプロパティをfalseに設定すると、JDKはHTTP POSTメソッドのみを使用してOCSPリクエストを送信します。設定されていない場合のデフォルト値はtrueで、これまでの動作と同じです。
[JDK-8328638] Fallback option for POST-only OCSP requests
https://bugs.openjdk.org/browse/JDK-8328638
Authorization
Subject.getSubject() now throws UnsupportedOperationException unless a Security Manager is allowed or enabled
javax.security.auth.Subject のメソッドgetSubjectが変更され、UnsupportedOperationExceptionをスローするようになりました。
getSubject – Subject (Java SE 23 & JDK 23)
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/javax/security/auth/Subject.html#getSubject(java.security.AccessControlContext)
ユーザーはコマンドラインで-Djava.security.managerを使ってSecurity Managerを有効、もしくは許可することにより、以前の振る舞いに変更できます。Subject.getSubject メソッドはSecurity Managerに依存していませんが、AccessControlContextパラメータが原因で、この機能を許可 (allowed) にする必要があります。
この変更は、このメソッドが常にUnsupportedOperationExceptionをスローするように変更される将来のリリースに備えるために行われました。このメソッドが問題なのは、AccessControlContextという、JDK 17で削除に備えて非推奨になった一つのSecurity Manager APIに依存するためです。
JEP 411: Deprecate the Security Manager for Removal
https://openjdk.org/jeps/411
良いニュースとして、JDK 18で代替APIであるSubject.current()が追加されました。
current – Subject (Java SE 23 & JDK 23)
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/javax/security/auth/Subject.html#current()
アプリケーションやライブラリでは、Subject.getSubject()の呼び出しをSubject.current()に置き換えることを是非検討すべきです。
[JDK-8296244] Alternate implementation of user-based authorization Subject APIs that doesn’t depend on Security Manager APIs
https://bugs.openjdk.org/browse/JDK-8296244
Kerberos
New security/system property to support case-sensitive principal names
新たなセキュリティプロパティjdk.security.krb5.name.case.sensitiveが導入され、Kerberosプリンシパル名を大文字小文字を区別してkeytabとクレデンシャルキャッシュファイルを検索できるようになりました。この変更以前は、プリンシパル名は常に大文字小文字を区別しないものとして扱われていました。つまり、SEAN@ACME.ORGのプリンシパル名はsean@acme.orgに一致しました。しかし、一部のKerberos実装では、これらのプリンシパルは別物として扱われます。
このプロパティをtrueに設定すると、JDKのKerberos実装は、プリンシパル名のマッチング時に大文字と小文字を区別して比較します。このプロパティのデフォルト値、つまり設定しない場合の値はfalseで、以前と同じ振る舞いをします。同じ名前のシステム・プロパティを使用することもできます。その場合、セキュリティ・プロパティの値を上書きします。
[JDK-8331975] Enable case-sensitive check in ccache and keytab entry lookup
https://bugs.openjdk.org/browse/JDK-8331975
Enhanced Kerberos debugging
Kerberosコンポーネントのデバッグ出力が、標準出力ではなく標準エラーに向けられるようになりました。各メッセージの先頭に、krb5loginmodule、jgss、krb5などのKerberosサブコンポーネントが付くようになりました。
以下は、sun.security.krb5.debugシステムプロパティをtrueに設定したデバッグコードの出力例です。
krb5: Java config name: null
krb5: Native config name: /etc/krb5.conf
krb5: Loading config file from /etc/krb5.conf
krb5: Loaded from native config
[JDK-8327818] Implement Kerberos debug with sun.security.util.Debug
https://bugs.openjdk.org/browse/JDK-8327818
Miscellaneous
New “thread” and “timestamp” options for the java.security.debug system property
アプリケーションのデバッグ支援の目的で、システム・プロパティjava.security.debugに新たなオプションthreadとtimestampが追加されました。
| thread | 各デバッグ・ステートメントのスレッドと呼び出し元の情報を表示 |
| timestamp | 各デバッグ・ステートメントの日付と時刻を表示 |
これらの新しいオプションは、マルチスレッド・アプリケーションをデバッグする際に非常に役立ちます。
これらのオプションを+記号でjava.security.debugに付加できます。例えば以下は-Djava.security.debug=properties+thread+timestampで実行されたアプリケーションの出力の一部です。各デバッグ行には、タイムスタンプ、スレッド ID、呼び出し元が含まれています。
properties[0x1|main|Security.java:161|2024-09-20 09:31:39.929]: java.security
properties[0x1|main|Security.java:122|2024-09-20 09:31:39.931]: Initial security property: jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, DSA keySize < 1024, SHA1 denyAfter 2019-01-01
properties[0x1|main|Security.java:122|2024-09-20 09:31:39.931]: Initial security property: security.provider.13=SunPKCS11
properties[0x1|main|Security.java:122|2024-09-20 09:31:39.931]: Initial security property: security.provider.12=Apple
properties[0x1|main|Security.java:122|2024-09-20 09:31:39.931]: Initial security property: http.auth.digest.disabledAlgorithms=MD5, SHA-1
properties[0x1|main|Security.java:122|2024-09-20 09:31:39.932]: Initial security property: jdk.security.legacyAlgorithms=SHA1, RSA keySize < 2048, DSA keySize < 2048, DES, DESede, MD5, RC2, ARCFOUR
properties[0x1|main|Security.java:122|2024-09-20 09:31:39.932]: Initial security property: securerandom.source=file:/dev/random
[JDK-8051959] Add thread and timestamp options to java.security.debug system property
https://bugs.openjdk.org/browse/JDK-8051959