Skip to content

Commit 03f89c4

Browse files
feat(awm): add security recommendation
1 parent 30ea0a0 commit 03f89c4

File tree

1 file changed

+10
-35
lines changed

1 file changed

+10
-35
lines changed

demo-kms-script/dinamo-interface.md

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Dinamo HSM KMS Implementation Documentation
22

3+
## ⚠️ Security Recommendation
4+
5+
**For production KMS implementations, consider implementing the KMS-API in a C++ like language, or use typed arrays like Uint8Array for all sensitive data because JavaScript does not support secure memory management.**
6+
7+
**Recommended Alternatives:**
8+
- **C++/Rust**: Languages with explicit memory management and secure allocation
9+
- **Node.js Typed Arrays**: Use `Uint8Array` for sensitive data with explicit zeroing
10+
- **Native Addons**: Implement cryptographic operations in native C++ modules
11+
- **Hardware Security**: Use HSM-backed secure memory when available
12+
313
This document provides a reference implementation for integrating the 4 KMS API's with Dinamo HSM, covering the complete request-response flow from API handlers to HSM operations.
414

515
## Demo Scripts
@@ -153,41 +163,6 @@ async generateDataKey(rootKey: string, keySpec: DataKeyTypeType): Promise<Genera
153163
5. **Automatic Cleanup**: HSM deletes temporary key
154164
6. **⚠️ MEMORY SECURITY**: Plaintext key must be wiped from memory after use
155165

156-
### Memory Security Best Practices
157-
158-
```typescript
159-
// Example of secure memory handling (recommended for production)
160-
async secureDataKeyGeneration(rootKey: string): Promise<GenerateDataKeyKmsRes> {
161-
let plaintextKey: string | null = null;
162-
163-
try {
164-
const result = await this.generateDataKey(rootKey, 'AES-256');
165-
plaintextKey = result.plaintextKey;
166-
167-
// Use the plaintext key immediately
168-
const encryptedData = encrypt(plaintextKey, sensitiveData);
169-
170-
return {
171-
encryptedKey: result.encryptedKey,
172-
encryptedData: encryptedData
173-
};
174-
} finally {
175-
// **CRITICAL**: Explicitly wipe plaintext key from memory
176-
if (plaintextKey) {
177-
// Overwrite with random data multiple times
178-
for (let i = 0; i < 3; i++) {
179-
plaintextKey = crypto.randomBytes(plaintextKey.length).toString('base64');
180-
}
181-
plaintextKey = null;
182-
}
183-
184-
// Force garbage collection (if available)
185-
if (global.gc) {
186-
global.gc();
187-
}
188-
}
189-
}
190-
```
191166

192167
**Security Considerations:**
193168
- **Immediate Use**: Plaintext keys should be used immediately after generation

0 commit comments

Comments
 (0)