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
swap from WinRM to SMB for credential validation
x032205c5049b73f579
diff --git a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-factory.ts b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-factory.tsindex b1ed782847..2d03c0eaff 100644--- a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-factory.ts+++ b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-factory.ts@@ -1,11 +1,10 @@import net from "node:net";-import axios from "axios";-import { BadRequestError } from "@app/lib/errors";import { GatewayProxyProtocol } from "@app/lib/gateway";import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";import { logger } from "@app/lib/logger";+import { verifyWindowsCredentials } from "@app/lib/smb-rpc";import { verifyHostInputValidity } from "../../dynamic-secret/dynamic-secret-fns";import { TGatewayV2ServiceFactory } from "../../gateway-v2/gateway-v2-service";@@ -18,7 +17,7 @@ import {import { TWindowsAccountCredentials, TWindowsResourceConnectionDetails } from "./windows-server-resource-types";const EXTERNAL_REQUEST_TIMEOUT = 10 * 1000;-const WINRM_HTTP_PORT = 5985;+const SMB_PORT = 445;const executeWithGateway = async <T>(config: {@@ -129,32 +128,19 @@ export const windowsResourceFactory: TPamResourceFactory<}try {- const statusCode = await executeWithGateway(- { connectionDetails, gatewayId, resourceType, targetPortOverride: WINRM_HTTP_PORT },+ await executeWithGateway(+ { connectionDetails, gatewayId, resourceType, targetPortOverride: SMB_PORT },gatewayV2Service,async (proxyPort) => {- const resp = await axios.post(`http://localhost:${proxyPort}/wsman`, "", {- headers: { "Content-Type": "application/soap+xml;charset=UTF-8" },- auth: { username: credentials.username, password: credentials.password },- timeout: EXTERNAL_REQUEST_TIMEOUT,- validateStatus: () => true- });- return resp.status;+ await verifyWindowsCredentials("localhost", proxyPort, credentials.username, credentials.password);});-- if (statusCode === 401) {- throw new BadRequestError({- message:- "Account credentials invalid: username or password is incorrect, or the account does not have WinRM access (only administrators can authenticate via WinRM by default)"- });- }} catch (error) {if (error instanceof BadRequestError) throw error;const errMsg = error instanceof Error ? error.message : String(error);throw new BadRequestError({- message: `Unable to validate account credentials via WinRM (port 5985): ${errMsg}. Ensure WinRM is enabled (run 'winrm quickconfig' on the server) and that port 5985 is open.`+ message: `Unable to validate account credentials via SMB: ${errMsg}`});}diff --git a/docs/documentation/platform/pam/getting-started/resources/windows-server.mdx b/docs/documentation/platform/pam/getting-started/resources/windows-server.mdxindex 782c94a56a..3361dc19b7 100644--- a/docs/documentation/platform/pam/getting-started/resources/windows-server.mdx+++ b/docs/documentation/platform/pam/getting-started/resources/windows-server.mdx@@ -35,7 +35,7 @@ sequenceDiagram2. **RDP Protocol**: Infisical connects to your Windows server using the Remote Desktop Protocol (RDP) on the configured port (default: 3389).-3. **Credential Validation via WinRM**: When creating or updating accounts, Infisical validates credentials by connecting to the Windows server's WinRM service (port 5985). This ensures credentials are correct before they are stored.+3. **Credential Validation via SMB**: When creating or updating accounts, Infisical validates credentials by connecting to the Windows server's SMB service (port 445). This ensures credentials are correct before they are stored.4. **Account Types**: Windows accounts can be categorized as either **User** accounts or **Service** accounts, allowing you to organize and manage different types of access.@@ -45,21 +45,15 @@ Before configuring Windows Server access in Infisical PAM, you need:1. **Infisical Gateway** - A Gateway deployed in your network with access to the Windows server2. **RDP Enabled** - Remote Desktop must be enabled on the Windows server (port 3389 by default)-3. **WinRM Enabled** - Windows Remote Management must be enabled for credential validation (port 5985)+3. **SMB Enabled** - SMB (Server Message Block) must be accessible for credential validation (port 445)4. **Windows Credentials** - A username and password for a Windows account on the server<Warning>- **WinRM Required**: Infisical validates account credentials using WinRM (Windows Remote Management) on port 5985. Ensure WinRM is enabled on your Windows server by running the following command in an elevated PowerShell prompt:-- ```powershell- winrm quickconfig- ```-- By default, only administrators can authenticate via WinRM. Ensure the account you're configuring has WinRM access.+ **SMB Required**: Infisical validates account credentials using SMB (Server Message Block) on port 445. SMB is enabled by default on Windows servers. Ensure port 445 is accessible from the Gateway and not blocked by a firewall.</Warning><Warning>- **Gateway Required**: Windows Server access requires an Infisical Gateway to be deployed and registered with your Infisical instance. The Gateway must have network connectivity to your Windows server on both the RDP port (default: 3389) and WinRM port (5985).+ **Gateway Required**: Windows Server access requires an Infisical Gateway to be deployed and registered with your Infisical instance. The Gateway must have network connectivity to your Windows server on both the RDP port (default: 3389) and SMB port (445).</Warning>## Create the PAM Resource@@ -131,7 +125,7 @@ A PAM Account represents a specific Windows user account on the server. You can</ParamField><Note>- When creating the account, Infisical will validate the credentials by connecting to the server's WinRM service. Ensure the account has WinRM access (administrators have this by default).+ When creating the account, Infisical will validate the credentials by connecting to the server via SMB (port 445).</Note></Step></Steps>