Skip to content

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

hide project id if no access

Matheus Nogueira86f0c02d62bf
diff --git a/backend/src/services/secret-sync/secret-sync-service.ts b/backend/src/services/secret-sync/secret-sync-service.ts
index 26b894768a..cf5f37522a 100644
--- a/backend/src/services/secret-sync/secret-sync-service.ts
+++ b/backend/src/services/secret-sync/secret-sync-service.ts
@@ -343,9 +343,28 @@ export const secretSyncServiceFactory = ({
const duplicates = duplicateCheckResults.filter(Boolean);
const hasDuplicate = duplicates.length > 0;
+
+ let duplicateProjectId: string | undefined;
+ if (hasDuplicate) {
+ const duplicateProject = duplicates[0]!.projectId;
+ try {
+ await permissionService.getProjectPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ actionProjectType: ActionProjectType.SecretManager,
+ projectId: duplicateProject
+ });
+ duplicateProjectId = duplicateProject;
+ } catch {
+ // actor lacks access to the duplicate's project -- do not reveal it
+ }
+ }
+
return {
hasDuplicate,
- duplicateProjectId: hasDuplicate ? duplicates[0]!.projectId : undefined
+ duplicateProjectId
};
} catch (error) {
return { hasDuplicate: false, duplicateProjectId: undefined };
@@ -421,7 +440,9 @@ export const secretSyncServiceFactory = ({
if (duplicateCheck.hasDuplicate) {
throw new BadRequestError({
message: `A secret sync with this destination already exists${
- duplicateCheck.duplicateProjectId ? ` in project ${duplicateCheck.duplicateProjectId}` : ""
+ duplicateCheck.duplicateProjectId
+ ? ` in project ${duplicateCheck.duplicateProjectId}`
+ : " in another project in your organization"
}.`
});
}
diff --git a/frontend/src/components/secret-syncs/forms/DuplicateDestinationConfirmationModal.tsx b/frontend/src/components/secret-syncs/forms/DuplicateDestinationConfirmationModal.tsx
index ee8b5d0d08..c4fa5871bf 100644
--- a/frontend/src/components/secret-syncs/forms/DuplicateDestinationConfirmationModal.tsx
+++ b/frontend/src/components/secret-syncs/forms/DuplicateDestinationConfirmationModal.tsx
@@ -47,14 +47,18 @@ export const DuplicateDestinationConfirmationModal = ({
</span>
</AlertDialogDescription>
</AlertDialogHeader>
- {duplicateProjectId && (
- <p className="text-xs text-mineshaft-400">
- Duplicate found in project ID:{" "}
- <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5 text-mineshaft-200">
- {duplicateProjectId}
- </code>
- </p>
- )}
+ <p className="text-xs text-mineshaft-400">
+ {duplicateProjectId ? (
+ <>
+ Duplicate found in project ID:{" "}
+ <code className="rounded-sm bg-mineshaft-600 px-1 py-0.5 text-mineshaft-200">
+ {duplicateProjectId}
+ </code>
+ </>
+ ) : (
+ "Duplicate found in another project in your organization."
+ )}
+ </p>
{!isDisabled && <p className="text-sm">Are you sure you want to continue?</p>}
<AlertDialogFooter>
<AlertDialogCancel isDisabled={isLoading}>
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
index 4310240bf9..26d52d1f46 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
@@ -292,14 +292,18 @@ export const SecretSyncReviewFields = () => {
? "Another secret sync in your organization is already configured with the same destination. Your organization does not allow duplicate destination configurations."
: "Another secret sync in your organization is already configured with the same destination. This may lead to conflicts or unexpected behavior."}
</p>
- {duplicateProjectId && (
- <p>
- Duplicate found in project ID:{" "}
- <code className="rounded-sm bg-foreground/10 px-1 py-0.5 font-mono">
- {duplicateProjectId}
- </code>
- </p>
- )}
+ <p>
+ {duplicateProjectId ? (
+ <>
+ Duplicate found in project ID:{" "}
+ <code className="rounded-sm bg-foreground/10 px-1 py-0.5 font-mono">
+ {duplicateProjectId}
+ </code>
+ </>
+ ) : (
+ "Duplicate found in another project in your organization."
+ )}
+ </p>
</AlertDescription>
</Alert>
)}