Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(pam-clickhouse): check both ports without a retyped password
bernie-g5c8ea4a652b2
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-router.tsindex c803c32eaf..3d4454ca6f 100644--- a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts@@ -95,7 +95,12 @@ const accountDetailVariants = Object.entries(ACCOUNT_TYPE_CONFIGS).map(([accountaccessibilityIssues: z.array(z.nativeEnum(PamAccountAccessibilityIssue)).describe("Reasons the account cannot launch a session, if any"),- isStale: z.boolean().describe("Whether the discovery source's latest scan no longer found this account.")+ isStale: z.boolean().describe("Whether the discovery source's latest scan no longer found this account."),+ webAccessUnavailableReason: z+ .string()+ .nullable()+ .optional()+ .describe("Why a browser session cannot open this account, or null when it can")}));diff --git a/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.ts b/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.tsindex e36b8490d8..b3d109723a 100644--- a/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.ts+++ b/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.ts@@ -18,7 +18,7 @@ import {CLOUD_CONNECTION_VALIDATORS,exceedsOraclePasswordLimit,ORACLE_MAX_PASSWORD_LENGTH,- TestConnectionMode+ testVerifiesCredential} from "../pam-account/pam-account-connection-test";import { TPamAccountDALFactory, TPamAccountDetail } from "../pam-account/pam-account-dal";import {@@ -228,8 +228,8 @@ export const pamAccountHeartbeatServiceFactory = ({return { status: PamHeartbeatStatus.Unknown, message: "This account type cannot be checked yet" };}- // Every type has a login-based check, so a TCP fallback means the credential is incomplete, not healthy.- if (test.request.mode === TestConnectionMode.Tcp) {+ // Every type has a login-based check, so a check without one means the credential is incomplete, not healthy.+ if (!testVerifiesCredential(test.request)) {return {status: PamHeartbeatStatus.Unknown,message: "This account is missing the credential details needed to sign in"diff --git a/backend/src/ee/services/pam-account/pam-account-connection-test.test.ts b/backend/src/ee/services/pam-account/pam-account-connection-test.test.tsindex 9fae2c78ba..9190e01df2 100644--- a/backend/src/ee/services/pam-account/pam-account-connection-test.test.ts+++ b/backend/src/ee/services/pam-account/pam-account-connection-test.test.ts@@ -4,7 +4,8 @@ import { PamAccountType, PamSshAuthMethod } from "../pam/pam-enums";import {buildGatewayConnectionTest,ORACLE_MAX_PASSWORD_LENGTH,- TestConnectionMode+ TestConnectionMode,+ testVerifiesCredential} from "./pam-account-connection-test";const ORG_ID = "11111111-1111-1111-1111-111111111111";@@ -309,4 +310,42 @@ describe("buildGatewayConnectionTest: ClickHouse", () => {expect(result?.additionalPorts).toEqual([8123]);expect(wireKeys(result!.request)).not.toContain("nativePort");});++ test("an edit without a new password still checks both ports, sending no credential", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.ClickHouse,+ { ...connectionDetails, nativePort: 9000 },+ { username: "default" },+ ORG_ID+ );++ expect(result?.request).toMatchObject({+ mode: TestConnectionMode.ClickHouse,+ probeOnly: true,+ httpPort: 8123,+ nativePort: 9000+ });+ expect(result?.additionalPorts).toEqual([8123, 9000]);+ expect(wireKeys(result!.request)).not.toContain("username");+ expect(wireKeys(result!.request)).not.toContain("password");+ expect(testVerifiesCredential(result!.request)).toBe(false);+ });++ test("an http-only edit without a new password stays a reachability check older gateways understand", async () => {+ const result = await buildGatewayConnectionTest(PamAccountType.ClickHouse, connectionDetails, null, ORG_ID);++ expect(result?.request).toEqual({ mode: TestConnectionMode.Tcp });+ expect(testVerifiesCredential(result!.request)).toBe(false);+ });++ test("a supplied password is a real credential check", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.ClickHouse,+ { ...connectionDetails, nativePort: 9000 },+ { username: "default", password: "pw" },+ ORG_ID+ );++ expect(testVerifiesCredential(result!.request)).toBe(true);+ });});diff --git a/backend/src/ee/services/pam-account/pam-account-connection-test.ts b/backend/src/ee/services/pam-account/pam-account-connection-test.tsindex 0856a5d43a..3de9bc4770 100644--- a/backend/src/ee/services/pam-account/pam-account-connection-test.ts+++ b/backend/src/ee/services/pam-account/pam-account-connection-test.ts@@ -115,6 +115,16 @@ export type TestConnectionRequest =sslRejectUnauthorized?: boolean;sslCertificate?: string;}+ | {+ mode: TestConnectionMode.ClickHouse;+ probeOnly: true;+ database: string;+ httpPort?: number;+ nativePort?: number;+ sslEnabled?: boolean;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+ }| { mode: TestConnectionMode.Tcp };const SQL_DIALECTS = {@@ -126,6 +136,9 @@ const SQL_DIALECTS = {const tcp = (host: string, port: number) => ({ host, port, request: { mode: TestConnectionMode.Tcp } as const });+export const testVerifiesCredential = (request: TestConnectionRequest): boolean =>+ request.mode !== TestConnectionMode.Tcp && !("probeOnly" in request && request.probeOnly);+export const exceedsOraclePasswordLimit = (accountType: PamAccountType,credentials: Record<string, unknown> | null@@ -398,22 +411,30 @@ export const buildGatewayConnectionTest = async (sslCertificate?: string;};const c = creds as { username: string; password?: string } | null;- if (!c) return tcp(host, port);+ const details = {+ database: cd.database,+ httpPort: cd.port,+ nativePort: cd.nativePort,+ sslEnabled: cd.sslEnabled,+ sslRejectUnauthorized: cd.sslRejectUnauthorized,+ sslCertificate: cd.sslCertificate+ };+ const additionalPorts = [cd.port, cd.nativePort].filter((p): p is number => typeof p === "number");+ if (!c) {+ // Only a gateway with native support understands probeOnly, and a native port already requires one.+ if (cd.nativePort === undefined) return tcp(host, port);+ return {+ host,+ port,+ additionalPorts,+ request: { mode: TestConnectionMode.ClickHouse, probeOnly: true, ...details }+ };+ }return {host,port,- additionalPorts: [cd.port, cd.nativePort].filter((p): p is number => typeof p === "number"),- request: {- mode: TestConnectionMode.ClickHouse,- username: c.username,- password: c.password,- database: cd.database,- httpPort: cd.port,- nativePort: cd.nativePort,- sslEnabled: cd.sslEnabled,- sslRejectUnauthorized: cd.sslRejectUnauthorized,- sslCertificate: cd.sslCertificate- }+ additionalPorts,+ request: { mode: TestConnectionMode.ClickHouse, username: c.username, password: c.password, ...details }};}case PamAccountType.Windows:diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 2c01af08c9..edeac3dc3b 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -71,7 +71,7 @@ import { terminatePamSessions } from "../pam-session/pam-session-fns";import {buildGatewayConnectionTest,CLOUD_CONNECTION_VALIDATORS,- TestConnectionMode+ testVerifiesCredential} from "./pam-account-connection-test";import { TPamAccountDALFactory } from "./pam-account-dal";import {@@ -93,7 +93,8 @@ import {type TSshInternalMetadata,type TSupportedAccountType,validateConnectionDetails,- validateCredentials+ validateCredentials,+ webAccessUnavailableReason} from "./pam-account-schemas";import {TCreatePamAccountDTO,@@ -484,6 +485,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>settingsOverrides: account.settingsOverrides ?? null,connectionDetails,credentials,+ webAccessUnavailableReason: webAccessUnavailableReason(account.accountType as PamAccountType, connectionDetails),...computeAccessibility(account),isStale: account.isStale,createdAt: account.createdAt,@@ -657,7 +659,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>throw new BadRequestError({ message: `Connection test failed: ${result.errorMessage}` });}- return Boolean(result?.ok) && test.request.mode !== TestConnectionMode.Tcp;+ return Boolean(result?.ok) && testVerifiesCredential(test.request);};const create = async ({diff --git a/docs/documentation/platform/pam/accounts/clickhouse.mdx b/docs/documentation/platform/pam/accounts/clickhouse.mdxindex 2cd7da4fa9..59c899c9b9 100644--- a/docs/documentation/platform/pam/accounts/clickhouse.mdx+++ b/docs/documentation/platform/pam/accounts/clickhouse.mdx@@ -45,7 +45,7 @@ Either interface can be turned off on the server. Set whichever ports it serves| **Password** | The user's password. Leave blank for a user created with `no_password` |</Step><Step title="Save">- Select **Create**. Infisical signs in to ClickHouse through the gateway and confirms the credential works before saving the account. Each port you set is checked, and the error names the one that failed.+ Select **Create**. Infisical signs in to ClickHouse through the gateway and confirms the credential works before saving the account. Each port you set is checked, and the error names the one that failed. An edit that leaves the password blank can't sign in, so it checks only that each port answers as the right ClickHouse interface.</Step></Steps>@@ -124,7 +124,7 @@ On the HTTP interface, applying that policy means reading the statement first, sThe native protocol has no such limit. A statement arrives in its own packet, separate from any rows that follow, so it's always read in full and an insert's data never counts against the policy or fills the recording.<Note>- Over the native protocol, an `INSERT` that pushes rows from the client is read so that later statements on the same connection stay covered by the policy. A few column types can't be read yet, including `Map` with a non-`String` value, `Tuple`, `JSON` and `Nested`. Inserting into a table that has one of those columns is refused with a message naming the type. Reading those columns is unaffected, and so is inserting over the HTTP interface.+ Over the native protocol, an `INSERT` that pushes rows from the client is read so that later statements on the same connection stay covered by the policy. A few column types can't be read yet, including `Tuple`, `JSON`, `Nested`, `LowCardinality(Nullable(...))` and the geo types. Inserting into a table that has one of those columns is refused with a message naming the type. Reading those columns is unaffected, and so is inserting over the HTTP interface. A single block is also capped at 64 MB, so a client sending larger batches is asked to split them.</Note>## Servers with HTTP turned offdiff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.tsindex c2a57ad33e..33c07490b1 100644--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@ -225,6 +225,7 @@ export type TPamAccount = {// the latest discovery scan didn't find it. Informational only, nothing about the account is blocked.isStale: boolean;heartbeatStatus?: PamHeartbeatStatus | null;+ webAccessUnavailableReason?: string | null;createdAt: string;updatedAt: string;};diff --git a/frontend/src/pages/pam/components/accountSheetDetails.tsx b/frontend/src/pages/pam/components/accountSheetDetails.tsxindex 275b9870fc..02a062a00b 100644--- a/frontend/src/pages/pam/components/accountSheetDetails.tsx+++ b/frontend/src/pages/pam/components/accountSheetDetails.tsx@@ -79,11 +79,7 @@ export const useAccountSheetDetails = (account: TAccessiblePamAccount | null, is...fieldRows(typeMeta?.credentialFields, credentials)];- // Null until the account loads, so missing data doesn't grey out Web Access.- const webAccessUnavailableReason =- fullAccount && account.accountType === PamAccountType.ClickHouse && conn.port === undefined- ? "Requires ClickHouse's HTTP interface. Set an HTTP port on this account, or use the CLI."- : null;+ const webAccessUnavailableReason = fullAccount?.webAccessUnavailableReason ?? null;return { typeMeta, typeName, subtitle, metadata, hosts, webAccessUnavailableReason };};