Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use RSA_PKCS1_PADDING with v22+ - --security-revert suggests CVE-2024-PEND #55628

Closed
SPodjasek opened this issue Oct 31, 2024 · 7 comments · Fixed by #55629
Closed
Labels
crypto Issues and PRs related to the crypto subsystem. security Issues and PRs related to security.

Comments

@SPodjasek
Copy link

Version

v22.11.0, v23.1.0

Platform

Linux 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Trying to run this sample code:

import('node:crypto').then(
  ({ constants, generateKeyPairSync, privateDecrypt, publicEncrypt }) => {
    console.log(`Running on ${process.version}`);
    const padding = constants.RSA_PKCS1_PADDING;
    const { publicKey, privateKey } = generateKeyPairSync('rsa', {
      modulusLength: 2048,
    });

    const source = Buffer.from('test');
    const encrypted = publicEncrypt({ key: publicKey, padding }, source);
    const decrypted = privateDecrypt({ key: privateKey, padding }, encrypted);

    console.log(
      source.toString() === decrypted.toString() ? 'Match' : 'Failure'
    );
  }
);

How often does it reproduce? Is there a required condition?

I've tested on v22.0.0, v22.10.0, v22.11.0 and v23.1.0 - all return

TypeError: RSA_PKCS1_PADDING is no longer supported for private decryption, 
  this can be reverted with --security-revert=CVE-2024-PEND

What is the expected behavior? Why is that the expected behavior?

It should run with a warning as v20.17.0

SECURITY WARNING: Reverting CVE-2023-46809: Marvin attack on PKCS#1 padding

What do you see instead?

It complains about unknown CVE

node: Error: Attempt to revert an unknown CVE [CVE-2024-PEND]

Additional information

Complete 'test' session

$ nvm use v20
Now using node v20.17.0 (npm v10.8.3)
$ node test.js                                        
Running on v20.17.0
node:internal/crypto/cipher:79
    return method(data, format, type, passphrase, buffer, padding, oaepHash,
           ^

TypeError: RSA_PKCS1_PADDING is no longer supported for private decryption, this can be reverted with --security-revert=CVE-2023-46809
    at node:internal/crypto/cipher:79:12
    at file:///.../test.js:11:23 {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v20.17.0
$ node --security-revert=CVE-2023-46809 test.js        
SECURITY WARNING: Reverting CVE-2023-46809: Marvin attack on PKCS#1 padding
Running on v20.17.0
Match
$ nvm use v22                                  
Now using node v22.11.0 (npm v10.9.0)
$ node test.js                                 
Running on v22.11.0
node:internal/crypto/cipher:79
    return method(data, format, type, passphrase, buffer, padding, oaepHash,
           ^

TypeError: RSA_PKCS1_PADDING is no longer supported for private decryption, this can be reverted with --security-revert=CVE-2024-PEND
    at node:internal/crypto/cipher:79:12
    at file:///.../test.js:11:23 {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v22.11.0
$ node --security-revert=CVE-2024-PEND test.js 
node: Error: Attempt to revert an unknown CVE [CVE-2024-PEND]
$ nvm use v23                                 
Now using node v23.1.0 (npm v10.9.0)
$ node test.js                                
Running on v23.1.0
node:internal/crypto/cipher:79
    return method(data, format, type, passphrase, buffer, padding, oaepHash,
           ^

TypeError: RSA_PKCS1_PADDING is no longer supported for private decryption, this can be reverted with --security-revert=CVE-2024-PEND
    at node:internal/crypto/cipher:79:12
    at file:///.../test.js:11:23 {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v23.1.0
$ node --security-revert=CVE-2024-PEND test.js
node: Error: Attempt to revert an unknown CVE [CVE-2024-PEND]

@avivkeller avivkeller added crypto Issues and PRs related to the crypto subsystem. security Issues and PRs related to security. regression Issues related to regressions. labels Oct 31, 2024
@aduh95
Copy link
Contributor

aduh95 commented Oct 31, 2024

@mhdawson @RafaelGSS git blame points at 54cd268, should the error message mention CVE-2023-46809 instead of CVE-2024-PEND? Or should the error message message be amended to remove the this can be reverted part?

@richardlau
Copy link
Member

The this can be reverted part should be removed. The revert was only added to Node.js 21, 20 and 18 (the release lines at the time).

main should not have any reverts

* For *main* this list should always be empty!
so it is not possible to revert that fix for Node.js 22 and 23 (which were created later than that fix).

@richardlau
Copy link
Member

Opened #55629 to fix the error message.

@richardlau richardlau removed the regression Issues related to regressions. label Nov 1, 2024
@SPodjasek
Copy link
Author

@richardlau Out of curiosity is it expected that OpenSSL will release patched implementation - or should PKCS #1 v1.5 be considered as obsolete and will never be supported again?
I'm not a crypto expert, but we need to use this implementation for communication with some governmental systems which I guess won't change anything in near future, nor I don't think they'll ever switch to RSA OAEP.

@richardlau
Copy link
Member

@SPodjasek AIUI OpenSSL patched 3.2 but do not plan to merge to 3.1 (or 3.0). From our point-of-view we're going to stay on OpenSSL 3.0 for Node.js 22 for as long as possible since OpenSSL 3.0 has long term support (LTS). We'll consider our options when OpenSSL announced their successor LTS to OpenSSL 3.0.

Some Linux distros (e.g. Fedora/RHEL) have patched their OpenSSL implementations -- if you get Node.js on those from their package repositories you'll be linked to those patched implementations.

@SPodjasek
Copy link
Author

@richardlau Great, thank you for clarifying that

aduh95 pushed a commit that referenced this issue Nov 5, 2024
The ability to revert the fix for CVE-2023-46809 was only added to
Node.js 18.x, 20.x and 21.x as, per policy, security reverts are only
added to the existing supported release lines at the time of the fix.

The error message thrown when `RSA_PKCS1_PADDING` is used on `main`
and subsequent major versions (i.e. Node.js 22 and 23) when OpenSSL
does not support implicit rejections should not have suggested that
it is possible to revert the fix.

PR-URL: #55629
Fixes: #55628
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
aduh95 pushed a commit that referenced this issue Nov 6, 2024
The ability to revert the fix for CVE-2023-46809 was only added to
Node.js 18.x, 20.x and 21.x as, per policy, security reverts are only
added to the existing supported release lines at the time of the fix.

The error message thrown when `RSA_PKCS1_PADDING` is used on `main`
and subsequent major versions (i.e. Node.js 22 and 23) when OpenSSL
does not support implicit rejections should not have suggested that
it is possible to revert the fix.

PR-URL: #55629
Fixes: #55628
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
tpoisseau pushed a commit to tpoisseau/node that referenced this issue Nov 21, 2024
The ability to revert the fix for CVE-2023-46809 was only added to
Node.js 18.x, 20.x and 21.x as, per policy, security reverts are only
added to the existing supported release lines at the time of the fix.

The error message thrown when `RSA_PKCS1_PADDING` is used on `main`
and subsequent major versions (i.e. Node.js 22 and 23) when OpenSSL
does not support implicit rejections should not have suggested that
it is possible to revert the fix.

PR-URL: nodejs#55629
Fixes: nodejs#55628
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
ruyadorno pushed a commit that referenced this issue Nov 27, 2024
The ability to revert the fix for CVE-2023-46809 was only added to
Node.js 18.x, 20.x and 21.x as, per policy, security reverts are only
added to the existing supported release lines at the time of the fix.

The error message thrown when `RSA_PKCS1_PADDING` is used on `main`
and subsequent major versions (i.e. Node.js 22 and 23) when OpenSSL
does not support implicit rejections should not have suggested that
it is possible to revert the fix.

PR-URL: #55629
Fixes: #55628
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
ruyadorno pushed a commit that referenced this issue Nov 27, 2024
The ability to revert the fix for CVE-2023-46809 was only added to
Node.js 18.x, 20.x and 21.x as, per policy, security reverts are only
added to the existing supported release lines at the time of the fix.

The error message thrown when `RSA_PKCS1_PADDING` is used on `main`
and subsequent major versions (i.e. Node.js 22 and 23) when OpenSSL
does not support implicit rejections should not have suggested that
it is possible to revert the fix.

PR-URL: #55629
Fixes: #55628
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
ruyadorno pushed a commit that referenced this issue Nov 27, 2024
The ability to revert the fix for CVE-2023-46809 was only added to
Node.js 18.x, 20.x and 21.x as, per policy, security reverts are only
added to the existing supported release lines at the time of the fix.

The error message thrown when `RSA_PKCS1_PADDING` is used on `main`
and subsequent major versions (i.e. Node.js 22 and 23) when OpenSSL
does not support implicit rejections should not have suggested that
it is possible to revert the fix.

PR-URL: #55629
Fixes: #55628
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
@Ceres6
Copy link
Contributor

Ceres6 commented Jan 3, 2025

Hi! Sorry, does that mean that we can not use Node v22 if we need to use that feature? @richardlau

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. security Issues and PRs related to security.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants