aws / aws/aws-encryption-sdk-javascript

Hierarchical Keyring: cold-cache stampede — N concurrent decrypts → N DynamoDB/KMS calls

Đang mở
#1,663 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
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ả

### Security issue notifications

If you discover a potential security issue in the AWS Encryption SDK we ask that you notify AWS Security via our [vulnerability reporting page](https://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue.

### Problem:

The Node Hierarchical Keyring doesn't de-dupe concurrent branch-key lookups. If I fire a lot of decrypts for the same branch key at once against a cold cache, they all miss the cache together (it's only filled after the keystore call returns), so each one hits the keystore on its own.

So instead of one lookup I get N DynamoDB `GetItem` + N KMS `Decrypt` calls. Easy to repro: `await Promise.all` of ~3000 decrypts for the same key version, and you see ~3000 keystore calls instead of 1. Encrypt has the same problem since it shares the same code path.

### Solution:

Add single-flight to `getBranchKeyMaterials`: on a miss, the first caller starts the keystore fetch and stores the in-flight promise (keyed by cache entry id); everyone else for the same key awaits that promise instead of starting their own. The entry is dropped once it settles, so the materials cache still owns caching and TTL, and a failed request isn't shared — the next call just retries.

### Out of scope:

The legacy caching CMM has the same gap but it's a separate path, so I'm not touching it here.

[//]: # (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

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start at the Node Hierarchical Keyring's getBranchKeyMaterials path and trace how the materials cache handles a cold-cache lookup. Reproduce the issue with concurrent decrypts or encrypts for one branch-key version and verify that one in-flight keystore request is shared, settled entries are removed, and a failed request can be retried.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, node.js, typescript
Lĩnh vực
backend, security
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.