Skip to content

fix: resource exhaustion from an incomplete encrypted message #348

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

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion modules/decrypt-browser/test/decrypt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

/* eslint-env mocha */

import { expect } from 'chai'
import * as chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { decrypt } from '../src/index'
import { AlgorithmSuiteIdentifier } from '@aws-crypto/material-management-browser'
import * as fixtures from './fixtures'
chai.use(chaiAsPromised)
const { expect } = chai

describe('decrypt', () => {
it('buffer', async () => {
Expand Down Expand Up @@ -52,4 +55,34 @@ describe('decrypt', () => {
}
)
})

it('verify incomplete chipertext will fail for an un-signed algorithm suite', async () => {
const data = fixtures.base64CiphertextAlgAes256GcmIv12Tag16HkdfWith4Frames()
const keyring = fixtures.decryptKeyring()

// First we make sure that the test vector is well formed
await decrypt(keyring, data)

// This is the real test:
// trying to decrypt
// on EVERY boundary
for (let i = 0; data.byteLength > i; i++) {
await expect(decrypt(keyring, data.slice(0, i))).to.rejectedWith(Error)
}
})

it('verify incomplete chipertext will fail for a signed algorithm suite', async () => {
const data = fixtures.base64CiphertextAlgAes256GcmIv12Tag16HkdfSha384EcdsaP384With4Frames()
const keyring = fixtures.decryptKeyring()

// First we make sure that the test vector is well formed
await decrypt(keyring, data)

// This is the real test:
// trying to decrypt
// on EVERY boundary
for (let i = 0; data.byteLength > i; i++) {
await expect(decrypt(keyring, data.slice(0, i))).to.rejectedWith(Error)
}
})
})
Loading