You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "coheigea (via GitHub)" <gi...@apache.org> on 2026/09/02 10:24:49 UTC

[PR] Add a fallback to prevent attacks on RSA 1.5 in the Jose code [cxf]

coheigea opened a new pull request, #3435:
URL: https://github.com/apache/cxf/pull/3435

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add a fallback to prevent attacks on RSA 1.5 in the Jose code [cxf]

Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3435:
URL: https://github.com/apache/cxf/pull/3435#discussion_r3913815268


##########
rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/WrappedKeyDecryptionAlgorithm.java:
##########
@@ -41,22 +42,54 @@ public WrappedKeyDecryptionAlgorithm(Key cekDecryptionKey, KeyAlgorithm supporte
         this.cekDecryptionKey = cekDecryptionKey;
         this.supportedAlgo = supportedAlgo;
         this.unwrap = unwrap;
+        if (KeyAlgorithm.RSA1_5 == supportedAlgo) {
+            LOG.warning("The RSA1_5 JWE key encryption algorithm is deprecated: RSAES-PKCS1-v1_5 is"
+                + " vulnerable to padding oracle attacks, consider migrating to RSA-OAEP");
+        }
     }
     public byte[] getDecryptedContentEncryptionKey(JweDecryptionInput jweDecryptionInput) {
         KeyProperties keyProps = new KeyProperties(getKeyEncryptionAlgorithm(jweDecryptionInput));
         AlgorithmParameterSpec spec = getAlgorithmParameterSpec(jweDecryptionInput);
         if (spec != null) {
             keyProps.setAlgoSpec(spec);
         }
-        if (!unwrap) {
-            keyProps.setBlockSize(getKeyCipherBlockSize());
-            return CryptoUtils.decryptBytes(getEncryptedContentEncryptionKey(jweDecryptionInput),
-                                            getCekDecryptionKey(), keyProps);
+        byte[] fallbackCek = supportedAlgo == KeyAlgorithm.RSA1_5

Review Comment:
   Sorry @coheigea , may be missing something here, but if `fallbackCek` is always random, how the decryption is going to work? The content is guaranteed to be encrypted with different key, right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add a fallback to prevent attacks on RSA 1.5 in the Jose code [cxf]

Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea merged PR #3435:
URL: https://github.com/apache/cxf/pull/3435


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add a fallback to prevent attacks on RSA 1.5 in the Jose code [cxf]

Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea commented on code in PR #3435:
URL: https://github.com/apache/cxf/pull/3435#discussion_r3914236492


##########
rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/WrappedKeyDecryptionAlgorithm.java:
##########
@@ -41,22 +42,54 @@ public WrappedKeyDecryptionAlgorithm(Key cekDecryptionKey, KeyAlgorithm supporte
         this.cekDecryptionKey = cekDecryptionKey;
         this.supportedAlgo = supportedAlgo;
         this.unwrap = unwrap;
+        if (KeyAlgorithm.RSA1_5 == supportedAlgo) {
+            LOG.warning("The RSA1_5 JWE key encryption algorithm is deprecated: RSAES-PKCS1-v1_5 is"
+                + " vulnerable to padding oracle attacks, consider migrating to RSA-OAEP");
+        }
     }
     public byte[] getDecryptedContentEncryptionKey(JweDecryptionInput jweDecryptionInput) {
         KeyProperties keyProps = new KeyProperties(getKeyEncryptionAlgorithm(jweDecryptionInput));
         AlgorithmParameterSpec spec = getAlgorithmParameterSpec(jweDecryptionInput);
         if (spec != null) {
             keyProps.setAlgoSpec(spec);
         }
-        if (!unwrap) {
-            keyProps.setBlockSize(getKeyCipherBlockSize());
-            return CryptoUtils.decryptBytes(getEncryptedContentEncryptionKey(jweDecryptionInput),
-                                            getCekDecryptionKey(), keyProps);
+        byte[] fallbackCek = supportedAlgo == KeyAlgorithm.RSA1_5

Review Comment:
   @reta It's to prevent https://en.wikipedia.org/wiki/Adaptive_chosen-ciphertext_attack#Practical_attacks. By generating a random key and forcing it to be used for decryption we deny that knowledge back to the attacker.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add a fallback to prevent attacks on RSA 1.5 in the Jose code [cxf]

Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3435:
URL: https://github.com/apache/cxf/pull/3435#discussion_r3915150932


##########
rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/WrappedKeyDecryptionAlgorithm.java:
##########
@@ -41,22 +42,54 @@ public WrappedKeyDecryptionAlgorithm(Key cekDecryptionKey, KeyAlgorithm supporte
         this.cekDecryptionKey = cekDecryptionKey;
         this.supportedAlgo = supportedAlgo;
         this.unwrap = unwrap;
+        if (KeyAlgorithm.RSA1_5 == supportedAlgo) {
+            LOG.warning("The RSA1_5 JWE key encryption algorithm is deprecated: RSAES-PKCS1-v1_5 is"
+                + " vulnerable to padding oracle attacks, consider migrating to RSA-OAEP");
+        }
     }
     public byte[] getDecryptedContentEncryptionKey(JweDecryptionInput jweDecryptionInput) {
         KeyProperties keyProps = new KeyProperties(getKeyEncryptionAlgorithm(jweDecryptionInput));
         AlgorithmParameterSpec spec = getAlgorithmParameterSpec(jweDecryptionInput);
         if (spec != null) {
             keyProps.setAlgoSpec(spec);
         }
-        if (!unwrap) {
-            keyProps.setBlockSize(getKeyCipherBlockSize());
-            return CryptoUtils.decryptBytes(getEncryptedContentEncryptionKey(jweDecryptionInput),
-                                            getCekDecryptionKey(), keyProps);
+        byte[] fallbackCek = supportedAlgo == KeyAlgorithm.RSA1_5

Review Comment:
   Makes perfect sense in this case, thanks @coheigea !



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org