Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc,test: clarify behavior of DH generateKeys
The DiffieHellman class is an old and thin wrapper around certain OpenSSL functions, many of which are deprecated in OpenSSL 3.0. Because the Node.js API mirrors the OpenSSL API, it adopts some of its peculiarities, but the Node.js documentation does not properly reflect these. Most importantly, despite the documentation saying otherwise, diffieHellman.generateKeys() does not generate a new private key when one has already been set or generated. Based on the documentation alone, users may be led to misuse the API in a way that results in key reuse, which can have drastic negative consequences for subsequent operations that consume the shared secret. These design issues in this old API have been around for many years, and we are not currently aware of any misuse in the ecosystem that falls into the above scenario. Changing the behavior of the API would be a significant breaking change and is thus not appropriate for a security release (nor is it a goal.) The reported issue is treated as CWE-1068 (after a vast amount of uncertainty whether to treat it as a vulnerability at all), therefore, this change only updates the documentation to match the actual behavior. Tests are also added that demonstrate this particular oddity. Newer APIs exist that can be used for some, but not all, Diffie-Hellman operations (e.g., crypto.diffieHellman() that was added in 2020). We should keep modernizing crypto APIs, but that is a non-goal for this security release. The ECDH class mirrors the DiffieHellman class in many ways, but it does not appear to be affected by this particular peculiarity. In particular, ecdh.generateKeys() does appear to always generate a new private key. PR-URL: nodejs-private/node-private#426 Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> CVE-ID: CVE-2023-30590
- Loading branch information