Skip to content

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

security check

Matheus Nogueira3444f3c51704
diff --git a/backend/src/services/secret-import/secret-import-service.ts b/backend/src/services/secret-import/secret-import-service.ts
index aada4c7b56..6c33b984f8 100644
--- a/backend/src/services/secret-import/secret-import-service.ts
+++ b/backend/src/services/secret-import/secret-import-service.ts
@@ -51,7 +51,7 @@ type TSecretImportServiceFactoryDep = {
secretDAL: Pick<TSecretDALFactory, "find">;
secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "find" | "findByFolderIds" | "invalidateSecretCacheByProjectId">;
projectBotService: Pick<TProjectBotServiceFactory, "getBotKey">;
- projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus">;
+ projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus" | "findById">;
projectEnvDAL: TProjectEnvDALFactory;
projectGrantDAL: Pick<TProjectGrantDALFactory, "findOne" | "find">;
orgDAL: Pick<TOrgDALFactory, "findOrgById">;
@@ -160,6 +160,11 @@ export const secretImportServiceFactory = ({
throw new ForbiddenRequestError({ message: "Cross-project secret sharing is not enabled for this organization" });
}
+ const sourceProject = await projectDAL.findById(sourceProjectId);
+ if (!sourceProject || sourceProject.orgId !== actorOrgId) {
+ throw new NotFoundError({ message: "Source project not found" });
+ }
+
const importFolder = await folderDAL.findBySecretPath(sourceProjectId, data.environment, data.path);
if (!importFolder) {
throw new NotFoundError({
@@ -1155,6 +1160,10 @@ export const secretImportServiceFactory = ({
secretName
});
+ const sourceProject = await projectDAL.findById(sourceProjectId);
+ if (!sourceProject || sourceProject.orgId !== actorOrgId)
+ throw new NotFoundError({ message: "Source project not found" });
+
const sourceFolder = await folderDAL.findBySecretPath(sourceProjectId, environment, secretPath);
if (!sourceFolder)
throw new NotFoundError({