Repository navigation
fix: require the password when changing a connection's host - #3716
Conversation
Changing a connection's host without resending the password now returns 400, so a caller who can update the connection can't redirect the stored password to a server they control. Prometheus endpoints, which never send the stored password, drop it instead. The connection form asks for the password when the host is edited and shows the API's message.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: f3db556 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
2 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 1 P3 1 posted as inline comment(s) on the changed lines. 1 P3 folded at the bottom. 🔵 1 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep ReviewScope: ✅ No critical issues found. The core guard is sound, symmetric across both routes, and the shared 🟡 P2 — recommended
🔵 P3 nitpicks (3)
Reviewers (10): correctness, security, adversarial, api-contract, testing, maintainability, kieran-typescript, julik-frontend-races, project-standards, previous-comments. Testing gaps: v1 integration suite omits the no-stored-password and Prometheus-clear host-change branches (shared logic is unit-tested; v2 covers them end-to-end). Previous comments: all prior PR comments are bot-generated (Vercel, changeset, triage, jscpd, e2e) — no human review threads to verify. No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 480 passed • 1 skipped • 1068s
Tests ran across 4 shards in parallel. |
…rometheus flag (review P1/P2) - Normalize the host without stripTrailingSlash, which throws on ''. - Reset the password field when its input hides, so a password typed for a reverted host change isn't saved. - Fall back to the stored isPrometheusEndpoint when the update omits it. - Unit-test every branch of resolveUpdatedPassword and assert the stored password is untouched on a rejected host change.
| const [showUpdatePassword, setShowUpdatePassword] = useState(false); | ||
| // The API rejects a host change that doesn't resend the password. Matches | ||
| // the API's normalization; stripTrailingSlash throws on an empty host. | ||
| const normalizeHost = (host?: string) => (host ?? '').replace(/\/+$/, ''); |
There was a problem hiding this comment.
🟡 P2 — Host normalization exists in two places that have to be kept in sync by hand
The normalize inside resolveUpdatedPassword (packages/api/src/controllers/connection.ts:114) is copied here as normalizeHost, and the comment says it must match the API. If one copy changes (say, the API starts lowercasing the scheme or host), the form hides the password field but the API still returns 400. Move a single normalizeConnectionHost into packages/common-utils/src and import it in both places, which is what the DRY rule in the repository conventions requires.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
Summary
Changing a connection's
hostwithout sendingpasswordkept the stored password. A team member who can edit connections but never knew the password could point a connection at a server they control, and the next query would send the stored password there.Both
PUT /connections/:idandPUT /api/v2/connections/:idnow return 400 (Password is required when changing the host) in that case, and nothing is saved.isPrometheusEndpoint: true), no passwordThe connection form opens the password field when the host is edited, with the hint "Re-enter the password to move this connection to a new host." It also shows the API's error message on a failed update instead of the generic text. The v2 OpenAPI docs describe the new rule.
The internal route previously fetched the connection without its password. The old password was kept only because Mongoose dropped the
password: undefinedkey from$set. It now fetches with the password so the check can see it.Screenshots or video
Not captured yet (no browser available to the authoring agent). To add: Team Settings → Connections → edit a connection's host, before vs after.
How to reproduce
Starting point:
yarn dev(the bug is in the API, so local mode/demo server doesn't show it). Register, create a connection with a password, and copy your API key from Team Settings.On
main:curl -X PUT http://localhost:<api-port>/api/v2/connections/<id> -H "Authorization: Bearer <key>" -H 'Content-Type: application/json' -d '{"name":"x","host":"https://other.example.com:8443","username":"default"}'On this branch:
{"message":"Password is required when changing the host"}, and the host is unchanged.How to test on Vercel preview
Preview routes: /team
Steps:
https://other.example.com:8443./appended.References