Skip to content

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

even more greptile feedback fixes

x032205815b591dff34
diff --git a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts
index 94acf8497c..79af27d771 100644
--- a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts
+++ b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts
@@ -286,7 +286,7 @@ export const activeDirectoryResourceFactory: TPamResourceFactory<
reject(new Error(`AD password reset failed: ${modifyErr.message}`));
} else {
logger.info(
- `[AD Rotation] Password rotated for ${currentCredentials.username} on ${connectionDetails.domain}`
+ `[AD Rotation] Password rotated for domain account [username=${currentCredentials.username}] on [domain=${connectionDetails.domain}]`
);
resolve();
}
diff --git a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts
index 114c61cf78..de81a0e798 100644
--- a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts
+++ b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts
@@ -26,8 +26,8 @@ export const ActiveDirectoryResourceConnectionDetailsSchema = z.object({
domain: z.string().trim().min(1).max(255),
dcAddress: z.string().trim().min(1).max(255),
port: z.coerce.number().int().min(1).max(65535),
- useLdaps: z.boolean().optional(),
- ldapRejectUnauthorized: z.boolean().optional(),
+ useLdaps: z.boolean(),
+ ldapRejectUnauthorized: z.boolean(),
ldapCaCert: z
.string()
.trim()
diff --git a/backend/src/ee/services/pam-resource/shared/dependency-sync-fns.ts b/backend/src/ee/services/pam-resource/shared/dependency-sync-fns.ts
index e532d697ae..2999f1daee 100644
--- a/backend/src/ee/services/pam-resource/shared/dependency-sync-fns.ts
+++ b/backend/src/ee/services/pam-resource/shared/dependency-sync-fns.ts
@@ -15,26 +15,33 @@ import { decryptResource } from "../pam-resource-fns";
import { TPostRotateContext } from "../pam-resource-types";
import { TWindowsResourceConnectionDetails } from "../windows-server/windows-server-resource-types";
-const SINGLE_QUOTE_RE = new RE2("'", "g");
-const NEWLINE_RE = new RE2("[\\r\\n]", "g");
-
-// Allow alphanumerics, spaces, single backslash, hyphen, underscore, dot, but NOT ".." sequences
-const SAFE_WINDOWS_NAME_RE = new RE2("^[a-zA-Z0-9 _\\-.]+$");
-const SAFE_WINDOWS_PATH_RE = new RE2("^[a-zA-Z0-9 _\\-.\\\\/]+$");
-const PATH_TRAVERSAL_RE = new RE2("\\.\\.");
-
// Sanitize a string for safe use inside PowerShell single-quoted strings:
// - doubles single quotes (PowerShell escape)
// - strips newlines/carriage returns
+const SINGLE_QUOTE_RE = new RE2("'", "g");
+const NEWLINE_RE = new RE2("[\\r\\n]", "g");
export const escapePowershellSingleQuote = (value: string) =>
NEWLINE_RE.replace(SINGLE_QUOTE_RE.replace(value, "''"), "");
+// Reject control characters (U+0000–U+001F) that could survive escaping
+const CONTROL_CHAR_RE = new RE2("[\\x00-\\x1f]");
+const validateNoControlChars = (value: string, label: string) => {
+ if (CONTROL_CHAR_RE.test(value)) {
+ throw new Error(`${label} contains control characters`);
+ }
+};
+
+// Allow alphanumerics, spaces, hyphen, underscore, dot
+const SAFE_WINDOWS_NAME_RE = new RE2("^[a-zA-Z0-9 _\\-.]+$");
const validateWindowsName = (value: string, label: string) => {
if (!SAFE_WINDOWS_NAME_RE.test(value)) {
throw new Error(`${label} contains invalid characters: ${value}`);
}
};
+// Allow alphanumerics, spaces, hyphen, underscore, dot, backslash, forward slash (but reject ".." path traversal)
+const SAFE_WINDOWS_PATH_RE = new RE2("^[a-zA-Z0-9 _\\-.\\\\/]+$");
+const PATH_TRAVERSAL_RE = new RE2("\\.\\.");
const validateWindowsPath = (value: string, label: string) => {
if (!SAFE_WINDOWS_PATH_RE.test(value) || PATH_TRAVERSAL_RE.test(value)) {
throw new Error(`${label} contains invalid characters or path traversal: ${value}`);
@@ -46,12 +53,15 @@ export const buildDependencySyncScript = (
accountUsername: string,
newPassword: string
): string => {
- validateWindowsName(dep.name, "Dependency name");
-
const escapedPassword = escapePowershellSingleQuote(newPassword);
const escapedName = escapePowershellSingleQuote(dep.name);
const escapedUsername = escapePowershellSingleQuote(accountUsername);
+ // Validate all escaped values before interpolation into PowerShell commands
+ validateWindowsName(escapedName, "Dependency name");
+ validateNoControlChars(escapedUsername, "Account username");
+ validateNoControlChars(escapedPassword, "Password");
+
switch (dep.dependencyType) {
case PamAccountDependencyType.WindowsService:
return [