Repository navigation
fix(network): fix BoringSSL diagnostics and TLS - #1655
Conversation
Fixes the four confirmed Secure Network bugs from the post-3.14.0 review: pins loopback HTTPS/WebSocket diagnostics against the expected leaf and CA so Electron BoringSSL does not reject GEN_IPADD Name Constraints (and runs test:secure-network-service under Electron), preserves http_port in /api/secure-network/status, warns on Domain Windows Firewall profiles while fixing UAC cancellation exit codes and /repair firewall_fixed UI handling, and clears all cached certificate state together while isolating config.json IP-change writes on startup. Fixes #1643
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoFix Secure Network TLS diagnostics, firewall feedback, and stale state
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
|
@greptile review |
[Medium impact] The changes affect Secure Network diagnostics, startup, status, and repair within the app. The firewall fix needs a mixed-profile follow-up, and the explicit comment-length requirement must be satisfied before merging. Findings
|
…on` alerts (`main/security/lan-tls/secure-network.ts:568` and `tests/secure-network-service.test.ts:101`) by eliminating all `rejectUnauthorized: false` usage and keeping native TLS certificate validation enabled everywhere. Root cause & invariant: - Electron 45's BoringSSL `x509_vfy` rejects IP Name Constraints (`GEN_IPADD`, OID `2.5.29.30`) on CA certificates, so the previous patch disabled TLS certificate validation (`rejectUnauthorized: false`) and re-implemented verification in `secureConnect` callbacks in both `SecureNetworkService` and `tests/secure-network-service.test.ts`. - Invariant: TLS clients in production and test code must never disable certificate validation (`rejectUnauthorized: false`); native TLS handshake verification must remain enabled while keeping the persisted CA and `/ca.cer` Name Constraints intact for LAN devices. Changes: - `main/security/lan-tls/x509.ts`: Added `caTrustAnchorPemForNodeTls(caDer)` to derive an in-memory PEM trust anchor with only the Name Constraints extension omitted so Electron's BoringSSL and OpenSSL both perform full native signature, issuer, validity, and SAN verification with `rejectUnauthorized: true`. - `main/security/lan-tls/secure-network.ts`: Replaced `createPinnedLoopbackSocket` / `verifyLoopbackPeerCertificate` (and its `rejectUnauthorized: false`) with `loopbackTlsOptions()` passing `ca: caTrustAnchorPemForNodeTls(this.ca.certificateDer)`, `servername: 'localhost'`, and leaf pinning via `checkServerIdentity` to `https.request` (with `agent: false`) and `new WebSocket(...)`. Removed now-unused `crypto` import. - `tests/secure-network-service.test.ts`: Removed `connectWithCa` (`rejectUnauthorized: false`) and passed `ca: caTrustAnchorPemForNodeTls(derFromPem(...))` directly to `https.request`, `new WebSocket`, and `tls.connect`; updated the loopback negative checks to verify live rejection of both rogue-CA and same-CA mismatched-leaf servers under Electron's BoringSSL. Verification: - `rg -n "rejectUnauthorized" main/ tests/ frontend/` confirmed zero remaining `rejectUnauthorized: false` call sites (only the negative regex assertion in `tests/secure-network-windows.test.ts`). - `npm run test:secure-network-certificates`: passed. - `npm run test:secure-network-service` (Electron BoringSSL): passed. - `npm run test:secure-network-lan-integrity`: passed. - `npm run test:secure-network-windows`: passed. - `npm run lint`: passed (0 warnings/errors on modified files). - `npm run build`: passed. - `git diff --check`: passed
Addresses remaining Qodo and Greptile review findings on PR #1655: gives Domain network profiles precedence over Private in parseNetworkProfile() so mixed Private+Domain hosts still warn, retains unpersisted IP-change notices in memory when config.json is unwritable and retries persistence on refresh(), and clarifies diagProfileDomain wording across all 32 locales to direct Domain firewall configuration to Windows Defender Firewall or IT.
Intent
Fix the four confirmed non-product Secure Network bugs tracked in #1643 from the post-3.14.0 dual review: Electron BoringSSL failing loopback diagnostics due to CA IP Name Constraints, missing
http_portin/api/secure-network/status, Windows Firewall Domain-profile false-green / UAC cancel exit-0 //repairUI ignoringfirewall_fixed: false, and stale CA fingerprint/IP state plus unwritableconfig.jsonaborting HTTPS fronts. Ship cleanly viano-mistakesclosing #1643.What Changed
main/security/lan-tls/secure-network.ts,main/routes/secure-network.ts): Pin loopback HTTPS and WebSocket self-checks to the active leaf certificate and verify its CA signature, issuer, validity window, and loopback SANs directly; clear cached CA, leaf, fingerprint, and IP state on startup failure, stop, disable, and reset; preventrecordIpChange()write failures from aborting HTTPS startup; and includehttp_porton each surface returned bybuildSurfaceAddresses.main/security/lan-tls/windows-firewall.ts,frontend/src/components/settings/SecureNetworkCard.tsx,frontend/src/lib/secure-network.ts,frontend/src/lib/i18n/messages/*.json): Report Windowsdomainnetwork profiles aswarn(network_profile_domain) instead ofok, exit non-zero from the elevated PowerShell firewall script when UAC is cancelled or fails to start, and display a warning toast inSecureNetworkCardwhen/secure-network/repairreturnsfirewall_fixed: falsewith new translations across all locale catalogs.package.json,tests/secure-network-*.test.ts): Runtest:secure-network-serviceviatests/run-electron-node-test.cjsand add assertions covering loopback peer certificate verification,http_portin status payloads, Domain profile warnings, UAC cancellation handling, and TLS state cleanup/config write resilience.Risk Assessment
✅ Low: All four Secure Network bug fixes are tightly scoped, preserve TLS and authorization invariants, have direct behavioral test coverage under Electron BoringSSL, and the prior Round 1 source-grep finding in tests/secure-network-windows.test.ts has been cleanly removed.
Testing
Ran the three targeted Secure Network suites (including Electron 45.4.1 BoringSSL loopback diagnostics, rogue-cert rejection, authenticated /api/secure-network/status http_port checks, Domain-profile diagnostics, read-only config.json startup resilience, stale CA state clearing, and Windows PowerShell script checks) and drove a live Electron+HTTPS+Playwright Chromium session against the built Settings UI capturing four screenshots of Domain-profile diagnostics, firewall_fixed:false warning toast, normal repair toast, and HTTPS-to-HTTP disable fallback; all locally exercisable scenarios passed, with native Windows UAC/netsh execution marked untested on macOS.
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
tests/secure-network-windows.test.ts:221- Lines 221-242 add source-content-only substring and regex assertions againstmain/security/lan-tls/secure-network.ts(assertingrejectUnauthorized: falsematch count on lines 232-236, forbidden-token regexes on lines 222-231, and literal source substringsverifyLoopbackPeerCertificate,peerRaw.equals(expectedLeafDer), andpeerCert.verify(caCert.publicKey)on lines 237-242). Source-grepping does not prove runtime behavior (matching text can be dead or commented out and breaks on behavior-preserving refactors). Remove these newly added source-content assertions onsecure-network.ts; the behavioral contract (rejecting missing, mismatched, rogue-CA, expired, and bad-SAN peer certificates on loopback HTTPS and WebSocket diagnostics) is already exercised directly againstverifyLoopbackPeerCertificate,selfRequest, andwebsocketCheckintests/secure-network-service.test.ts:812-920.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm run test:secure-network-servicenpm run test:secure-network-lan-integritynpm run test:secure-network-windowsELECTRON_RUN_AS_NODE=1 ./node_modules/electron/dist/Electron.app/Contents/MacOS/Electronlive POS/KDS/Server App + SecureNetworkService + Playwright Chromium Settings UI verification✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Issues
Closes #1643