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: update SMB connection to Windows terminology, enhance authentication handling, and improve related schemas
Victor Santos4b143c1f6dec
diff --git a/backend/src/lib/smb-rpc/smb-rpc-client.ts b/backend/src/lib/smb-rpc/smb-rpc-client.tsindex 656d2a0bc7..621408c015 100644--- a/backend/src/lib/smb-rpc/smb-rpc-client.ts+++ b/backend/src/lib/smb-rpc/smb-rpc-client.ts@@ -1,4 +1,9 @@import { spawn } from "child_process";+import * as fs from "fs";+import * as os from "os";+import * as path from "path";++import { logger } from "@app/lib/logger";export interface SmbRpcConfig {host: string;@@ -11,30 +16,51 @@ export interface SmbRpcConfig {const SMB3_SECURITY_OPTIONS = ["--option=client min protocol=SMB3", "--option=client smb encrypt=required"];/**- * Build the target string (//host:port)+ * Build the target string (//host)*/const buildTarget = (config: SmbRpcConfig): string => {- return `//${config.host}:${config.port}`;+ return `//${config.host}`;+};++/**+ * Build port args for SMB commands+ */+const buildPortArgs = (config: SmbRpcConfig): string[] => {+ return ["-p", String(config.port)];};/**- * Helper to build common auth args for SMB commands- * Uses --stdin to read password from stdin (avoids exposing password in process listings)+ * Create a temporary authentication file for Samba tools+ * Format: username = value, password = value, domain = value (optional)+ * Returns the file path*/-const buildAuthArgs = (config: SmbRpcConfig): string[] => {- const userCredential = config.domain ? `${config.domain}\\${config.adminUser}` : config.adminUser;+const createAuthFile = (config: SmbRpcConfig): string => {+ const authFilePath = path.join(os.tmpdir(), `smb-auth-${Date.now()}-${Math.random().toString(36).slice(2)}`);++ let content = `username = ${config.adminUser}\npassword = ${config.adminPassword}\n`;+ if (config.domain) {+ content += `domain = ${config.domain}\n`;+ }++ // Write with restrictive permissions (owner read/write only)+ fs.writeFileSync(authFilePath, content, { mode: 0o600 });++ return authFilePath;+};- return ["-U", userCredential, "--stdin", ...SMB3_SECURITY_OPTIONS];+/**+ * Helper to build common auth args for SMB commands using authentication file+ */+const buildAuthArgs = (authFilePath: string): string[] => {+ return ["-A", authFilePath, ...SMB3_SECURITY_OPTIONS];};/*** Execute a command and return stdout/stderr- * Optionally writes data to stdin (used for password input)*/const executeCommand = (command: string,- args: string[],- stdinData?: string+ args: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> => {return new Promise((resolve) => {const proc = spawn(command, args, {@@ -60,12 +86,6 @@ const executeCommand = (stderr += err.message;resolve({ stdout, stderr, exitCode: 1 });});-- // Write password to stdin if provided- if (stdinData !== undefined) {- proc.stdin.write(`${stdinData}\n`);- proc.stdin.end();- }});};@@ -93,6 +113,7 @@ const getNtStatusMessage = (ntStatus: string): string => {NT_STATUS_CONNECTION_REFUSED: "Connection refused - check if SMB is enabled on target",NT_STATUS_HOST_UNREACHABLE: "Host unreachable",NT_STATUS_IO_TIMEOUT: "Connection timed out",+ NT_STATUS_UNSUCCESSFUL: `Connection failed - verify SMB is enabled on target, firewall allows the port provided in the connection configuration, and SMB3 protocol is supported`,NT_STATUS_PASSWORD_RESTRICTION:"Password rejected by Windows policy - ensure Infisical password requirements meet or exceed Windows password policy",NT_STATUS_WRONG_PASSWORD: "Incorrect password"@@ -106,18 +127,28 @@ const getNtStatusMessage = (ntStatus: string): string => {* Uses smbclient to list shares and verify connectivity*/const testSmbConnection = async (config: SmbRpcConfig): Promise<void> => {- const args = ["-L", buildTarget(config), ...buildAuthArgs(config)];+ const authFilePath = createAuthFile(config);- const { stdout, stderr, exitCode } = await executeCommand("smbclient", args, config.adminPassword);- const combinedOutput = stdout + stderr;+ try {+ const args = ["-L", buildTarget(config), ...buildPortArgs(config), ...buildAuthArgs(authFilePath)];- const ntStatus = parseNtStatusError(combinedOutput);- if (ntStatus) {- throw new Error(getNtStatusMessage(ntStatus));- }+ const { stdout, stderr, exitCode } = await executeCommand("smbclient", args);+ const combinedOutput = stdout + stderr;- if (exitCode !== 0) {- throw new Error(`SMB connection failed: ${combinedOutput || "Unknown error"}`);+ const ntStatus = parseNtStatusError(combinedOutput);+ if (ntStatus) {+ throw new Error(getNtStatusMessage(ntStatus));+ }++ if (exitCode !== 0) {+ throw new Error(`SMB connection failed: ${combinedOutput || "Unknown error"}`);+ }+ } finally {+ try {+ fs.unlinkSync(authFilePath);+ } catch (err) {+ logger.warn({ err, authFilePath }, "Failed to cleanup SMB auth file");+ }}};@@ -159,21 +190,31 @@ export const changeWindowsPassword = async ();}- const escapedPassword = escapePasswordForRpc(newPassword);- const rpcCommand = `setuserinfo2 ${targetUser} 23 '${escapedPassword}'`;+ const authFilePath = createAuthFile(config);- const args = [buildTarget(config), ...buildAuthArgs(config), "-c", rpcCommand];+ try {+ const escapedPassword = escapePasswordForRpc(newPassword);+ const rpcCommand = `setuserinfo2 ${targetUser} 23 '${escapedPassword}'`;- const { stdout, stderr, exitCode } = await executeCommand("rpcclient", args, config.adminPassword);- const combinedOutput = stdout + stderr;+ const args = [buildTarget(config), ...buildPortArgs(config), ...buildAuthArgs(authFilePath), "-c", rpcCommand];- const ntStatus = parseNtStatusError(combinedOutput);- if (ntStatus) {- throw new Error(getNtStatusMessage(ntStatus));- }+ const { stdout, stderr, exitCode } = await executeCommand("rpcclient", args);+ const combinedOutput = stdout + stderr;++ const ntStatus = parseNtStatusError(combinedOutput);+ if (ntStatus) {+ throw new Error(getNtStatusMessage(ntStatus));+ }- if (exitCode !== 0) {- throw new Error(`Password change failed: ${combinedOutput || "Unknown error"}`);+ if (exitCode !== 0) {+ throw new Error(`Password change failed: ${combinedOutput || "Unknown error"}`);+ }+ } finally {+ try {+ fs.unlinkSync(authFilePath);+ } catch (err) {+ logger.warn({ err, authFilePath }, "Failed to cleanup SMB auth file");+ }}};diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.tsindex 9c0db67e75..1cef9abe4c 100644--- a/backend/src/services/app-connection/app-connection-maps.ts+++ b/backend/src/services/app-connection/app-connection-maps.ts@@ -47,7 +47,7 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {[AppConnection.Northflank]: "Northflank",[AppConnection.OctopusDeploy]: "Octopus Deploy",[AppConnection.SSH]: "SSH",- [AppConnection.SMB]: "SMB"+ [AppConnection.SMB]: "Windows"};export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanType> = {diff --git a/backend/src/services/app-connection/smb/smb-connection-fns.ts b/backend/src/services/app-connection/smb/smb-connection-fns.tsindex d89ae8e8c2..de39f3cbb0 100644--- a/backend/src/services/app-connection/smb/smb-connection-fns.ts+++ b/backend/src/services/app-connection/smb/smb-connection-fns.ts@@ -12,7 +12,7 @@ import { TSmbConnectionConfig } from "./smb-connection-types";export const getSmbConnectionListItem = () => {return {- name: "SMB" as const,+ name: "Windows" as const,app: AppConnection.SMB as const,methods: Object.values(SmbConnectionMethod) as [SmbConnectionMethod.Credentials]};diff --git a/backend/src/services/app-connection/smb/smb-connection-schemas.ts b/backend/src/services/app-connection/smb/smb-connection-schemas.tsindex 4f49164f96..286b17e0cc 100644--- a/backend/src/services/app-connection/smb/smb-connection-schemas.ts+++ b/backend/src/services/app-connection/smb/smb-connection-schemas.ts@@ -75,7 +75,7 @@ export const SanitizedSmbConnectionSchema = z.discriminatedUnion("method", [// List item schemaexport const SmbConnectionListItemSchema = z.object({- name: z.literal("SMB"),+ name: z.literal("Windows"),app: z.literal(AppConnection.SMB),methods: z.nativeEnum(SmbConnectionMethod).array()})diff --git a/frontend/public/images/integrations/Windows.png b/frontend/public/images/integrations/Windows.pngnew file mode 100644index 0000000000..6c3b1c0f8bBinary files /dev/null and b/frontend/public/images/integrations/Windows.png differdiff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsxindex 882e349be4..680638857d 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/WindowsLocalAccountRotationParametersFields.tsx@@ -33,7 +33,7 @@ export const WindowsLocalAccountRotationParametersFields = () => {<span>Determines how the rotation will be performed:</span><ul className="mt-2 ml-4 flex list-disc flex-col gap-2"><li>- <span className="font-medium">Login as Root</span> - The SMB connection+ <span className="font-medium">Login as Root</span> - The Windows connectioncredentials of the app connection linked will be used to change the targetuser's password.</li>@@ -53,7 +53,7 @@ export const WindowsLocalAccountRotationParametersFields = () => {isUpdate? "Cannot be updated.": value === WindowsLocalAccountRotationMethod.LoginAsRoot- ? "The SMB connection credentials will change the target user's password"+ ? "The Windows connection credentials will change the target user's password": "The target user will change their own password"}>diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/index.tsindex d7edf85bb5..942057a89e 100644--- a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts@@ -12,11 +12,13 @@ import { PostgresCredentialsRotationSchema } from "@app/components/secret-rotatiimport { SecretRotation } from "@app/hooks/api/secretRotationsV2";import { LdapPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ldap-password-rotation";import { UnixLinuxLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/unix-linux-local-account-rotation";+import { WindowsLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/windows-local-account-rotation";import { OktaClientSecretRotationSchema } from "./okta-client-secret-rotation-schema";import { OracleDBCredentialsRotationSchema } from "./oracledb-credentials-rotation-schema";import { RedisCredentialsRotationSchema } from "./redis-credentials-rotation-schema";import { UnixLinuxLocalAccountRotationSchema } from "./unix-linux-local-account-rotation-schema";+import { WindowsLocalAccountRotationSchema } from "./windows-local-account-rotation-schema";export const SecretRotationV2FormSchema = (isUpdate: boolean) =>z@@ -34,7 +36,8 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>RedisCredentialsRotationSchema,MongoDBCredentialsRotationSchema,DatabricksServicePrincipalSecretRotationSchema,- UnixLinuxLocalAccountRotationSchema+ UnixLinuxLocalAccountRotationSchema,+ WindowsLocalAccountRotationSchema]),z.object({ id: z.string().optional() }))@@ -67,6 +70,19 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>});}}++ if (val.type === SecretRotation.WindowsLocalAccount) {+ if (+ val.parameters.rotationMethod === WindowsLocalAccountRotationMethod.LoginAsTarget &&+ !val.temporaryParameters?.password+ ) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: "Password required",+ path: ["temporaryParameters", "password"]+ });+ }+ }});export type TSecretRotationV2Form = z.infer<ReturnType<typeof SecretRotationV2FormSchema>>;diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.tsindex aa34d324d1..a9d42a7137 100644--- a/frontend/src/helpers/appConnections.ts+++ b/frontend/src/helpers/appConnections.ts@@ -142,7 +142,7 @@ export const APP_CONNECTION_MAP: Record<[AppConnection.Chef]: { name: "Chef", image: "Chef.png", enterprise: true },[AppConnection.OctopusDeploy]: { name: "Octopus Deploy", image: "Octopus Deploy.png" },[AppConnection.SSH]: { name: "SSH", image: "SSH.png" },- [AppConnection.SMB]: { name: "SMB", image: "Windows.png", size: 50 }+ [AppConnection.SMB]: { name: "Windows", image: "Windows.png", size: 50 }};export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsxindex cb3eb09fd1..2a51856dbb 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx@@ -137,9 +137,6 @@ export const SmbConnectionForm = ({ appConnection, onSubmit }: Props) => {</OrgPermissionCan>)}<div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">- <p className="mb-3 text-xs text-mineshaft-300">- SMB connection uses SMB3 encryption for secure Windows remote management.- </p><Controllername="credentials.host"control={control}@@ -161,7 +158,6 @@ export const SmbConnectionForm = ({ appConnection, onSubmit }: Props) => {errorText={error?.message}isError={Boolean(error?.message)}label="Port"- isOptional><Inputtype="number"diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsxindex a29a9a6931..664838e921 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewSecretRotationRow/SecretOverviewSecretRotationRow.tsx@@ -31,6 +31,7 @@ import {TSecretRotationV2} from "@app/hooks/api/secretRotationsV2";import { UnixLinuxLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/unix-linux-local-account-rotation";+import { WindowsLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/windows-local-account-rotation";import { getExpandedRowStyle } from "@app/pages/secret-manager/OverviewPage/components/utils";import { SecretOverviewRotationSecretRow } from "./SecretOverviewRotationSecretRow";@@ -211,31 +212,34 @@ export const SecretOverviewSecretRotationRow = ({</IconButton>)}</ProjectPermissionCan>- {secretRotation.type === SecretRotation.UnixLinuxLocalAccount &&+ {((secretRotation.type === SecretRotation.UnixLinuxLocalAccount &&secretRotation.parameters.rotationMethod ===- UnixLinuxLocalAccountRotationMethod.LoginAsTarget && (- <ProjectPermissionCan- I={ProjectPermissionSecretRotationActions.RotateSecrets}- a={subject(ProjectPermissionSub.SecretRotation, {- environment: environment.slug,- secretPath: folder.path- })}- renderTooltip- allowedLabel="Reconcile Secret"- >- {(isAllowed) => (- <IconButton- ariaLabel="Reconcile secret"- variant="plain"- size="sm"- isDisabled={!isAllowed}- onClick={() => onReconcile(secretRotation)}- >- <FontAwesomeIcon icon={faHandshake} />- </IconButton>- )}- </ProjectPermissionCan>- )}+ UnixLinuxLocalAccountRotationMethod.LoginAsTarget) ||+ (secretRotation.type === SecretRotation.WindowsLocalAccount &&+ secretRotation.parameters.rotationMethod ===+ WindowsLocalAccountRotationMethod.LoginAsTarget)) && (+ <ProjectPermissionCan+ I={ProjectPermissionSecretRotationActions.RotateSecrets}+ a={subject(ProjectPermissionSub.SecretRotation, {+ environment: environment.slug,+ secretPath: folder.path+ })}+ renderTooltip+ allowedLabel="Reconcile Secret"+ >+ {(isAllowed) => (+ <IconButton+ ariaLabel="Reconcile secret"+ variant="plain"+ size="sm"+ isDisabled={!isAllowed}+ onClick={() => onReconcile(secretRotation)}+ >+ <FontAwesomeIcon icon={faHandshake} />+ </IconButton>+ )}+ </ProjectPermissionCan>+ )}<ProjectPermissionCanI={ProjectPermissionSecretRotationActions.Edit}a={subject(ProjectPermissionSub.SecretRotation, {diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsxindex 5a0efa061d..efc9650de6 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx@@ -22,6 +22,7 @@ import { SECRET_ROTATION_MAP } from "@app/helpers/secretRotationsV2";import { UsedBySecretSyncs } from "@app/hooks/api/dashboard/types";import { SecretRotation, TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";import { UnixLinuxLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/unix-linux-local-account-rotation";+import { WindowsLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/windows-local-account-rotation";import { SecretV3RawSanitized, WsTag } from "@app/hooks/api/types";import { SecretListView } from "../SecretListView";@@ -184,9 +185,12 @@ export const SecretRotationItem = ({</IconButton>)}</ProjectPermissionCan>- {secretRotation.type === SecretRotation.UnixLinuxLocalAccount &&+ {((secretRotation.type === SecretRotation.UnixLinuxLocalAccount &&secretRotation.parameters.rotationMethod ===- UnixLinuxLocalAccountRotationMethod.LoginAsTarget && (+ UnixLinuxLocalAccountRotationMethod.LoginAsTarget) ||+ (secretRotation.type === SecretRotation.WindowsLocalAccount &&+ secretRotation.parameters.rotationMethod ===+ WindowsLocalAccountRotationMethod.LoginAsTarget)) && (<ProjectPermissionCanI={ProjectPermissionSecretRotationActions.RotateSecrets}a={subject(ProjectPermissionSub.SecretRotation, {