Skip to content

Commit 84a7034

Browse files
authored
fix: Add CVE-2023-46809 option to integration node (#1424)
Adding a CVE-2023-46809 option to integration-node to skip RSA_PKCS1_OAEP_PADDING test vectors. Adding a CI target to start node with --security-revert=CVE-2023-46809 and attempt RSA_PKCS1_OAEP_PADDING test vectors.
1 parent c1e61d2 commit 84a7034

File tree

6 files changed

+42
-32
lines changed

6 files changed

+42
-32
lines changed

.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ module.exports = {
8080
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': false }],
8181
// This rule fights with Prettier and no-semi
8282
'@typescript-eslint/no-extra-semi': 'off',
83+
// Added in later versions of @typescript-eslint
84+
'@typescript-eslint/explicit-module-boundary-types': 'off',
85+
'@typescript-eslint/no-unused-vars': 'off',
8386
},
8487
// This is a good rule,
8588
// but in many tests,

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
CI:
88
strategy:
99
matrix:
10-
node: [16, 18.3.0, 20.4.0]
10+
node: [16, 18.x, 20.x, 22.x, latest]
1111
fail-fast: false
1212
runs-on: codebuild-AWS-ESDK-JS-Release-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-5.0-large
1313
permissions:

modules/integration-node/src/cli.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,21 @@ import {
1212

1313
const cli = yargs
1414
.command('decrypt', 'verify decrypt vectors', (y) =>
15-
y.option('vectorFile', {
16-
alias: 'v',
17-
describe: 'a vector zip file from aws-encryption-sdk-test-vectors',
18-
demandOption: true,
19-
type: 'string',
20-
})
15+
y
16+
.option('vectorFile', {
17+
alias: 'v',
18+
describe: 'a vector zip file from aws-encryption-sdk-test-vectors',
19+
demandOption: true,
20+
type: 'string',
21+
})
22+
.option('CVE-2023-46809', {
23+
alias: 'C',
24+
describe:
25+
'Attempt RSA_PKCS1_OAEP_PADDING decrypt vectors, requires node process started with --security-revert=CVE-2023-46809',
26+
default: false,
27+
demandOption: false,
28+
type: 'boolean',
29+
})
2130
)
2231
.command('encrypt', 'verify encrypt manifest', (y) =>
2332
y
@@ -79,6 +88,7 @@ const cli = yargs
7988
_: [command],
8089
tolerateFailures,
8190
testName,
91+
['CVE-2023-46809']: CVE202346809,
8292
concurrency,
8393
} = await argv
8494
/* I set the result to 1 so that if I fall through the exit condition is a failure */
@@ -89,6 +99,7 @@ const cli = yargs
8999
vectorFile,
90100
tolerateFailures,
91101
testName,
102+
!!CVE202346809,
92103
concurrency
93104
)
94105
} else if (command === 'encrypt') {

modules/integration-node/src/integration_tests.ts

+12
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export async function integrationDecryptTestVectors(
162162
vectorFile: string,
163163
tolerateFailures = 0,
164164
testName?: string,
165+
CVE202346809?: boolean,
165166
concurrency = 1
166167
): Promise<number> {
167168
const tests = await parseIntegrationTestVectorsToTestVectorIterator(
@@ -174,6 +175,17 @@ export async function integrationDecryptTestVectors(
174175
if (testName) {
175176
if (test.name !== testName) return true
176177
}
178+
179+
if (
180+
!CVE202346809 &&
181+
test.keysInfo.some(
182+
([info, _]) =>
183+
info.type == 'raw' && info['padding-algorithm'] == 'pkcs1'
184+
)
185+
) {
186+
return true
187+
}
188+
177189
return handleTestResults(
178190
await testDecryptVector(test),
179191
notSupportedDecryptMessages

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"integration-browser-encrypt": "npm run build; integration-browser encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle --karma -c cpu",
3939
"browser-integration": "run-s integration-browser-*",
4040
"integration-node-decrypt": "npm run build; integration-node decrypt -v $npm_package_config_localTestVectors -c cpu",
41+
"integration-node-decrypt-legacy": "node --security-revert=CVE-2023-46809 ./modules/integration-node/build/main/src/cli.js decrypt -v $npm_package_config_localTestVectors -c cpu --CVE-2023-46809",
4142
"integration-node-encrypt": "npm run build; integration-node encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle -c cpu",
4243
"node-integration": "run-s integration-node-*",
4344
"integration": "run-s integration-*",

wallaby.conf.js

+8-25
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ const compilerOptions = Object.assign({
88
})
99

1010
module.exports = function (wallaby) {
11+
var path = require('path');
12+
process.env.NODE_PATH += path.delimiter + path.join(wallaby.localProjectDir, 'core', 'node_modules');
13+
1114
return {
1215
files: [
1316
'modules/**/src/**/*.ts',
1417
'modules/**/fixtures.ts',
15-
'!modules/**/test/**/*.test.ts',
16-
'!modules/**/node_modules/**',
17-
'!modules/**/build/**',
18-
'!modules/*-+(browser|backend)/**/*.ts'
18+
{ pattern: 'modules/**/test/**/*.test.ts', ignore: true},
19+
{ pattern: 'modules/**/node_modules/**', ignore: true},
20+
{ pattern: 'modules/**/build/**', ignore: true},
21+
{ pattern: 'modules/*-browser/**/*.ts', ignore: true},
22+
{ pattern: 'modules/*-backend/**/*.ts', ignore: true},
1923
],
2024
tests: [
2125
'modules/**/test/**/*test.ts',
@@ -32,26 +36,5 @@ module.exports = function (wallaby) {
3236
},
3337
env: { type: 'node' },
3438
debug: true,
35-
setup: w => {
36-
const { projectCacheDir } = w
37-
const path = require('path')
38-
const { Module } = require('module')
39-
const fs = require('fs')
40-
if (!Module._originalRequire) {
41-
const modulePrototype = Module.prototype
42-
Module._originalRequire = modulePrototype.require
43-
modulePrototype.require = function (filePath) {
44-
if (!filePath.startsWith('@aws-crypto')) {
45-
return Module._originalRequire.call(this, filePath)
46-
}
47-
const [, _module] = filePath.split('/')
48-
const _filePath = path.join(projectCacheDir, 'modules', _module, 'src', 'index.js')
49-
if (!fs.existsSync(_filePath)) {
50-
return Module._originalRequire.call(this, filePath)
51-
}
52-
return Module._originalRequire.call(this, _filePath)
53-
}
54-
}
55-
}
5639
}
5740
}

0 commit comments

Comments
 (0)