Colm O hEigeartaigh created CXF-9282:
----------------------------------------

             Summary: Use AES-GCM by default for JAX-RS XML Encryption and 
reject AES-CBC unless explicitly configured
                 Key: CXF-9282
                 URL: https://issues.apache.org/jira/browse/CXF-9282
             Project: CXF
          Issue Type: Improvement
            Reporter: Colm O hEigeartaigh
            Assignee: Colm O hEigeartaigh
             Fix For: 4.3.0


h3. Background

The JAX-RS XML Security interceptors (\{{XmlEncOutInterceptor}}, 
\{{XmlSecOutInterceptor}}) default to the \{{aes256-cbc}} content encryption 
algorithm, except in FIPS mode, where \{{aes256-gcm}} is already used. On the 
inbound side, \{{XmlEncInInterceptor}} / \{{XmlEncInHandler}} (DOM) and 
\{{XmlSecInInterceptor}} (StAX) accept any content encryption algorithm unless 
\{{encryptionSymmetricKeyAlgo}} is set in the \{{EncryptionProperties}}.

CBC mode in XML Encryption is unauthenticated. A receiver that decrypts CBC 
ciphertext and returns errors or timing that depend on the padding or on the 
decrypted content can act as a decryption oracle for captured messages. CXF 
already returns a single error for all decryption failures in the DOM path, but 
the safest default is to not accept CBC at all.

Sending GCM is not enough on its own: if a receiver still accepts CBC, an 
attacker can relabel a captured GCM message as CBC with the same key 
("backwards compatibility" attack, Jager, Schinzel and Somorovsky, "One Bad 
Apple", NDSS 2013). The protection has to come from the receiver.

h3. Changes in 4.3.0

* \{{XmlEncOutInterceptor}} and \{{XmlSecOutInterceptor}} default to 
\{{http://www.w3.org/2009/xmlenc11#aes256-gcm}}, in all modes (not just FIPS).
* \{{XmlEncInInterceptor}} / \{{XmlEncInHandler}} and \{{XmlSecInInterceptor}} 
accept only \{{aes128-gcm}}, \{{aes192-gcm}} and \{{aes256-gcm}} when no 
\{{encryptionSymmetricKeyAlgo}} is configured. Any other algorithm (AES-CBC, 
Triple DES) is rejected with a 400.
* If \{{encryptionSymmetricKeyAlgo}} is configured, behaviour is unchanged: 
only that exact algorithm is accepted.
* This applies to both directions: servers receiving requests and clients 
receiving responses.

h3. Migration

* No change is needed if both sides run CXF 4.3.0 and neither side configures a 
symmetric algorithm.
* A 4.3.0 receiver will reject CBC messages from older CXF senders (which 
default to \{{aes256-cbc}}) and from other peers that use CBC. Either upgrade 
or configure the sender to use GCM, or, as a temporary measure, set 
\{{encryptionSymmetricKeyAlgo}} on the receiver to the CBC algorithm in use 
(e.g. \{{http://www.w3.org/2001/04/xmlenc#aes256-cbc}}). Note that this 
re-enables the risk described above.
* A 4.3.0 sender talking to an older receiver that pins a CBC algorithm in 
\{{encryptionSymmetricKeyAlgo}} will be rejected. Configure the sender's 
\{{symmetricEncAlgorithm}} explicitly, or update the receiver to a GCM 
algorithm.
* Peers must support AES-GCM in XML Encryption (Apache Santuario does).

h3. Recommendation for earlier releases

Users of earlier releases can get the same protection without upgrading by 
setting \{{encryptionSymmetricKeyAlgo}} to a GCM algorithm (e.g. 
\{{http://www.w3.org/2009/xmlenc11#aes256-gcm}}) on the receiving 
\{{EncryptionProperties}}, and the matching \{{symmetricEncAlgorithm}} on the 
sender.

h3. References

* https://github.com/apache/cxf/pull/3689
* Related hardening on main: #3766, #3767, #3768



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to