Skip to content

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

hide by default

Matheus Nogueira35208c647b21
diff --git a/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts b/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
index 1f376f6f61..b2a19b0477 100644
--- a/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
+++ b/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-nested-ternary */
-import { ForbiddenError, subject } from "@casl/ability";
+import { ForbiddenError, MongoAbility, subject } from "@casl/ability";
import { Knex } from "knex";
import {
@@ -86,6 +86,7 @@ import { TPermissionServiceFactory } from "../permission/permission-service-type
import {
ProjectPermissionSecretActions,
ProjectPermissionSecretApprovalRequestActions,
+ ProjectPermissionSet,
ProjectPermissionSub
} from "../permission/project-permission";
import { ProjectEvents, TProjectEventPayload } from "../project-events/project-events-types";
@@ -206,6 +207,14 @@ export const secretApprovalRequestServiceFactory = ({
queueService,
secretValidationRuleService
}: TSecretApprovalRequestServiceFactoryDep) => {
+ // A duplicate-value violation may only name where the value is already used when the writer can read there.
+ const $canDescribeSecretAt =
+ (permission: MongoAbility<ProjectPermissionSet>) => (environment: string, secretPath: string) =>
+ permission.can(
+ ProjectPermissionSecretActions.DescribeSecret,
+ subject(ProjectPermissionSub.Secrets, { environment, secretPath })
+ );
+
const requestCount = async ({
projectId,
policyId,
@@ -934,14 +943,7 @@ export const secretApprovalRequestServiceFactory = ({
envId: policyEnvId,
secretPath: folderPaths?.[0]?.path || "/",
secrets: secretsToValidate,
- canAccessLocation: (duplicateEnvironment, duplicateSecretPath) =>
- permission.can(
- ProjectPermissionSecretActions.DescribeSecret,
- subject(ProjectPermissionSub.Secrets, {
- environment: duplicateEnvironment,
- secretPath: duplicateSecretPath
- })
- )
+ canAccessLocation: $canDescribeSecretAt(permission)
},
tx
);
@@ -2518,7 +2520,8 @@ export const secretApprovalRequestServiceFactory = ({
environment,
envId: folder.envId,
secretPath,
- secrets: secretsToValidate
+ secrets: secretsToValidate,
+ canAccessLocation: $canDescribeSecretAt(permission)
},
providedTx
);
diff --git a/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts b/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
index 246ac20c26..3589dc860a 100644
--- a/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
@@ -459,7 +459,8 @@ export const secretValidationRuleServiceFactory = ({
const accessByLocation = new Map<string, boolean>();
const isHidden = (dupEnvironment: string, dupPath: string) => {
- if (!canAccessLocation) return false;
+ // A caller that cannot say what the writer may read gets the location withheld, never leaked.
+ if (!canAccessLocation) return true;
const location = `${dupEnvironment}:${dupPath}`;
let hidden = accessByLocation.get(location);
diff --git a/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts b/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts
index 95838648fd..df278dd10d 100644
--- a/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts
+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts
@@ -129,8 +129,9 @@ export type TValidateSecretsDTO = {
envId: string;
secretPath: string;
secrets: TSecretToValidate[];
- // Whether the writer may read a location a duplicate value was found in. Without it the violation
- // would name a secret they cannot see, telling them where a value they hold is also used.
+ // Whether the writer may read a location a duplicate value was found in. A violation must not name
+ // a secret they cannot see, telling them where a value they hold is also used, so a caller that
+ // omits this has every location hidden.
canAccessLocation?: (environment: string, secretPath: string) => boolean;
};