Skip to content

fix(security): secure SSL Bump key wiping via tmpfs#1156

Merged
Mossaka merged 1 commit intomainfrom
fix/096-ssl-bump-key-security
Mar 5, 2026
Merged

fix(security): secure SSL Bump key wiping via tmpfs#1156
Mossaka merged 1 commit intomainfrom
fix/096-ssl-bump-key-security

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Mar 5, 2026

Summary

  • Store SSL Bump CA private keys in tmpfs (memory-only filesystem) when available, so keys never touch persistent disk
  • Securely wipe all SSL key material (overwrite with random data) before deletion during cleanup
  • Clean up ssl_db generated certificates alongside CA keys

Changes

  • src/ssl-bump.ts: Add mountSslTmpfs/unmountSslTmpfs for memory-only storage, secureWipeFile for secure deletion, cleanupSslKeyMaterial for comprehensive SSL cleanup
  • src/docker-manager.ts: Integrate secure SSL cleanup into the cleanup lifecycle (before rmSync)
  • src/ssl-bump.test.ts: Add tests for secure wipe and cleanup functions, update mocks for tmpfs

Security

  • tmpfs: When AWF runs with root/sudo (typical), SSL keys are stored in RAM-only tmpfs mount. On unmount, all data is immediately destroyed.
  • Secure wipe: Even without tmpfs, keys are overwritten with crypto.randomBytes() and fsync'd before unlink, preventing recovery from disk.
  • Defense in depth: Both mechanisms work together — tmpfs prevents disk writes, secure wipe handles the fallback case.

Test plan

  • npm run build passes
  • npm test passes (821 tests)
  • npm run lint passes (0 errors)
  • New tests for secureWipeFile, cleanupSslKeyMaterial
  • Existing SSL Bump tests still pass with updated mocks

Fixes #247

🤖 Generated with Claude Code

Store SSL Bump CA private keys in tmpfs (memory-only filesystem) when
available, ensuring keys never touch persistent disk. When tmpfs is not
available (e.g., insufficient permissions), fall back to disk storage.

On cleanup, all SSL key material is securely wiped by overwriting with
random data before deletion, preventing recovery of sensitive CA keys.

- Add mountSslTmpfs/unmountSslTmpfs for memory-only key storage
- Add secureWipeFile to overwrite files with random data before unlink
- Add cleanupSslKeyMaterial to wipe all SSL files including ssl_db certs
- Integrate secure cleanup into docker-manager cleanup lifecycle

Fixes #247

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 5, 2026 19:30
@Mossaka Mossaka merged commit 6278746 into main Mar 5, 2026
13 of 18 checks passed
@Mossaka Mossaka deleted the fix/096-ssl-bump-key-security branch March 5, 2026 19:31
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 82.36% 82.42% 📈 +0.06%
Statements 82.33% 82.39% 📈 +0.06%
Functions 82.75% 82.60% 📉 -0.15%
Branches 74.38% 74.52% 📈 +0.14%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/ssl-bump.ts 100.0% → 90.6% (-9.44%) 100.0% → 90.6% (-9.44%)
src/docker-manager.ts 83.1% → 83.6% (+0.49%) 82.4% → 82.9% (+0.48%)

Coverage comparison generated by scripts/ci/compare-coverage.ts


if (size > 0) {
// Overwrite with random data
const fd = fs.openSync(filePath, 'w');

if (size > 0) {
// Overwrite with random data
const fd = fs.openSync(filePath, 'w');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] H2: SSL Bump Key Exposure Risk - Implement secure key wiping + tmpfs

1 participant