-
Notifications
You must be signed in to change notification settings - Fork 404
fix(internal-plugin-encryption): fail closed on KMS x5c chain validation (FPV-531) #5154
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
base: next
Are you sure you want to change the base?
Changes from 3 commits
e09577a
7cdd975
d78ada7
0cc340a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,38 @@ | |
| * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file. | ||
| */ | ||
|
|
||
| import {has} from 'lodash'; | ||
|
|
||
| import DEFAULT_KMS_CAROOTS from './kms-default-caroots'; | ||
|
|
||
| /** | ||
| * lodash merge combines arrays by index, so an explicit encryption.caroots | ||
| * override (including []) would otherwise retain default root entries. | ||
| * | ||
| * @param {Object} webexConfig merged webex config object | ||
| * @param {Object} [overrideConfig] config passed to initialize/setConfig | ||
| * @returns {void} | ||
| */ | ||
| export function applyEncryptionConfigOverrides(webexConfig, overrideConfig = {}) { | ||
| if (!webexConfig?.encryption) { | ||
| return; | ||
| } | ||
|
|
||
| if (has(overrideConfig, 'encryption.caroots')) { | ||
| webexConfig.encryption.caroots = overrideConfig.encryption.caroots; | ||
| } | ||
| } | ||
|
|
||
| export default { | ||
| encryption: { | ||
| /** | ||
| * PEM (base64 DER) encoded CA certificates trusted to sign the KMS | ||
| * static-key certificate chain. KMS validation fails closed when this | ||
| * list is empty; deployments MUST provide the Webex KMS issuing roots. | ||
| * @type {Array<string>} | ||
| */ | ||
| caroots: DEFAULT_KMS_CAROOTS, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a consumer supplies Useful? React with 👍 / 👎. |
||
|
|
||
| joseOptions: { | ||
| compact: true, | ||
| contentAlg: 'A256GCM', | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import {assert} from '@webex/test-helper-chai'; | ||
| import {cloneDeep, merge} from 'lodash'; | ||
|
|
||
| import defaultConfig, {applyEncryptionConfigOverrides} from '../../../src/config'; | ||
|
|
||
| describe('internal-plugin-encryption', () => { | ||
| describe('encryption config', () => { | ||
| it('replaces caroots when consumer supplies an empty array', () => { | ||
| const webexConfig = merge({}, defaultConfig, {encryption: {caroots: []}}); | ||
|
|
||
| assert.isAbove(webexConfig.encryption.caroots.length, 0); | ||
|
|
||
| applyEncryptionConfigOverrides(webexConfig, {encryption: {caroots: []}}); | ||
|
|
||
| assert.deepEqual(webexConfig.encryption.caroots, []); | ||
| }); | ||
|
|
||
| it('replaces caroots when consumer supplies a single custom root', () => { | ||
| const customRoot = 'CUSTOM_CA_ROOT'; | ||
| const webexConfig = merge({}, defaultConfig, {encryption: {caroots: [customRoot]}}); | ||
|
|
||
| assert.isAbove(webexConfig.encryption.caroots.length, 1); | ||
| assert.include(webexConfig.encryption.caroots, customRoot); | ||
|
|
||
| applyEncryptionConfigOverrides(webexConfig, {encryption: {caroots: [customRoot]}}); | ||
|
|
||
| assert.deepEqual(webexConfig.encryption.caroots, [customRoot]); | ||
| }); | ||
|
|
||
| it('leaves default caroots when consumer does not override caroots', () => { | ||
| const webexConfig = merge({}, defaultConfig, {encryption: {kmsInitialTimeout: 1000}}); | ||
| const expectedCaroots = cloneDeep(webexConfig.encryption.caroots); | ||
|
|
||
| applyEncryptionConfigOverrides(webexConfig, {encryption: {kmsInitialTimeout: 1000}}); | ||
|
|
||
| assert.deepEqual(webexConfig.encryption.caroots, expectedCaroots); | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a consumer retains and later mutates the array passed in
config.encryption.caroots, this direct assignment mutates the SDK's active trust store as well. This differs from the normalmerge({}, …)configuration path, which creates a separate array, and can unexpectedly add or remove trusted roots after initialization without callingsetConfig(). Clone the explicit replacement array while preserving replacement rather than index-merge semantics.Useful? React with 👍 / 👎.