aws / aws/aws-encryption-sdk-javascript
Use more privileged memory allocation for the plaintext Buffer in Decrypt
- Lingua principale
- TypeScript
- Stelle
- 260
- Fork
- 68
- Merge medio
- 22h 19m
- PR unite (30g)
- 2
Descrizione
### 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/ )
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da modules/decrypt-node/src/decrypt.ts e analizza come i chunk di testo in chiaro vengono raccolti e combinati tramite Buffer.concat. Determina cosa significa l’allocazione privilegiata per questo percorso di decrittazione Node.js e come devono essere gestiti i dati sensibili prima della garbage collection. La modifica completata deve risolvere il problema segnalato relativo alla durata del buffer di testo in chiaro senza cambiare il risultato della decrittazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- node.js, typescript
- Ambito
- security
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100