Repository navigation
fix(neo4j): connect TLS sessions to the validated address - #10481
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryEncrypted self-hosted Neo4j connections now reach the validated IP through a local TLS relay while keeping hostname and certificate checks.
|
There was a problem hiding this comment.
1 issue found across 4 files
Confidence score: 4/5
- In
apps/sim/lib/internal/neo4j/client.ts, an abort during relay setup can be missed, allowing a connection to start after cancellation. Make relay startup abort-aware and close it before propagating the abort.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/internal/neo4j/client.ts">
<violation number="1" location="apps/sim/lib/internal/neo4j/client.ts:140">
P2: An abort during relay setup is missed because the abort listener is registered only after setup. Make relay startup abort-aware and close it before propagating the abort, so cancellation does not start a connection attempt or wait for the 10-second timeout.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
…ests to integration
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
bolt+s) validated the host, then let the driver connect by name, so the name was resolved a second time at connect. A name that answers a public IP at validation and a private or loopback IP at connect (DNS rebinding) steered the TCP connect inward. Certificate verification stopped it short of a session, but the refused-vs-TLS-error difference still worked as an internal port probe.bolt+sconnection:resolveronly feedsneo4j://routing, and the direct channel callstls.connect(port, address.resolvedHost())withresolvedHost()equal to the URL host. Pinning to the IP in the URL would drop SNI and verify the certificate against the IP.127.0.0.1:<ephemeral>, and the relay opens TLS to the validated IP with SNI set to the configured host,rejectUnauthorized: true, andcheckServerIdentityagainst that host. The certificate check is the same system CA store and hostname rule the driver applied before, but it runs against the pinned address. No globals are patched and no driver internals are used.boltstill connects straight to the validated IP (IPv6 bracketed). Aura (*.databases.neo4j.io) stays on the driver'sneo4j+srouting by name on purpose: those hosts and the routing table they return are operated by Neo4j, not chosen by the caller.createNeo4jDriveris nowopenNeo4jConnection, returning{ driver, close }so the relay closes with the driver, on abort included. A relay-side failure (refused, timeout, untrusted or mismatched certificate) comes back in the driver's usual "Failed to connect to server ... Caused by: ..." shape.Residual: the relay accepts on loopback for the life of one operation (at most 4 accepted connections). Another local process could connect to it in that window, but it only reaches the user's already validated public host, which it could reach directly anyway. Bolt between the driver and the relay is plaintext on loopback, inside the same process.
Type of Change
Testing
lib/internal/neo4j/client.integration.ts(new, integration layer) runs a real loopback TLS server, withneo4j.invalid(never resolves) validated to127.0.0.1:neo4j.invalidand the Bolt magic6060b017Neo4jError(ServiceUnavailable) with the altnames causeENOTFOUND). Reverting each guard on its own (connect by name, dropservername, verify against the IP,rejectUnauthorized: false) also turns a test red.lib/internal/neo4j/client.test.ts: an out-of-range port is rejected before the relay starts. The contract also boundsportto 1–65535.neo4j.invalid. Create, query and introspection all succeeded through the relay. The pre-fix code failed withgetaddrinfo ENOTFOUND neo4j.invalid, which confirms it resolved the name itself.lib/internal/neo4j/operations.test.ts,tools/neo4j,blocks/blocks/neo4j,lib/internal/tool-operations: 33 passedbun run generate(no drift),bun run lint,bun run type-check,bun run check:audits,check:test-types,bun run test:integration lib/internal/neo4j/client.integration.ts,check-block-registry.ts origin/staging, rootbun run testChecklist
test-auditauthoring gate)