Skip to content

Commit fe633d8

Browse files
committed
chore: mark US-027 complete and update progress log
1 parent 91ea777 commit fe633d8

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

progress.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ PRD: ralph/kernel-hardening (46 stories)
102102
- Node driver stdin: buffer writeStdin data, closeStdin resolves Promise passed to exec({ stdin })
103103
- Permission-wrapped VFS affects mount() via populateBin() — fs deny tests must skip driver mounting; childProcess deny tests must include allowAllFs
104104
- Bridge process.stdin does NOT emit 'end' for empty stdin ("") — pass undefined for no-stdin case
105+
- TLS bridge: host wraps net.Socket with tls.TLSSocket, remove only specific event types (not removeAllListeners) — TLSSocket forward end/close to wrapped raw socket for library compat (pg relies on original socket's close listener)
105106
- E2E fixture tests: use NodeFileSystem({ root: projectDir }) for real npm package resolution
106107
- npm/npx in V8 isolate need host filesystem fallback — createHostFallbackVfs wraps kernel VFS
107108
- WasmVM _handleSyscall fdRead case MUST call data.set(result, 0) to write to SAB — without this, worker reads garbage
@@ -2790,3 +2791,28 @@ PRD: ralph/kernel-hardening (46 stories)
27902791
- Reusing the same name with different values exercises the prepared statement cache (pg only sends Parse once, then reuses)
27912792
- e2e-docker fixtures are NOT tracked in the docs Tested Packages table (that's for project-matrix fixtures only)
27922793
---
2794+
2795+
## 2026-03-19 - US-027
2796+
- Implemented tls.connect() bridge for TLS socket upgrade in the sandbox
2797+
- Created pg-ssl e2e-docker fixture for SSL-encrypted Postgres connections
2798+
- Files changed:
2799+
- packages/secure-exec-core/src/shared/bridge-contract.ts (NetSocketUpgradeTlsRaw, tlsModule)
2800+
- packages/secure-exec-core/src/types.ts (netSocketUpgradeTls on NetworkAdapter)
2801+
- packages/secure-exec-core/src/bridge/network.ts (TLSSocket class, tls module, secureConnect dispatch)
2802+
- packages/secure-exec-core/src/shared/permissions.ts (forward netSocketUpgradeTls)
2803+
- packages/secure-exec-core/isolate-runtime/src/inject/require-setup.ts (tls special handling)
2804+
- packages/secure-exec-core/src/generated/isolate-runtime.ts (regenerated)
2805+
- packages/secure-exec-node/src/driver.ts (host-side TLS upgrade, tls import)
2806+
- packages/secure-exec-node/src/bridge-setup.ts (netSocketUpgradeTlsRef)
2807+
- packages/secure-exec/tests/e2e-docker.test.ts (postgres-ssl image, SSL command args)
2808+
- packages/secure-exec/tests/e2e-docker/dockerfiles/postgres-ssl.Dockerfile (new)
2809+
- packages/secure-exec/tests/e2e-docker/pg-ssl/ (new fixture)
2810+
- **Learnings for future iterations:**
2811+
- TLS bridge pattern: host wraps existing net.Socket with Node.js tls.TLSSocket, removes old bridge listeners (data/end/error/close), adds new ones to TLS socket
2812+
- TLSSocket must forward end/close events to the wrapped raw socket — libraries like pg add listeners to the original socket before SSL upgrade, and rely on those listeners to detect shutdown
2813+
- TLSSocket._connectHost/_connectPort must be copied from the original socket so _cleanup() unregisters the correct active handle
2814+
- NetSocket._socketId must be accessible (not private) for TLS module to share it — changed to public underscore-prefixed
2815+
- socket.removeAllListeners() on a raw socket breaks tls.TLSSocket wrapping — only remove specific event types (data/end/error/close/connect)
2816+
- Postgres SSL: use custom Dockerfile (postgres-ssl.Dockerfile) that installs openssl and generates self-signed cert; existing pg fixtures still work when server has SSL enabled (SSL is optional)
2817+
- pg_stat_ssl system view verifies the connection is actually encrypted — query WHERE pid = pg_backend_pid()
2818+
---

scripts/ralph/prd.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@
481481
"Tests pass"
482482
],
483483
"priority": 27,
484-
"passes": false,
485-
"notes": "No database connection in the test suite uses TLS/SSL. In production, pg connections are almost always SSL-encrypted. The pg library's SSL support goes through a different code path (tls.connect wrapper) than plain TCP. Since the tls module is deferred (Tier 4), this may require implementing enough of tls for pg's SSL to work, or documenting the limitation."
484+
"passes": true,
485+
"notes": "Completed. Implemented tls.connect() bridge for TLS socket upgrade. Host wraps existing net.Socket with tls.TLSSocket, re-wires bridge callbacks for decrypted data. TLSSocket forwards end/close events to wrapped raw socket (pg relies on original socket's 'close' listener for shutdown). Custom postgres-ssl.Dockerfile with self-signed cert. Fixture connects with ssl:{rejectUnauthorized:false}, queries pg_stat_ssl to verify encryption, runs CRUD through TLS. Host and sandbox produce identical output."
486486
},
487487
{
488488
"id": "US-028",

0 commit comments

Comments
 (0)