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
feat(pam): restore Oracle Database account support
Carlos Monastyrskia0096bc6d53f
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-fns.ts b/backend/src/ee/services/gateway-v2/gateway-v2-fns.tsindex b7f1e3431a..f3fc665404 100644--- a/backend/src/ee/services/gateway-v2/gateway-v2-fns.ts+++ b/backend/src/ee/services/gateway-v2/gateway-v2-fns.ts@@ -1,5 +1,7 @@+import { BadRequestError } from "@app/lib/errors";import { GatewayProxyProtocol } from "@app/lib/gateway";import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";+import { callSqlRotateCredential, TSqlRpcResponse } from "@app/lib/gateway-v2/sql-rpc";import { callTestConnection, TestConnectionResponse } from "@app/lib/gateway-v2/test-connection-rpc";import { verifyHostInputValidity } from "../dynamic-secret/dynamic-secret-fns";@@ -38,3 +40,28 @@ export const testConnectionWithGateway = async (return null;}};++export const rotateSqlCredentialWithGateway = async (+ targetHost: string,+ targetPort: number,+ gatewayId: string,+ gatewayV2Service: TGatewayDep,+ request: Record<string, unknown>,+ timeoutMs: number+): Promise<TSqlRpcResponse> => {+ const [host] = await verifyHostInputValidity({ host: targetHost, isGateway: true, isDynamicSecret: false });++ const platform = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost: host,+ targetPort+ });+ if (!platform) {+ throw new BadRequestError({ message: "Unable to reach the gateway for this account" });+ }++ return withGatewayV2Proxy((proxyPort) => callSqlRotateCredential({ port: proxyPort, body: request, timeoutMs }), {+ protocol: GatewayProxyProtocol.Sql,+ ...platform+ });+};diff --git a/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.test.ts b/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.test.tsindex a20c8993e8..6360c32c82 100644--- a/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.test.ts+++ b/backend/src/ee/services/pam-account-heartbeat/pam-account-heartbeat-service.test.ts@@ -53,6 +53,7 @@ const buildService = ([PamAccountType.Postgres]: handler,[PamAccountType.MySQL]: handler,[PamAccountType.MsSQL]: handler,+ [PamAccountType.OracleDB]: handler,[PamAccountType.Windows]: handler,[PamAccountType.WindowsAd]: handler} as typeof PAM_ROTATION_FACTORY_MAP;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 2d7eb2510c..83c4319287 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@@ -17,6 +17,8 @@ import { checkAccountAccess, TActorContext } from "../pam/pam-permission";import {buildGatewayConnectionTest,CLOUD_CONNECTION_VALIDATORS,+ exceedsOraclePasswordLimit,+ ORACLE_MAX_PASSWORD_LENGTH,TestConnectionMode} from "../pam-account/pam-account-connection-test";import { TPamAccountDALFactory, TPamAccountDetail } from "../pam-account/pam-account-dal";@@ -215,8 +217,15 @@ export const pamAccountHeartbeatServiceFactory = ({const probeCredentials =accountType === PamAccountType.SSH ? await mintEphemeralSshCertificate(account, credentials) : credentials;+ if (exceedsOraclePasswordLimit(accountType, credentials)) {+ return {+ status: PamHeartbeatStatus.CannotCheck,+ message: `This account's password is longer than ${ORACLE_MAX_PASSWORD_LENGTH} characters, so this credential was not checked`+ };+ }+const test = await buildGatewayConnectionTest(accountType, connectionDetails, probeCredentials, orgId, {- allowWindowsAuthSql: true+ allowNewerGatewayTests: true});if (!test) {return { status: PamHeartbeatStatus.Unknown, message: "This account type cannot be checked yet" };diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.tsindex 0533ad216a..10cb264a20 100644--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts@@ -60,6 +60,7 @@ const buildService = ([PamAccountType.Postgres]: handler,[PamAccountType.MySQL]: handler,[PamAccountType.MsSQL]: handler,+ [PamAccountType.OracleDB]: handler,[PamAccountType.Windows]: handler,[PamAccountType.WindowsAd]: handler};@@ -315,4 +316,170 @@ describe("rotateScheduledAccount recovery probe", () => {expect(testCredential).not.toHaveBeenCalled();expect(applyPasswordChange).not.toHaveBeenCalled();});++ test("caps the generated Oracle password so the credential stays verifiable", async () => {+ const account = { ...buildAccount(), accountType: PamAccountType.OracleDB };+ const { service, applyPasswordChange } = buildService((pw) => pw === CURRENT_PASSWORD, { account });++ await service.rotateScheduledAccount("acc-1");++ expect(applyPasswordChange).toHaveBeenCalled();+ const { newPassword } = applyPasswordChange.mock.calls[0][0] as { newPassword: string };+ expect(newPassword.length).toBe(30);+ });++ test("caps an Oracle password whose required minimums sum above the ceiling", async () => {+ const account = {+ ...buildAccount(),+ accountType: PamAccountType.OracleDB,+ templateSettings: {+ rotation: { enabled: true, intervalSeconds: 3600 as number | null },+ passwordRequirements: {+ length: 100,+ required: { lowercase: 0, uppercase: 40, digits: 40, symbols: 20 },+ allowedSymbols: "-_.~!*"+ }+ }+ };+ const { service, applyPasswordChange } = buildService((pw) => pw === CURRENT_PASSWORD, { account });++ await service.rotateScheduledAccount("acc-1");++ const { newPassword } = applyPasswordChange.mock.calls[0][0] as { newPassword: string };+ expect(newPassword.length).toBe(30);+ });++ test("keeps every character class the template asked for when it caps", async () => {+ const account = {+ ...buildAccount(),+ accountType: PamAccountType.OracleDB,+ templateSettings: {+ rotation: { enabled: true, intervalSeconds: 3600 as number | null },+ passwordRequirements: {+ length: 80,+ required: { lowercase: 20, uppercase: 20, digits: 20, symbols: 20 },+ allowedSymbols: "-_.~!*"+ }+ }+ };+ const { service, applyPasswordChange } = buildService((pw) => pw === CURRENT_PASSWORD, { account });++ await service.rotateScheduledAccount("acc-1");++ const { newPassword } = applyPasswordChange.mock.calls[0][0] as { newPassword: string };+ expect(newPassword.length).toBe(30);+ expect(newPassword).toMatch(/[a-z]/);+ expect(newPassword).toMatch(/[A-Z]/);+ expect(newPassword).toMatch(/[0-9]/);+ expect(newPassword).toMatch(/[-_.~!*]/);+ });++ test("leaves the generated password length alone for the other SQL dialects", async () => {+ const { service, applyPasswordChange } = buildService((pw) => pw === CURRENT_PASSWORD);++ await service.rotateScheduledAccount("acc-1");++ const { newPassword } = applyPasswordChange.mock.calls[0][0] as { newPassword: string };+ expect(newPassword.length).toBe(48);+ });++ const buildOracleDelegatedPair = (rotatorService: string) => {+ const account = {+ ...buildAccount(),+ accountType: PamAccountType.OracleDB,+ rotationAccountId: "rot-1",+ encryptedConnectionDetails: blobOf({+ host: "oracle.internal",+ port: 1521,+ database: "PDB1",+ sslEnabled: false,+ sslRejectUnauthorized: false+ })+ };+ const rotator = {+ id: "rot-1",+ projectId: "proj-1",+ accountType: PamAccountType.OracleDB,+ encryptedCredentials: blobOf({ username: "rotuser", password: "rot-pw" }),+ encryptedConnectionDetails: blobOf({+ host: "oracle.internal",+ port: 1521,+ database: rotatorService,+ sslEnabled: false,+ sslRejectUnauthorized: false+ }),+ gatewayId: null,+ gatewayPoolId: null,+ templateGatewayId: null,+ templateGatewayPoolId: null+ };+ return { account, rotator };+ };++ test("aborts an Oracle delegated rotation when the rotator reaches a different service name", async () => {+ const { account, rotator } = buildOracleDelegatedPair("PDB2");+ const { service, applyPasswordChange } = buildService(() => true, { account, rotator });++ const result = await service.rotateScheduledAccount("acc-1");++ expect(result?.rotationStatus).toBe(ROTATION_STATUS.Failed);+ expect(result?.message).toContain("service name");+ expect(applyPasswordChange).not.toHaveBeenCalled();+ });++ test("treats a service name that differs only in case as the same resource", async () => {+ const { account, rotator } = buildOracleDelegatedPair("pdb1");+ const { service } = buildService((pw) => pw === CURRENT_PASSWORD, { account, rotator });++ const result = await service.rotateScheduledAccount("acc-1");++ expect(result?.message ?? "").not.toContain("service name");+ });++ test("allows an Oracle delegated rotation within the same service name", async () => {+ const { account, rotator } = buildOracleDelegatedPair("PDB1");+ const { service } = buildService(() => true, { account, rotator });++ const result = await service.rotateScheduledAccount("acc-1");++ expect(result?.rotationStatus).not.toBe(ROTATION_STATUS.Failed);+ expect(result?.message ?? "").not.toContain("same resource");+ });++ test("keeps Postgres delegated rotation working across different databases on one server", async () => {+ const account = {+ ...buildAccount(),+ rotationAccountId: "rot-1",+ encryptedConnectionDetails: blobOf({ ...connectionDetails, database: "app" })+ };+ const rotator = {+ id: "rot-1",+ projectId: "proj-1",+ accountType: PamAccountType.Postgres,+ encryptedCredentials: blobOf({ username: "rotuser", password: "rot-pw" }),+ encryptedConnectionDetails: blobOf({ ...connectionDetails, database: "rotdb" }),+ gatewayId: null,+ gatewayPoolId: null,+ templateGatewayId: null,+ templateGatewayPoolId: null+ };+ const { service } = buildService(() => true, { account, rotator });++ const result = await service.rotateScheduledAccount("acc-1");++ expect(result?.rotationStatus).not.toBe(ROTATION_STATUS.Failed);+ expect(result?.message ?? "").not.toContain("same resource");+ });+});++describe("sqlRotationHandler.validateTarget", () => {+ test("allows an Oracle account, whose SSL settings are handled by the gateway", () => {+ const validate = PAM_ROTATION_FACTORY_MAP[PamAccountType.OracleDB].validateTarget;+ expect(() => validate({ accountType: PamAccountType.OracleDB })).not.toThrow();+ });++ test("still refuses MSSQL Windows authentication", () => {+ const validate = PAM_ROTATION_FACTORY_MAP[PamAccountType.MsSQL].validateTarget;+ expect(() => validate({ accountType: PamAccountType.MsSQL, authMethod: "ntlm" })).toThrow(/SQL Server/);+ });});diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.tsindex e85141bcb2..eed39c5b9c 100644--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts@@ -5,7 +5,7 @@ import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gatewaimport { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import { ResourcePermissionPamResourceActions } from "@app/ee/services/permission/resource-permission";-import { generatePassword } from "@app/ee/services/secret-rotation-v2/shared/utils";+import { DEFAULT_PASSWORD_REQUIREMENTS, generatePassword } from "@app/ee/services/secret-rotation-v2/shared/utils";import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { WinRmRpcEndpoint } from "@app/lib/gateway-v2/winrm-rpc";@@ -23,6 +23,7 @@ import {TActorContext,verifyProductMembership} from "../pam/pam-permission";+import { ORACLE_MAX_PASSWORD_LENGTH } from "../pam-account/pam-account-connection-test";import { TPamAccountDALFactory, TPamAccountDetail } from "../pam-account/pam-account-dal";import { validateConnectionDetails, validateCredentials } from "../pam-account/pam-account-schemas";import { computeNextHeartbeatAt, isHeartbeatScheduled } from "../pam-account-heartbeat/pam-heartbeat-fns";@@ -57,6 +58,8 @@ import {winrmTransportFromConn} from "./pam-rotation-handlers";+type TGeneratedPasswordRequirements = Parameters<typeof generatePassword>[0];+export const ROTATION_STATUS = { Success: "success", Failed: "failed" } as const;const ROTATION_IN_PROGRESS_MESSAGE = "A rotation is already in progress for this account";@@ -154,6 +157,25 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServicconst getRotationConfig = (templateSettings: unknown) =>PamTemplateSettingsSchema.safeParse(templateSettings).data?.rotation;+ const capRequirementsForAccountType = (+ accountType: PamAccountType,+ requirements: TGeneratedPasswordRequirements+ ): TGeneratedPasswordRequirements => {+ if (accountType !== PamAccountType.OracleDB) return requirements;+ const effective = requirements ?? DEFAULT_PASSWORD_REQUIREMENTS;+ const requiredTotal = Object.values(effective.required).reduce((sum, count) => sum + count, 0);+ if (effective.length <= ORACLE_MAX_PASSWORD_LENGTH && requiredTotal <= ORACLE_MAX_PASSWORD_LENGTH) {+ return requirements;+ }+ return {+ ...effective,+ length: Math.min(effective.length, ORACLE_MAX_PASSWORD_LENGTH),+ required: Object.fromEntries(+ Object.entries(effective.required).map(([type, count]) => [type, count > 0 ? 1 : 0])+ ) as typeof effective.required+ };+ };+const getPasswordRequirements = (templateSettings: unknown) =>PamTemplateSettingsSchema.safeParse(templateSettings).data?.passwordRequirements;@@ -302,7 +324,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic};// A delegated rotator must sit on the same resource as its target so its credential can reach it: same- // host for SQL / local Windows, same domain controller for Windows AD.+ // host for SQL / local Windows, same domain controller for Windows AD. Oracle users live in a PDB rather+ // than the instance, so a rotator reaching a different service name cannot see the target user.const isSameResource = (accountType: PamAccountType,a: Record<string, unknown>,@@ -310,6 +333,13 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic): boolean => {if (accountType === PamAccountType.WindowsAd) return a.dcAddress === b.dcAddress && a.domain === b.domain;if (isWindowsRotatableType(accountType)) return a.host === b.host;+ if (accountType === PamAccountType.OracleDB) {+ return (+ a.host === b.host &&+ a.port === b.port &&+ (a.database as string | undefined)?.toLowerCase() === (b.database as string | undefined)?.toLowerCase()+ );+ }return a.host === b.host && a.port === b.port;};@@ -322,11 +352,13 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServiclet detail = "on the same resource (host and port) as";if (accountType === PamAccountType.WindowsAd) detail = "in the same domain as";else if (isWindowsRotatableType(accountType)) detail = "on the same host as";+ else if (accountType === PamAccountType.OracleDB) detail = "on the same resource (host, port and service name) as";throw new BadRequestError({ message: `Rotation account is no longer ${detail} this account` });};// Stable key for the identity an account authenticates as, to detect two PAM objects on the same credential:- // domain accounts on domain, local Windows on host, SQL on host+port, all on the bare name. Null if not rotatable.+ // domain accounts on domain, local Windows on host, SQL on host+port (plus service name for Oracle), all on+ // the bare name. Null if not rotatable.const identityKey = (accountType: PamAccountType, conn: Record<string, unknown>, username: string): string | null => {const user = toBareAccountName(username).toLowerCase();if (accountType === PamAccountType.WindowsAd) {@@ -339,7 +371,12 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic}if (isSqlRotatableType(accountType)) {const host = (conn.host as string | undefined)?.toLowerCase();- return host ? `sql|${host}|${String(conn.port)}|${user}` : null;+ if (!host) return null;+ if (accountType === PamAccountType.OracleDB) {+ const service = (conn.database as string | undefined)?.toLowerCase();+ return service ? `sql|${host}|${String(conn.port)}|${service}|${user}` : null;+ }+ return `sql|${host}|${String(conn.port)}|${user}`;}return null;};@@ -539,12 +576,12 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServicconst targetUsername = targetCredentials.username;const handler = rotationHandlers[accountType];- handler.validateTarget({ accountType, authMethod: targetCredentials.authMethod });-const connectionDetails = resolveConnectionDetails(accountType,await decrypt(projectId, account.encryptedConnectionDetails));++ handler.validateTarget({ accountType, authMethod: targetCredentials.authMethod });const gatewayId = account.gatewayId ?? account.templateGatewayId;const gatewayPoolId = account.gatewayPoolId ?? account.templateGatewayPoolId;const now = new Date();@@ -558,6 +595,7 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServicgatewayId: rotatorGatewayId,gatewayPoolId: rotatorGatewayPoolId} = await resolveRotator(account, targetCredentials, connectionDetails, { gatewayId, gatewayPoolId });+ handler.validateRotatorCredential?.({ accountType, password: auth.password });if (isDelegated) assertRotatorSameResource(accountType, rotatorConnectionDetails, connectionDetails);// A delegated local account can't be logged in as to verify, so validate via the admin rotator instead.const verifyVia = isDelegated && accountType === PamAccountType.Windows ? auth : undefined;@@ -633,7 +671,7 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic}}- const requirements = getPasswordRequirements(account.templateSettings);+ const requirements = capRequirementsForAccountType(accountType, getPasswordRequirements(account.templateSettings));const newPassword = generatePassword(requirements);const encryptedPending = await encrypt(projectId, { ...targetCredentials, password: newPassword });diff --git a/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.test.ts b/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.test.tsindex 1994dd83f5..ec70ab1793 100644--- a/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.test.ts+++ b/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.test.ts@@ -14,10 +14,11 @@ vi.mock("@app/lib/logger", () => ({}));describe("isRotatableAccountType", () => {- test("accepts the three SQL types", () => {+ test("accepts the SQL types", () => {expect(isRotatableAccountType(PamAccountType.Postgres)).toBe(true);expect(isRotatableAccountType(PamAccountType.MySQL)).toBe(true);expect(isRotatableAccountType(PamAccountType.MsSQL)).toBe(true);+ expect(isRotatableAccountType(PamAccountType.OracleDB)).toBe(true);});test("accepts Windows local and domain accounts", () => {diff --git a/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.ts b/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.tsindex 6d255ef343..d8dd3e2a49 100644--- a/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.ts+++ b/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.ts@@ -71,11 +71,12 @@ export const withGatewayRetry = async (// PamAccountType -> AppConnection, so we can reuse the per-dialect ALTER statement map keyed by AppConnection.export const PAM_ROTATION_APP_MAP: Record<TSqlRotatableType,- AppConnection.Postgres | AppConnection.MySql | AppConnection.MsSql+ AppConnection.Postgres | AppConnection.MySql | AppConnection.MsSql | AppConnection.OracleDB> = {[PamAccountType.Postgres]: AppConnection.Postgres,[PamAccountType.MySQL]: AppConnection.MySql,- [PamAccountType.MsSQL]: AppConnection.MsSql+ [PamAccountType.MsSQL]: AppConnection.MsSql,+ [PamAccountType.OracleDB]: AppConnection.OracleDB};export enum PamRotationReadinessIssue {diff --git a/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.test.ts b/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.test.tsnew file mode 100644index 0000000000..8dc2003156--- /dev/null+++ b/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.test.ts@@ -0,0 +1,62 @@+import { beforeEach, describe, expect, test, vi } from "vitest";++import { PamAccountType } from "../pam/pam-enums";++const testConnectionWithGateway = vi.fn();++vi.mock("@app/ee/services/gateway-v2/gateway-v2-fns", () => ({+ testConnectionWithGateway: (...args: unknown[]) => testConnectionWithGateway(...args) as unknown,+ rotateSqlCredentialWithGateway: vi.fn()+}));++vi.mock("@app/lib/logger", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }+}));++// eslint-disable-next-line import/first+import { PAM_ROTATION_FACTORY_MAP } from "./pam-rotation-handlers";++describe("Oracle testCredential distinguishes a rejected credential from an unreachable target", () => {+ const { testCredential } = PAM_ROTATION_FACTORY_MAP[PamAccountType.OracleDB];++ const invoke = () =>+ testCredential(+ {+ accountType: PamAccountType.OracleDB,+ connectionDetails: { host: "db.example.com", port: 2484, database: "FREEPDB1", sslEnabled: true },+ auth: { username: "PAMROT", password: "short-pw" },+ gatewayId: "11111111-1111-1111-1111-111111111111"+ } as never,+ {+ gatewayV2Service: {},+ gatewayPoolService: { resolveEffectiveGatewayId: vi.fn().mockResolvedValue("gw") }+ } as never+ );++ beforeEach(() => testConnectionWithGateway.mockReset());++ test("a null result (gateway unreachable) throws instead of returning false", async () => {+ testConnectionWithGateway.mockResolvedValue(null);+ await expect(invoke()).rejects.toThrow(/could not reach the target/i);+ });++ test("a transport-kind failure throws instead of returning false", async () => {+ testConnectionWithGateway.mockResolvedValue({+ ok: false,+ status: 502,+ errorMessage: "dial tcp",+ kind: "transport"+ });+ await expect(invoke()).rejects.toThrow(/could not reach the target/i);+ });++ test("an auth-kind failure returns false", async () => {+ testConnectionWithGateway.mockResolvedValue({ ok: false, status: 502, errorMessage: "ORA-01017", kind: "auth" });+ await expect(invoke()).resolves.toBe(false);+ });++ test("a successful probe returns true", async () => {+ testConnectionWithGateway.mockResolvedValue({ ok: true, status: 200 });+ await expect(invoke()).resolves.toBe(true);+ });+});diff --git a/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.ts b/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.tsindex 59d9caeca8..68abc66eae 100644--- a/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.ts+++ b/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.ts@@ -1,3 +1,4 @@+import { rotateSqlCredentialWithGateway, testConnectionWithGateway } from "@app/ee/services/gateway-v2/gateway-v2-fns";import { BadRequestError } from "@app/lib/errors";import { WinRmRpcEndpoint } from "@app/lib/gateway-v2/winrm-rpc";import {@@ -7,6 +8,7 @@ import {} from "@app/services/app-connection/shared/sql";import { PamAccountType, PamPostgresAuthMethod } from "../pam/pam-enums";+import { ORACLE_MAX_PASSWORD_LENGTH } from "../pam-account/pam-account-connection-test";import { TWindowsAdConnectionDetails, TWindowsConnectionDetails } from "../pam-account/pam-account-schemas";import { DEFAULT_WINRM_PORT, ldapBindCheckViaGateway, winrmRpcWithGateway } from "../pam-discovery/pam-discovery-fns";import {@@ -49,13 +51,125 @@ type TTestCredentialInput = {export type TPamRotationHandler = {validateTarget: (input: { accountType: TRotatableType; authMethod?: string }) => void;+ validateRotatorCredential?: (input: { accountType: TRotatableType; password?: string }) => void;applyPasswordChange: (input: TApplyPasswordChangeInput, deps: TPamRotationGatewayDeps) => Promise<void>;// Returns whether the credential authenticates. THROWS only when verification can't complete (transient// transport error); callers treat a throw as inconclusive and defer, never as a wrong password.testCredential: (input: TTestCredentialInput, deps: TPamRotationGatewayDeps) => Promise<boolean>;};+const ORACLE_ROTATE_TIMEOUT_MS = 30_000;++const resolveRotationGatewayId = async (+ deps: TPamRotationGatewayDeps,+ gatewayId?: string | null,+ gatewayPoolId?: string | null+): Promise<string> => {+ const resolved = gatewayPoolId+ ? await deps.gatewayPoolService.resolveEffectiveGatewayId({ gatewayId, gatewayPoolId })+ : gatewayId;+ if (!resolved) throw new BadRequestError({ message: "No healthy gateway is available to rotate this account" });+ return resolved;+};++const isGatewayProtocolUnsupported = (err: unknown) =>+ err instanceof Error && /no application protocol|alert number 120/i.test(err.message);++const assertOracleCredentialIsUsable = (password: string) => {+ if (password.length > ORACLE_MAX_PASSWORD_LENGTH) {+ throw new BadRequestError({+ message: `Oracle credentials longer than ${ORACLE_MAX_PASSWORD_LENGTH} characters cannot be used to rotate. Shorten the rotation account's password and try again.`+ });+ }+};++const ORACLE_GATEWAY_TOO_OLD =+ "This account's gateway does not support Oracle credential rotation. Update the gateway to v0.43.130 or later.";++const oracleGatewayRequest = (+ connectionDetails: TPamSqlConnectionDetails,+ auth: { username: string; password: string }+) => ({+ dialect: "oracle",+ username: auth.username,+ password: auth.password,+ database: connectionDetails.database,+ sslEnabled: connectionDetails.sslEnabled,+ sslRejectUnauthorized: connectionDetails.sslRejectUnauthorized,+ sslCertificate: connectionDetails.sslCertificate+});++const verifyOracleViaGateway = async (+ input: {+ connectionDetails: TPamSqlConnectionDetails;+ auth: { username: string; password: string };+ gatewayId?: string | null;+ gatewayPoolId?: string | null;+ },+ deps: TPamRotationGatewayDeps+): Promise<boolean> => {+ const { connectionDetails, auth } = input;+ const gatewayId = await resolveRotationGatewayId(deps, input.gatewayId, input.gatewayPoolId);+ const result = await testConnectionWithGateway(+ connectionDetails.host,+ connectionDetails.port,+ gatewayId,+ deps.gatewayV2Service,+ { mode: "sql", ...oracleGatewayRequest(connectionDetails, auth) },+ ORACLE_ROTATE_TIMEOUT_MS+ );++ if (!result) {+ throw new Error("Could not reach the target through the gateway to verify its credentials");+ }+ if (result.ok) return true;+ if (result.kind === "transport") {+ throw new Error(`Could not reach the target through the gateway to verify its credentials: ${result.errorMessage}`);+ }+ return false;+};++const rotateOracleViaGateway = async (+ input: {+ connectionDetails: TPamSqlConnectionDetails;+ auth: { username: string; password: string };+ targetUsername: string;+ newPassword: string;+ gatewayId?: string | null;+ gatewayPoolId?: string | null;+ },+ deps: TPamRotationGatewayDeps+) => {+ const { connectionDetails, auth, targetUsername, newPassword } = input;+ const gatewayId = await resolveRotationGatewayId(deps, input.gatewayId, input.gatewayPoolId);++ let result;+ try {+ result = await rotateSqlCredentialWithGateway(+ connectionDetails.host,+ connectionDetails.port,+ gatewayId,+ deps.gatewayV2Service,+ { ...oracleGatewayRequest(connectionDetails, auth), targetUsername, newPassword },+ ORACLE_ROTATE_TIMEOUT_MS+ );+ } catch (err) {+ if (isGatewayProtocolUnsupported(err)) {+ throw new BadRequestError({ message: ORACLE_GATEWAY_TOO_OLD });+ }+ throw new Error(redactRotationError(err, [newPassword, auth.password]));+ }++ if (!result.ok) {+ throw new Error(redactRotationError(new Error(result.errorMessage), [newPassword, auth.password]));+ }+};+const sqlRotationHandler: TPamRotationHandler = {+ validateRotatorCredential: ({ accountType, password }) => {+ if (accountType === PamAccountType.OracleDB && password) assertOracleCredentialIsUsable(password);+ },+validateTarget: ({ accountType, authMethod }) => {// MSSQL Windows-auth (ntlm/kerberos) logins have no SQL-managed password to change, so only sql-login rotates.if (accountType === PamAccountType.MsSQL && authMethod !== "sql-login") {@@ -72,6 +186,15 @@ const sqlRotationHandler: TPamRotationHandler = {applyPasswordChange: async (input, deps) => {const { accountType, auth, targetUsername, newPassword, gatewayId, gatewayPoolId } = input;const connectionDetails = input.connectionDetails as TPamSqlConnectionDetails;++ if (accountType === PamAccountType.OracleDB) {+ await rotateOracleViaGateway(+ { connectionDetails, auth, targetUsername, newPassword, gatewayId, gatewayPoolId },+ deps+ );+ return;+ }+// Strip the PlanetScale `<user>.<branch>` suffix so the ALTER targets the real role.const roleUsername = getRoleUsernameForHost(targetUsername, connectionDetails.host);const [statement, bindings] = SQL_CONNECTION_ALTER_LOGIN_STATEMENT[@@ -100,6 +223,11 @@ const sqlRotationHandler: TPamRotationHandler = {testCredential: async (input, deps) => {const { accountType, auth, gatewayId, gatewayPoolId } = input;const connectionDetails = input.connectionDetails as TPamSqlConnectionDetails;++ if (accountType === PamAccountType.OracleDB) {+ return verifyOracleViaGateway({ connectionDetails, auth, gatewayId, gatewayPoolId }, deps);+ }+try {await withPamSqlClient({ accountType: accountType as TSqlRotatableType, connectionDetails, auth, gatewayId, gatewayPoolId },@@ -146,18 +274,6 @@ const winrmRotationTargetHost = (accountType: TRotatableType, connectionDetails:return conn.host;};-const resolveRotationGatewayId = async (- deps: TPamRotationGatewayDeps,- gatewayId?: string | null,- gatewayPoolId?: string | null-): Promise<string> => {- const resolved = gatewayPoolId- ? await deps.gatewayPoolService.resolveEffectiveGatewayId({ gatewayId, gatewayPoolId })- : gatewayId;- if (!resolved) throw new BadRequestError({ message: "No healthy gateway available for Windows rotation" });- return resolved;-};-// Set-ADAccountPassword -Identity and Set-LocalUser -Name want a bare sAMAccountName, not DOMAIN\user or a// UPN (both accepted by the account schema), so strip any domain qualifier before building the rotate script.// The identity WinRM connects AS must be domain-qualified for a domain rotator: NTLM resolves a bare name@@ -280,6 +396,7 @@ export const PAM_ROTATION_FACTORY_MAP: Record<TRotatableType, TPamRotationHandle[PamAccountType.Postgres]: sqlRotationHandler,[PamAccountType.MySQL]: sqlRotationHandler,[PamAccountType.MsSQL]: sqlRotationHandler,+ [PamAccountType.OracleDB]: sqlRotationHandler,[PamAccountType.Windows]: windowsRotationHandler,[PamAccountType.WindowsAd]: windowsRotationHandler};diff --git a/backend/src/ee/services/pam-account-template/pam-account-template-service.ts b/backend/src/ee/services/pam-account-template/pam-account-template-service.tsindex 0489fd7af5..e78a4c9d7f 100644--- a/backend/src/ee/services/pam-account-template/pam-account-template-service.ts+++ b/backend/src/ee/services/pam-account-template/pam-account-template-service.ts@@ -12,6 +12,7 @@ import {validateRecordingConnection,validateRecordingS3Config} from "../pam/pam-validators";+import { ORACLE_MAX_PASSWORD_LENGTH } from "../pam-account/pam-account-connection-test";import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";import { ACCOUNT_TYPE_CONFIGS } from "../pam-account/pam-account-schemas";import { isRotatableAccountType, ROTATABLE_ACCOUNT_TYPES } from "../pam-account-rotation/pam-rotation-fns";@@ -81,6 +82,16 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicthrow new BadRequestError({ message: `Allowed symbols may only include: ${SAFE_PASSWORD_SYMBOLS}` });}}+ const requestedLength = settings.passwordRequirements?.length;+ if (+ accountType === PamAccountType.OracleDB &&+ requestedLength !== undefined &&+ requestedLength > ORACLE_MAX_PASSWORD_LENGTH+ ) {+ throw new BadRequestError({+ message: `Oracle passwords are limited to ${ORACLE_MAX_PASSWORD_LENGTH} characters, so a template cannot request a longer one`+ });+ }};const verifyProductAdmin = async (projectId: string, ctx: TActorContext) => {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 be52e69166..b1836ee6ea 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@@ -1,7 +1,11 @@import { describe, expect, test } from "vitest";import { PamAccountType, PamSshAuthMethod } from "../pam/pam-enums";-import { buildGatewayConnectionTest, TestConnectionMode } from "./pam-account-connection-test";+import {+ buildGatewayConnectionTest,+ ORACLE_MAX_PASSWORD_LENGTH,+ TestConnectionMode+} from "./pam-account-connection-test";const ORG_ID = "11111111-1111-1111-1111-111111111111";@@ -20,7 +24,7 @@ describe("buildGatewayConnectionTest: MSSQL Windows authentication", () => {connectionDetails,{ authMethod: "ntlm", username: "svc_app", password: "pw", domain: "CORP" },ORG_ID,- { allowWindowsAuthSql: true }+ { allowNewerGatewayTests: true });expect(result?.request.mode).toBe(TestConnectionMode.SQL);@@ -40,7 +44,7 @@ describe("buildGatewayConnectionTest: MSSQL Windows authentication", () => {spn: "MSSQLSvc/sql.corp.example.com:1433"},ORG_ID,- { allowWindowsAuthSql: true }+ { allowNewerGatewayTests: true });expect(result?.request.mode).toBe(TestConnectionMode.SQL);@@ -128,3 +132,113 @@ describe("buildGatewayConnectionTest: SSH certificate authentication", () => {expect(result?.request).toMatchObject({ mode: TestConnectionMode.SSH, password: "pw" });});});++describe("buildGatewayConnectionTest: Oracle", () => {+ const connectionDetails = {+ host: "oracle.corp.example.com",+ port: 1521,+ database: "FREEPDB1",+ sslEnabled: false,+ sslRejectUnauthorized: true+ };++ test("authenticates against the service name using the oracle dialect", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.OracleDB,+ connectionDetails,+ { username: "system", password: "pw" },+ ORG_ID,+ { allowNewerGatewayTests: true }+ );++ expect(result).toMatchObject({ host: "oracle.corp.example.com", port: 1521 });+ expect(result?.request).toMatchObject({+ mode: TestConnectionMode.SQL,+ dialect: "oracle",+ username: "system",+ password: "pw",+ database: "FREEPDB1"+ });+ });++ test("carries the SSL settings the gateway needs to pin the CA", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.OracleDB,+ { ...connectionDetails, port: 2484, sslEnabled: true, sslCertificate: "-----BEGIN CERTIFICATE-----" },+ { username: "system", password: "pw" },+ ORG_ID,+ { allowNewerGatewayTests: true }+ );++ expect(result?.request).toMatchObject({+ sslEnabled: true,+ sslRejectUnauthorized: true,+ sslCertificate: "-----BEGIN CERTIFICATE-----"+ });+ });++ test("sends no Windows auth fields, which belong to MSSQL only", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.OracleDB,+ connectionDetails,+ { username: "system", password: "pw" },+ ORG_ID,+ { allowNewerGatewayTests: true }+ );++ expect(result?.request).not.toHaveProperty("authMethod");+ expect(result?.request).not.toHaveProperty("domain");+ expect(result?.request).not.toHaveProperty("spn");+ });++ test("an account with no credential falls back to a reachability check", async () => {+ const result = await buildGatewayConnectionTest(PamAccountType.OracleDB, connectionDetails, null, ORG_ID);+ expect(result?.request.mode).toBe(TestConnectionMode.Tcp);+ });++ test("callers that omit the opt keep a reachability check", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.OracleDB,+ connectionDetails,+ { username: "system", password: "pw" },+ ORG_ID+ );++ expect(result?.request.mode).toBe(TestConnectionMode.Tcp);+ });++ test("a password over the probe limit degrades to a reachability check", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.OracleDB,+ connectionDetails,+ { username: "system", password: "a".repeat(ORACLE_MAX_PASSWORD_LENGTH + 1) },+ ORG_ID,+ { allowNewerGatewayTests: true }+ );++ expect(result?.request.mode).toBe(TestConnectionMode.Tcp);+ });++ test("a password exactly at the probe limit still authenticates", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.OracleDB,+ connectionDetails,+ { username: "system", password: "a".repeat(ORACLE_MAX_PASSWORD_LENGTH) },+ ORG_ID,+ { allowNewerGatewayTests: true }+ );++ expect(result?.request).toMatchObject({ mode: TestConnectionMode.SQL, dialect: "oracle" });+ });++ test("the limit is Oracle-only and does not touch the other dialects", async () => {+ const result = await buildGatewayConnectionTest(+ PamAccountType.Postgres,+ { ...connectionDetails, port: 5432 },+ { authMethod: "password", username: "postgres", password: "a".repeat(64) },+ ORG_ID+ );++ expect(result?.request).toMatchObject({ mode: TestConnectionMode.SQL, dialect: "postgres" });+ });+});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 6667443f6b..1723ad535d 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@@ -24,7 +24,7 @@ export enum TestConnectionMode {export type TestConnectionRequest =| {mode: TestConnectionMode.SQL;- dialect: "postgres" | "mysql" | "mssql";+ dialect: "postgres" | "mysql" | "mssql" | "oracle";username: string;password?: string;database: string;@@ -85,19 +85,30 @@ export type TestConnectionRequest =const SQL_DIALECTS = {[PamAccountType.Postgres]: "postgres",[PamAccountType.MySQL]: "mysql",- [PamAccountType.MsSQL]: "mssql"+ [PamAccountType.MsSQL]: "mssql",+ [PamAccountType.OracleDB]: "oracle"} as const;const tcp = (host: string, port: number) => ({ host, port, request: { mode: TestConnectionMode.Tcp } as const });+export const ORACLE_MAX_PASSWORD_LENGTH = 30;++export const exceedsOraclePasswordLimit = (+ accountType: PamAccountType,+ credentials: Record<string, unknown> | null+): boolean =>+ accountType === PamAccountType.OracleDB &&+ typeof credentials?.password === "string" &&+ credentials.password.length > ORACLE_MAX_PASSWORD_LENGTH;+// resolves the gateway target and the per-type auth requestexport const buildGatewayConnectionTest = async (accountType: PamAccountType,connectionDetails: Record<string, unknown>,credentials: Record<string, unknown> | null,orgId: string,- // Off for account create and update, which must not fail against a gateway predating the proxy handshake.- opts?: { allowWindowsAuthSql?: boolean }+ // Off for account create and update, which must not fail against a gateway predating the test they need.+ opts?: { allowNewerGatewayTests?: boolean }): Promise<{ host: string; port: number; request: TestConnectionRequest } | null> => {const creds = credentials && isCredentialConfigured(accountType, credentials) ? credentials : null;@@ -114,7 +125,8 @@ export const buildGatewayConnectionTest = async (switch (accountType) {case PamAccountType.Postgres:case PamAccountType.MySQL:- case PamAccountType.MsSQL: {+ case PamAccountType.MsSQL:+ case PamAccountType.OracleDB: {const cd = connectionDetails as {database: string;sslEnabled?: boolean;@@ -133,9 +145,11 @@ export const buildGatewayConnectionTest = async (spn?: string;} | null;if (!c) return tcp(host, port);- if (accountType === PamAccountType.MsSQL && c.authMethod !== "sql-login" && !opts?.allowWindowsAuthSql) {- return tcp(host, port);- }+ const needsNewerGateway =+ (accountType === PamAccountType.MsSQL && c.authMethod !== "sql-login") ||+ accountType === PamAccountType.OracleDB;+ if (needsNewerGateway && !opts?.allowNewerGatewayTests) return tcp(host, port);+ if (exceedsOraclePasswordLimit(accountType, c)) return tcp(host, port);// An IAM login's password is a token Infisical mints per connection, so the test mints its ownconst password =c.authMethod === PamPostgresAuthMethod.AwsIamdiff --git a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts b/backend/src/ee/services/pam-account/pam-account-schemas.test.tsindex 692b8d9cc1..5e7a4a008a 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.test.ts@@ -140,6 +140,30 @@ describe("buildPamAccountTypeMetadata", () => {});});+ test("derives Oracle connection and credential fields, labelling the service name", () => {+ const oracle = byType.get(PamAccountType.OracleDB);+ expect(oracle).toBeDefined();+ expect(oracle?.name).toBe("Oracle Database");+ expect(oracle?.supportsWebAccess).toBe(false);++ expect(oracle?.connectionFields.map((f) => f.key)).toEqual([+ "host",+ "port",+ "database",+ "sslEnabled",+ "sslRejectUnauthorized",+ "sslCertificate"+ ]);+ expect(fieldByKey(oracle!.connectionFields, "database")).toMatchObject({+ label: "Service Name",+ required: true+ });+ expect(fieldByKey(oracle!.connectionFields, "port")).toMatchObject({ widget: "number", defaultValue: 1521 });++ expect(fieldByKey(oracle!.credentialFields, "username")).toMatchObject({ required: true, secret: false });+ expect(fieldByKey(oracle!.credentialFields, "password")).toMatchObject({ widget: "password", secret: true });+ });+test("derives Redis connection and credential fields from the schema", () => {const redis = byType.get(PamAccountType.Redis);expect(redis).toBeDefined();diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex b963a12099..a431124b4c 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -313,6 +313,55 @@ export const ACCOUNT_TYPE_CONFIGS = {}},+ [PamAccountType.OracleDB]: {+ name: "Oracle Database",+ icon: "Oracle.png",+ connectionDetails: z.object({+ host: z.string().trim().min(1).max(255),+ port: z.coerce.number().int().min(1).max(65535),+ database: z+ .string()+ .trim()+ .min(1)+ .max(255)+ .regex(+ new RE2(/^[A-Za-z0-9][A-Za-z0-9_.\-#$]*$/),+ "Must start with a letter or digit and contain only letters, digits, underscores, dots, hyphens, # or $"+ ),+ sslEnabled: z.boolean(),+ sslRejectUnauthorized: z.boolean(),+ sslCertificate: optionalTrimmedString+ }),+ credentials: z.object({+ username: z.string().trim().min(1).max(128),+ password: z+ .string()+ .trim()+ .max(256)+ .transform((v) => v || undefined)+ .optional()+ }),+ sanitizedCredentials: z.object({ username: z.string() }),+ ui: {+ port: { defaultValue: 1521 },+ database: {+ label: "Service Name",+ tooltip: "The Oracle service name. For example FREEPDB1 or ORCL."+ },+ sslEnabled: { label: "SSL Enabled" },+ sslRejectUnauthorized: {+ label: "Reject Unauthorized",+ showWhen: { field: "sslEnabled", equals: true }+ },+ sslCertificate: {+ label: "SSL Certificate",+ widget: PamFieldWidget.Textarea,+ showWhen: { field: "sslEnabled", equals: true }+ },+ password: { widget: PamFieldWidget.Password, secret: true }+ }+ },+[PamAccountType.MongoDB]: {name: "MongoDB",icon: "MongoDB.png",@@ -787,7 +836,8 @@ export type TWindowsAdConnectionDetails = z.infer<export const SQL_ROTATABLE_ACCOUNT_TYPES = [PamAccountType.Postgres,PamAccountType.MySQL,- PamAccountType.MsSQL+ PamAccountType.MsSQL,+ PamAccountType.OracleDB] as const;// Windows accounts rotate over WinRM through the gateway: local accounts on their host, domain accounts@@ -849,6 +899,7 @@ export const extractGatewayTarget = async (case PamAccountType.Postgres:case PamAccountType.MySQL:case PamAccountType.MsSQL:+ case PamAccountType.OracleDB:case PamAccountType.Redis:case PamAccountType.Windows:return {@@ -898,7 +949,7 @@ export const extractGatewayTarget = async (case PamAccountType.AzureCli:return { host: "management.azure.com", port: 443 };default:- throw new Error(`No gateway target extraction defined for account type '${accountType}'`);+ throw new Error(`No gateway target extraction defined for account type '${accountType as PamAccountType}'`);}};diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex 1923c55af8..34e40fb5f7 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -743,7 +743,8 @@ export const pamSessionServiceFactory = ({(account.accountType === PamAccountType.Postgres ||account.accountType === PamAccountType.MySQL ||account.accountType === PamAccountType.MongoDB ||- account.accountType === PamAccountType.MsSQL) &&+ account.accountType === PamAccountType.MsSQL ||+ account.accountType === PamAccountType.OracleDB) &&rawConnectionDetails.database) {metadata.database = rawConnectionDetails.database as string;diff --git a/backend/src/lib/gateway-v2/gateway-v2.ts b/backend/src/lib/gateway-v2/gateway-v2.tsindex b63472b074..f011adc532 100644--- a/backend/src/lib/gateway-v2/gateway-v2.ts+++ b/backend/src/lib/gateway-v2/gateway-v2.ts@@ -143,7 +143,8 @@ export const createGatewayConnection = async ([GatewayProxyProtocol.Adcs]: ["infisical-adcs"],[GatewayProxyProtocol.Discovery]: ["infisical-discovery"],[GatewayProxyProtocol.ConnectionTest]: ["infisical-connection-test"],- [GatewayProxyProtocol.WinRm]: ["infisical-winrm"]+ [GatewayProxyProtocol.WinRm]: ["infisical-winrm"],+ [GatewayProxyProtocol.Sql]: ["infisical-sql"]};const tlsOptions: tls.ConnectionOptions = {diff --git a/backend/src/lib/gateway-v2/sql-rpc.ts b/backend/src/lib/gateway-v2/sql-rpc.tsnew file mode 100644index 0000000000..260d7f8a46--- /dev/null+++ b/backend/src/lib/gateway-v2/sql-rpc.ts@@ -0,0 +1,38 @@+import { postGatewayRpc } from "./gateway-rpc";+import { GatewayFailureKind } from "./test-connection-rpc";++const SQL_RPC_TIMEOUT_MS = 60_000;++const MAX_RPC_RESPONSE_BYTES = 1024 * 1024;++export type TSqlRpcResponse = { ok: true } | { ok: false; errorMessage: string; kind: GatewayFailureKind | null };++export const callSqlRotateCredential = async (args: {+ port: number;+ body: Record<string, unknown>;+ timeoutMs: number;+}): Promise<TSqlRpcResponse> => {+ const { status, text } = await postGatewayRpc({+ port: args.port,+ path: "/v1/rotate-credential",+ payload: JSON.stringify({ ...args.body, timeoutMs: args.timeoutMs }),+ timeoutMs: SQL_RPC_TIMEOUT_MS,+ maxResponseBytes: MAX_RPC_RESPONSE_BYTES,+ label: "SQL rotation"+ });++ if (status >= 200 && status < 300) return { ok: true };++ const errEnv = (() => {+ try {+ return (JSON.parse(text) as { error?: { message?: string; kind?: GatewayFailureKind } }).error;+ } catch {+ return undefined;+ }+ })();+ return {+ ok: false,+ errorMessage: errEnv?.message ?? `Gateway returned HTTP ${status}`,+ kind: errEnv?.kind ?? null+ };+};diff --git a/backend/src/lib/gateway/types.ts b/backend/src/lib/gateway/types.tsindex 45d12f2ea9..d4ff0a8383 100644--- a/backend/src/lib/gateway/types.ts+++ b/backend/src/lib/gateway/types.ts@@ -16,7 +16,8 @@ export enum GatewayProxyProtocol {Adcs = "adcs",Discovery = "discovery",ConnectionTest = "connection-test",- WinRm = "winrm"+ WinRm = "winrm",+ Sql = "sql"}export enum GatewayHttpProxyActions {diff --git a/docs/cli/commands/pam.mdx b/docs/cli/commands/pam.mdxindex 30ac62ada9..e0d9031d24 100644--- a/docs/cli/commands/pam.mdx+++ b/docs/cli/commands/pam.mdx@@ -130,6 +130,21 @@ Based on the account's template, the CLI connects you directly or starts the appConnection string format: `redis://127.0.0.1:<port>`</Accordion>+ <Accordion title="Oracle">+ Starts a local Oracle proxy on `127.0.0.1`.++ ```bash+ # Example+ infisical pam access production/billing-db --duration 2h+ ```++ Oracle's login protocol requires the client to send a password, so type `password` literally. The Gateway swaps in the real credential during login.++ ```bash+ sqlplus <username>/[email protected]:<port>/<service-name>+ ```+ </Accordion>+<Accordion title="SSH">Connects you straight to a shell on the target.diff --git a/docs/docs.json b/docs/docs.jsonindex 0d84571d62..ab18a39504 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -698,6 +698,7 @@"documentation/platform/pam/accounts/postgresql","documentation/platform/pam/accounts/mysql","documentation/platform/pam/accounts/mssql",+ "documentation/platform/pam/accounts/oracledb","documentation/platform/pam/accounts/mongodb","documentation/platform/pam/accounts/redis","documentation/platform/pam/accounts/ssh",@@ -718,6 +719,7 @@"documentation/platform/pam/product-reference/credential-rotation/postgresql","documentation/platform/pam/product-reference/credential-rotation/mysql","documentation/platform/pam/product-reference/credential-rotation/mssql",+ "documentation/platform/pam/product-reference/credential-rotation/oracledb","documentation/platform/pam/product-reference/credential-rotation/windows"]},diff --git a/docs/documentation/platform/pam/accounts/oracledb.mdx b/docs/documentation/platform/pam/accounts/oracledb.mdxnew file mode 100644index 0000000000..874de72021--- /dev/null+++ b/docs/documentation/platform/pam/accounts/oracledb.mdx@@ -0,0 +1,71 @@+---+title: "Oracle accounts"+sidebarTitle: "Oracle"+description: "Add and connect to Oracle databases."+---++Oracle accounts let you manage access to your Oracle databases. Users connect through the CLI, which starts a local proxy, and every [session](/documentation/platform/pam/sessions/overview) is recorded.++## Creating an account++<Steps>+ <Step title="Start adding an account">+ Go to **Privileged Access Management → Accounts** and select **Add Account**.+ </Step>+ <Step title="Select a folder and template">+ Choose which [folder](/documentation/platform/pam/folders/overview) to add the account to, then select an Oracle [template](/documentation/platform/pam/templates/overview).+ </Step>+ <Step title="Enter connection details">+ | Field | Description |+ |-------|-------------|+ | **Name** | A descriptive name (e.g., `billing-db`) |+ | **Host** | Database hostname or IP |+ | **Port** | Listener port (default: 1521, or 2484 for TCPS) |+ | **Service Name** | The Oracle service name, such as `ORCL` or `FREEPDB1` |+ | **SSL Enabled** | Connect to the TCPS listener |+ | **Reject Unauthorized** | Reject connections with invalid certificates (only if SSL enabled) |+ | **SSL Certificate** | Custom CA certificate (only if SSL enabled) |+ </Step>+ <Step title="Enter credentials">+ | Field | Description |+ |-------|-------------|+ | **Username** | The Oracle username, exactly as Oracle stores it. Unquoted names are stored uppercase |+ | **Password** | The Oracle password. Maximum 30 characters |+ </Step>+ <Step title="Save">+ Select **Create**.+ </Step>+</Steps>++Infisical checks it can reach the host before saving, so a wrong host or port fails at **Create**. The username and password are verified by the first [credential health check](/documentation/platform/pam/product-reference/credential-health/overview), which reports **Out of Sync** if Oracle rejects them.++## Connecting++The CLI starts a local proxy that you connect to with your preferred Oracle client.++```bash+infisical pam access my-folder/billing-db+```++The command outputs the local port to connect to, along with the username and service name.++Then use `sqlplus`, SQL Developer, or any Oracle client:++```bash+sqlplus <username>/[email protected]:<port>/<service-name>+```++**Flags:**+- `--port <port>`: use a specific local port (otherwise one is assigned automatically)+- `--reason <reason>`: provide an access reason (if required by template)++## Next steps++<CardGroup cols={2}>+ <Card title="Oracle credential rotation" icon="rotate" href="/documentation/platform/pam/product-reference/credential-rotation/oracledb">+ Rotate Oracle account passwords on a schedule.+ </Card>+ <Card title="Sessions" icon="display" href="/documentation/platform/pam/sessions/overview">+ View and manage sessions.+ </Card>+</CardGroup>diff --git a/docs/documentation/platform/pam/accounts/overview.mdx b/docs/documentation/platform/pam/accounts/overview.mdxindex 811cfa0ee1..18c2ec6758 100644--- a/docs/documentation/platform/pam/accounts/overview.mdx+++ b/docs/documentation/platform/pam/accounts/overview.mdx@@ -17,6 +17,7 @@ PAM supports the following account types:| [**PostgreSQL**](/documentation/platform/pam/accounts/postgresql) | PostgreSQL databases | ✓ || [**MySQL**](/documentation/platform/pam/accounts/mysql) | MySQL databases | ✓ || [**MS SQL**](/documentation/platform/pam/accounts/mssql) | Microsoft SQL Server | |+| [**Oracle**](/documentation/platform/pam/accounts/oracledb) | Oracle databases | || [**MongoDB**](/documentation/platform/pam/accounts/mongodb) | MongoDB databases | || [**Redis**](/documentation/platform/pam/accounts/redis) | Redis databases | ✓ || [**SSH**](/documentation/platform/pam/accounts/ssh) | Linux/Unix servers | ✓ |diff --git a/docs/documentation/platform/pam/product-reference/credential-health/overview.mdx b/docs/documentation/platform/pam/product-reference/credential-health/overview.mdxindex 58b1a94970..f7e16e3e2c 100644--- a/docs/documentation/platform/pam/product-reference/credential-health/overview.mdx+++ b/docs/documentation/platform/pam/product-reference/credential-health/overview.mdx@@ -34,6 +34,7 @@ Each check signs in the same way a session would, using the account's own authen| --- | --- || PostgreSQL, MySQL, Microsoft SQL Server | Signs in and runs a trivial query || Microsoft SQL Server with Windows authentication | Completes an NTLM or Kerberos handshake |+| Oracle | Signs in and runs a trivial query || MongoDB | Signs in and pings the server || Redis | Sends `AUTH`, then `PING` || Windows Active Directory | Binds to the domain controller |@@ -49,6 +50,10 @@ Checks are spread across the interval rather than fired together, so a templateMicrosoft SQL Server accounts using Windows authentication need a gateway running a version that supports the Windows authentication handshake. An older gateway reports these accounts as **Out of Sync** even when the credential is valid. Update the gateway to get an accurate result.</Note>+<Note>+ Checking an Oracle credential needs a gateway running v0.43.130 or later, and a password of 30 characters or fewer. An Oracle account that doesn't meet both shows as **Unreachable**.+</Note>+## Configuring a templateTemplate settings are managed by a [Product Admin](/documentation/platform/pam/concepts/access-control#product-membership). Go to **Privileged Access Management → Account Templates**, open a template, and find **Credential Health**.diff --git a/docs/documentation/platform/pam/product-reference/credential-rotation/oracledb.mdx b/docs/documentation/platform/pam/product-reference/credential-rotation/oracledb.mdxnew file mode 100644index 0000000000..c80bce22cd--- /dev/null+++ b/docs/documentation/platform/pam/product-reference/credential-rotation/oracledb.mdx@@ -0,0 +1,51 @@+---+title: "Oracle credential rotation"+sidebarTitle: "Oracle"+description: "Rotate Oracle account passwords with Infisical PAM."+---++This page covers what is specific to rotating an [Oracle account](/documentation/platform/pam/accounts/oracledb). For how rotation is configured and scheduled, see the [overview](/documentation/platform/pam/product-reference/credential-rotation/overview).++<Note>+ Rotating an Oracle account needs a [Gateway](/documentation/platform/gateways/overview) running v0.43.130 or later. Rotation fails on an older Gateway.+</Note>++## How the password is changed++When an Oracle account rotates, the rotation account connects to the target and runs:++```sql+ALTER USER "<target_username>" IDENTIFIED BY "<generated_password>";+```++The connection uses the account's existing connection details, including the SSL settings.++The statement matches the stored username exactly, so an account whose username doesn't match the case Oracle stored fails to rotate even though its sessions launch fine. Oracle reports this as a privilege error, not a missing user.++## Rotation account requirements++- **Self-rotation**: an Oracle user can change its own password, so no extra privileges are needed beyond `CREATE SESSION`.+- **Delegated rotation**: the rotation account needs the `ALTER USER` system privilege to change another user's password. Without it Oracle returns `ORA-01031: insufficient privileges`.++An example setup for a dedicated delegated rotation user:++```sql+-- the user Infisical connects as to perform rotations+CREATE USER infisical_rotator IDENTIFIED BY "temporary_password";+GRANT CREATE SESSION TO infisical_rotator;+GRANT ALTER USER TO infisical_rotator;++-- the account whose password gets rotated+CREATE USER app_user IDENTIFIED BY "temporary_password";+GRANT CREATE SESSION TO app_user;+```++<Note>+ A delegated rotation account has to use the same service name as its target, not just the same host and port. Oracle scopes a user to a single database, so a rotation account pointed at a different service can't see the target user.+</Note>++## Password length++An Oracle template won't accept a password length above 30 characters, and rotation never generates a longer one.++The same limit applies to the rotation account itself. If its own password is longer than 30 characters it can't sign in to perform the rotation, so shorten it first.diff --git a/docs/documentation/platform/pam/product-reference/credential-rotation/overview.mdx b/docs/documentation/platform/pam/product-reference/credential-rotation/overview.mdxindex eed004be71..2839fbeb4f 100644--- a/docs/documentation/platform/pam/product-reference/credential-rotation/overview.mdx+++ b/docs/documentation/platform/pam/product-reference/credential-rotation/overview.mdx@@ -85,6 +85,9 @@ Each resource type applies the password change differently and has its own requi<Card title="Microsoft SQL Server" icon="database" href="/documentation/platform/pam/product-reference/credential-rotation/mssql">Rotates a SQL Server login's password with `ALTER LOGIN`.</Card>+ <Card title="Oracle" icon="database" href="/documentation/platform/pam/product-reference/credential-rotation/oracledb">+ Rotates an Oracle user's password with `ALTER USER`.+ </Card><Card title="Windows" icon="windows" href="/documentation/platform/pam/product-reference/credential-rotation/windows">Rotates local Windows and Active Directory account passwords over WinRM.</Card>diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex 01ef81df66..ce61ad7611 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -30,6 +30,7 @@ export const ROTATABLE_PAM_ACCOUNT_TYPES = [PamAccountType.Postgres,PamAccountType.MySQL,PamAccountType.MsSQL,+ PamAccountType.OracleDB,PamAccountType.Windows,PamAccountType.WindowsAd];