Skip to content

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

fix(secret-folder): drop implied folder-read gate from folder move flow

Claudeb3f04ad07b86
diff --git a/backend/src/services/secret-folder/secret-folder-fns.ts b/backend/src/services/secret-folder/secret-folder-fns.ts
index d822fc20a3..62521f70a5 100644
--- a/backend/src/services/secret-folder/secret-folder-fns.ts
+++ b/backend/src/services/secret-folder/secret-folder-fns.ts
@@ -102,21 +102,26 @@ export const resolveClosestFolder = (
// read permission used to decide whether an actor is allowed to learn that a given blocking resource
// exists at a folder path. used to avoid disclosing subtree contents (e.g. honey tokens) to actors
-// without access while still scanning the full subtree to enforce move correctness.
-const FOLDER_MOVE_BLOCK_PERMISSION: Record<TFolderMoveBlockingType, { action: string; subject: ProjectPermissionSub }> =
- {
- secret_import: { action: ProjectPermissionActions.Read, subject: ProjectPermissionSub.SecretImports },
- dynamic_secret: {
- action: ProjectPermissionDynamicSecretActions.ReadRootCredential,
- subject: ProjectPermissionSub.DynamicSecrets
- },
- honey_token: { action: ProjectPermissionHoneyTokenActions.Read, subject: ProjectPermissionSub.HoneyTokens },
- secret_rotation: {
- action: ProjectPermissionSecretRotationActions.Read,
- subject: ProjectPermissionSub.SecretRotation
- },
- secret_approval_policy: { action: ProjectPermissionActions.Read, subject: ProjectPermissionSub.SecretFolders }
- };
+// without access while still scanning the full subtree to enforce move correctness. a `null` entry means
+// the block is not gated by any permission (the folder path is universally readable).
+const FOLDER_MOVE_BLOCK_PERMISSION: Record<
+ TFolderMoveBlockingType,
+ { action: string; subject: ProjectPermissionSub } | null
+> = {
+ secret_import: { action: ProjectPermissionActions.Read, subject: ProjectPermissionSub.SecretImports },
+ dynamic_secret: {
+ action: ProjectPermissionDynamicSecretActions.ReadRootCredential,
+ subject: ProjectPermissionSub.DynamicSecrets
+ },
+ honey_token: { action: ProjectPermissionHoneyTokenActions.Read, subject: ProjectPermissionSub.HoneyTokens },
+ secret_rotation: {
+ action: ProjectPermissionSecretRotationActions.Read,
+ subject: ProjectPermissionSub.SecretRotation
+ },
+ // an approval policy blocks at a folder path, and folder read is implied-for-all (folder list/get is not
+ // gated by a Read permission), so its existence is not disclosure-gated on a Read-on-SecretFolders proxy.
+ secret_approval_policy: null
+};
// when set, the move-block scan only reports blocks at paths the actor is allowed to read, so it cannot
// disclose the existence of blocking resources in a subtree the actor cannot see (used by the read-only
@@ -143,7 +148,10 @@ export const canActorReadBlock = (
blockingType: TFolderMoveBlockingType,
secretPath: string
) => {
- const { action, subject: sub } = FOLDER_MOVE_BLOCK_PERMISSION[blockingType];
+ const blockPermission = FOLDER_MOVE_BLOCK_PERMISSION[blockingType];
+ // no gating permission (e.g. approval policy at a universally-readable folder path): always readable.
+ if (!blockPermission) return true;
+ const { action, subject: sub } = blockPermission;
return (permission as MongoAbility).can(action, subject(sub, { environment, secretPath }));
};
diff --git a/backend/src/services/secret-folder/secret-folder-service.ts b/backend/src/services/secret-folder/secret-folder-service.ts
index f5582320c7..ddda5b0bf3 100644
--- a/backend/src/services/secret-folder/secret-folder-service.ts
+++ b/backend/src/services/secret-folder/secret-folder-service.ts
@@ -1594,6 +1594,8 @@ export const secretFolderServiceFactory = ({
};
const destinationParentPath = destinationPath ?? "/";
+ // a move only requires Create at the destination (the enforced move permission below). folder read is
+ // implied-for-all (folder list/get is not gated by a Read permission), so it is not required here.
const canActorAccessDestination =
!!destinationEnvironment &&
permission.can(
@@ -1602,13 +1604,6 @@ export const secretFolderServiceFactory = ({
environment: destinationEnvironment,
secretPath: destinationParentPath
})
- ) &&
- permission.can(
- ProjectPermissionActions.Read,
- subject(ProjectPermissionSub.SecretFolders, {
- environment: destinationEnvironment,
- secretPath: destinationParentPath
- })
);
// run every read inside a transaction so it hits the primary database rather than a read replica
@@ -1843,14 +1838,12 @@ export const secretFolderServiceFactory = ({
const sourceParent = path.dirname(entry.sourceAbsPath);
if (!checkedSourceParents.has(sourceParent)) {
checkedSourceParents.add(sourceParent);
+ // a move only requires Delete at each source parent path. folder read is implied-for-all (folder
+ // list/get is not gated by a Read permission), so it is not required here.
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionActions.Delete,
subject(ProjectPermissionSub.SecretFolders, { environment: sourceEnvironment, secretPath: sourceParent })
);
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionActions.Read,
- subject(ProjectPermissionSub.SecretFolders, { environment: sourceEnvironment, secretPath: sourceParent })
- );
}
const destinationParent = path.dirname(entry.destinationAbsPath);
if (!checkedDestinationParents.has(destinationParent)) {
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
index 6eff38e88d..48a823b101 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
@@ -303,10 +303,12 @@ const formatBlockedDestination = (
) => {
const envName =
envNameBySlug.get(blocked.destinationEnvironment) ?? blocked.destinationEnvironment;
+ // a policy name is only present when the destination is actually governed by a secret approval policy.
+ // when it is absent the destination is blocked because the actor lacks permission to create folders there.
if (blocked.policyName && blocked.blockingPath) {
return `At environment ${envName} the path "${blocked.blockingPath}" is governed by the secret approval policy "${blocked.policyName}", so "${blocked.folderName}" cannot be moved there.`;
}
- return `At environment ${envName} the destination is governed by a secret approval policy, so "${blocked.folderName}" cannot be moved there.`;
+ return `At environment ${envName} you don't have permission to create folders at the destination, so "${blocked.folderName}" cannot be moved there.`;
};
// surfaces the two destination-side reasons a move is blocked: a cyclic/self move (client-side) and a destination
@@ -350,10 +352,22 @@ const MoveBlockAlerts = ({
);
}
+ // a blocked destination carries a policy name only when it is genuinely governed by a secret approval
+ // policy; otherwise the block is a permission issue (the actor cannot create folders at the destination).
+ // title the alert by what actually blocks the set so a permission block is not mislabeled as a policy.
+ const hasPolicyBlock = blockedDestinations.some((blocked) => Boolean(blocked.policyName));
+ const hasPermissionBlock = blockedDestinations.some((blocked) => !blocked.policyName);
+ let title = "This move is blocked";
+ if (hasPolicyBlock && !hasPermissionBlock) {
+ title = "The destination is protected by a secret approval policy";
+ } else if (hasPermissionBlock && !hasPolicyBlock) {
+ title = "You don't have permission to move to the destination";
+ }
+
return (
<Alert variant="danger" className="mt-4">
<CircleAlertIcon />
- <AlertTitle>The destination is protected by a secret approval policy</AlertTitle>
+ <AlertTitle>{title}</AlertTitle>
<AlertDescription>
<ul className="list-disc pl-4">
{blockedDestinations.map((blocked) => (