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

Offen
#1,663 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
52/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Ruhig
Tech-Stack
aws, node.js, typescript
Bereich
backend, security

Rechercherichtung

Beginne beim Pfad getBranchKeyMaterials von Node Hierarchical Keyring und verfolge, wie der Materials-Cache eine Abfrage bei leerem Cache verarbeitet. Reproduziere das Problem mit gleichzeitigen Entschlüsselungen oder Verschlüsselungen für eine Branch-Key-Version und überprüfe, dass eine einzige laufende Keystore-Anfrage gemeinsam genutzt wird, abgeschlossene Einträge entfernt werden und eine fehlgeschlagene Anfrage erneut versucht werden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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. 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.

Vorherrschende Sprache
TypeScript
Sterne
260
Forks
68
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus aws/aws-encryption-sdk-javascript

Alle Issues in aws/aws-encryption-sdk-javascript

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.