aws / aws/aws-encryption-sdk-javascript
Use more privileged memory allocation for the plaintext Buffer in Decrypt
- Ngôn ngữ chính
- TypeScript
- Star
- 260
- Fork
- 68
- Merge trung bình
- 22 giờ 19 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
### 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/ )
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với modules/decrypt-node/src/decrypt.ts và kiểm tra cách các chunk bản rõ được thu thập và kết hợp bằng Buffer.concat. Xác định việc cấp phát đặc quyền có ý nghĩa gì đối với đường dẫn giải mã Node.js này và dữ liệu nhạy cảm nên được xử lý như thế nào trước khi garbage collection. Phần hoàn tất cần giải quyết mối lo ngại đã được báo cáo về vòng đời của bộ đệm bản rõ mà không thay đổi kết quả giải mã.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- node.js, typescript
- Lĩnh vực
- security
- Loại issue
- Lỗi
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100