Skip to content

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

fix(global-approvals): make canAccess path normalized

x032205c45289ebcfb2
diff --git a/backend/src/services/approval-policy/pam-access/pam-access-policy-factory.ts b/backend/src/services/approval-policy/pam-access/pam-access-policy-factory.ts
index 9cce575d40..dce43e3198 100644
--- a/backend/src/services/approval-policy/pam-access/pam-access-policy-factory.ts
+++ b/backend/src/services/approval-policy/pam-access/pam-access-policy-factory.ts
@@ -68,11 +68,16 @@ export const pamAccessPolicyFactory: TApprovalResourceFactory<
revokedAt: null
});
+ const normalizedAccountPath = inputs.accountPath.startsWith("/") ? inputs.accountPath.slice(1) : inputs.accountPath;
+
// TODO(andrey): Move some of this check to be part of SQL query
return grants.some((grant) => {
const grantAttributes = grant.attributes as TPamAccessPolicyInputs;
- const isMatch = picomatch(grantAttributes.accountPath);
- return isMatch(inputs.accountPath) && (!grant.expiresAt || grant.expiresAt > new Date());
+ const normalizedGrantPath = grantAttributes.accountPath.startsWith("/")
+ ? grantAttributes.accountPath.slice(1)
+ : grantAttributes.accountPath;
+ const isMatch = picomatch(normalizedGrantPath);
+ return isMatch(normalizedAccountPath) && (!grant.expiresAt || grant.expiresAt > new Date());
});
};