Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor: update password validation messages and dangerous character definitions in SMB and Windows local account schemas for improved clarity and security

Victor Santosc822f5a25cb6
diff --git a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts
index cb6b0e22c6..3cf2a13f6c 100644
--- a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts
+++ b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts
@@ -39,7 +39,7 @@ const WindowsPasswordRequirementsSchema = PasswordRequirementsSchema.refine(
return !containsDangerousSmbChars(data.allowedSymbols);
},
{
- message: "Allowed symbols cannot contain dangerous characters: ; | & ` $ ( )",
+ message: "Allowed symbols cannot contain: semicolons, spaces, quotes, or pipes",
path: ["allowedSymbols"]
}
);
@@ -102,7 +102,7 @@ export const CreateWindowsLocalAccountRotationSchema = BaseCreateSecretRotationS
password: z
.string()
.refine((val) => !val || validateSmbPassword(val), {
- message: "Password cannot contain dangerous characters: ; | & ` $ ( ) or newlines"
+ message: "Password cannot contain: semicolons, spaces, quotes, or pipes"
})
.optional()
.describe(SecretRotations.PARAMETERS.WINDOWS_LOCAL_ACCOUNT.password)
diff --git a/backend/src/lib/smb-rpc/smb-rpc-client.ts b/backend/src/lib/smb-rpc/smb-rpc-client.ts
index 79c4824a14..966e489869 100644
--- a/backend/src/lib/smb-rpc/smb-rpc-client.ts
+++ b/backend/src/lib/smb-rpc/smb-rpc-client.ts
@@ -89,7 +89,7 @@ const validatePassword = (password: string): void => {
throw new Error("Password is required");
}
if (!validateSmbPassword(password)) {
- throw new Error("Password cannot contain dangerous characters: ; | & ` $ ( ) or newlines");
+ throw new Error("Password cannot contain: semicolons, spaces, quotes, or pipes");
}
};
diff --git a/backend/src/lib/validator/validate-smb.ts b/backend/src/lib/validator/validate-smb.ts
index 3ca9a4b2a5..0ad7ab313b 100644
--- a/backend/src/lib/validator/validate-smb.ts
+++ b/backend/src/lib/validator/validate-smb.ts
@@ -32,11 +32,11 @@ export const validateDomain = characterValidator([
// Dangerous characters that could enable command/RPC injection in Windows/SMB context
// These are blocked to prevent security issues:
-// - Command separators: ; | &
-// - Command substitution: ` $ ( )
-// - Newlines: \n \r (auth file directive injection)
-// - Null bytes: \0 (string termination attacks)
-export const DANGEROUS_SMB_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
+// - Semicolons: ; (command separator)
+// - Spaces: (argument separator)
+// - Quotes: ' " ` (string delimiters that could break parsing)
+// - Pipes: | (command chaining)
+export const DANGEROUS_SMB_CHARS = [";", " ", "'", '"', "`", "|"];
/**
* Validate password doesn't contain dangerous SMB characters
diff --git a/backend/src/services/app-connection/smb/smb-connection-schemas.ts b/backend/src/services/app-connection/smb/smb-connection-schemas.ts
index 163d39d3e2..aed0c64f7a 100644
--- a/backend/src/services/app-connection/smb/smb-connection-schemas.ts
+++ b/backend/src/services/app-connection/smb/smb-connection-schemas.ts
@@ -60,7 +60,7 @@ export const SmbConnectionCredentialsSchema = z.object({
.string()
.min(1, "Password required")
.refine((val) => validateSmbPassword(val), {
- message: "Password cannot contain the following characters: ; | & ` $ ( ) or newlines"
+ message: "Password cannot contain: semicolons, spaces, quotes, or pipes"
})
.describe(AppConnections.CREDENTIALS.SMB.password)
});
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts
index 388542eeef..a121e3238d 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts
@@ -21,7 +21,7 @@ const WindowsPasswordRequirementsSchema = PasswordRequirementsSchema.refine(
return !containsDangerousSmbChars(data.allowedSymbols);
},
{
- message: "Allowed symbols cannot contain the characters: ; | & ` $ ( ) or newlines",
+ message: "Allowed symbols cannot contain: semicolons, spaces, quotes, or pipes",
path: ["allowedSymbols"]
}
);
@@ -61,7 +61,7 @@ export const WindowsLocalAccountRotationSchema = z
password: z
.string()
.refine((val) => !val || validateSmbPassword(val), {
- message: "Password cannot contain the following characters: ; | & ` $ ( ) or newlines"
+ message: "Password cannot contain: semicolons, spaces, quotes, or pipes"
})
.optional()
})
diff --git a/frontend/src/helpers/smb.ts b/frontend/src/helpers/smb.ts
index ba7366ad78..353babe146 100644
--- a/frontend/src/helpers/smb.ts
+++ b/frontend/src/helpers/smb.ts
@@ -17,11 +17,11 @@ export const SMB_USERNAME_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]*$/;
// Dangerous characters that could enable command/RPC injection in Windows/SMB context
// These are blocked to prevent security issues:
-// - Command separators: ; | &
-// - Command substitution: ` $ ( )
-// - Newlines: \n \r (auth file directive injection)
-// - Null bytes: \0 (string termination attacks)
-export const DANGEROUS_SMB_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
+// - Semicolons: ; (command separator)
+// - Spaces: (argument separator)
+// - Quotes: ' " ` (string delimiters that could break parsing)
+// - Pipes: | (command chaining)
+export const DANGEROUS_SMB_CHARS = [";", " ", "'", '"', "`", "|"];
/**
* Validate password doesn't contain dangerous SMB characters
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx
index 368db6036e..21fd5e0d74 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx
@@ -81,7 +81,7 @@ const formSchema = genericAppConnectionFieldsSchema.extend({
.string()
.min(1, "Password required")
.refine((val) => validateSmbPassword(val), {
- message: "Password cannot contain the following characters: ; | & ` $ ( ) or newlines"
+ message: "Password cannot contain: semicolons, spaces, quotes, or pipes"
})
})
});