Skip to content

Neon branchNameFor's 63-char truncation has no collision guard — two long, prefix-similar tenant names could resolve to the same branch #8026

Description

@JSONbored

Problem

control-plane/src/neon-database-driver.ts's branchNameFor sanitizes a tenant/product-derived name, then unconditionally .slice(0, 63)s the result (Neon's branch-name length limit) with no check that the truncated result is still unique.

Two distinct tenant names sharing the same first ~50 characters (after the tenant-${product}- prefix and sanitization) would truncate to the identical Neon branch name. provisionNeonDatabase's findBranchByName would then find the other tenant's already-existing branch and hand back its connection/role/password to the new tenant — a cross-tenant data-isolation bug. No test in test/neon-database-driver.test.ts exercises the truncation path.

This needs real Neon length/uniqueness semantics validated against a live account before a fix (e.g. appending a short hash of the untruncated name) is safe to merge — the exact real-infra dependency this issue's boundaries below call out.

Area

control-plane/src/neon-database-driver.ts (branchNameFor).

Proposal

Add a collision-resistant suffix (e.g. a short hash of the pre-truncation name) when the sanitized name would otherwise be truncated, so two long, prefix-similar tenant names can never collide on the same Neon branch name. Validate the exact scheme against Neon's real branch-naming constraints before merging.

Deliverables

  • branchNameFor produces a collision-resistant result for names that would otherwise truncate identically.
  • A test exercising two long, prefix-similar tenant names producing different branch names.
  • The scheme verified against Neon's real API constraints (length, allowed characters) before deploying for real.

Resources

  • control-plane/src/neon-database-driver.ts (branchNameFor, provisionNeonDatabase/findBranchByName)
  • test/neon-database-driver.test.ts (where the missing truncation-collision test belongs)

Boundaries

Scoped to the branch-naming collision issue only — not a broader audit of the Neon driver.

maintainer-only — this touches the real tenant-database provisioning driver and needs validation against live Neon API semantics before a fix is safe to merge; a naive contributor patch risks getting the truncation/hashing scheme subtly wrong against real infra constraints.

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions