aws / aws/aws-encryption-sdk-javascript

Use more privileged memory allocation for the plaintext Buffer in Decrypt

オープン
#1,173 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
TypeScript
スター
260
フォーク
68
平均マージ
22時間 19分
マージ済み PR(30日)
2

説明

### Problem:
[https://github.com/aws/aws-encryption-sdk-javascript/blob/master/modules/decrypt-node/src/decrypt.ts](url)
```javascript
const plaintext: Buffer[] = []
let messageHeader: MessageHeader | false = false
stream
.once('MessageHeader', (header: MessageHeader) => {
messageHeader = header
})
.on('data', (chunk: Buffer) => plaintext.push(chunk))

// This will check both Uint8Array|Buffer
if (ciphertext instanceof Uint8Array) {
stream.end(ciphertext)
} else if (typeof ciphertext === 'string') {
stream.end(Buffer.from(ciphertext, encoding))
} else if (ciphertext.readable) {
ciphertext.pipe(stream)
} else {
throw new Error('Unsupported ciphertext format')
}

await finishedAsync(stream)
if (!messageHeader) throw new Error('Unknown format')

return {
plaintext: Buffer.concat(plaintext),
messageHeader,
}
```

The `Buffer.concat(plaintext)` will result in a new Buffer. However, the `const plaintext: Buffer[] = []` seem not zero-out where sensitive data might remain in memory until gc.

[//]: # (NOTE: If you believe this might be a security issue, please email aws-security@amazon.com instead of creating a GitHub issue. For more details, see the AWS Vulnerability Reporting Guide: https://aws.amazon.com/security/vulnerability-reporting/ )

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

modules/decrypt-node/src/decrypt.ts から始め、平文チャンクがどのように収集され、Buffer.concat によって結合されるかを確認します。この Node.js 復号パスにおける特権付きアロケーションの意味と、ガベージコレクションの前に機密データをどのように扱うべきかを判断します。完了した変更では、復号結果を変更せずに、報告された平文バッファの存続期間に関する懸念に対処する必要があります。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, typescript
領域
security
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。