Skip to content

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

security findings

Matheus Nogueirad26c9946a271
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index f69c44a919..71f431fcb1 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1981,6 +1981,7 @@ export const registerRoutes = async (
licenseService,
projectBotService,
projectGrantDAL,
+ orgDAL,
projectEnvDAL,
folderDAL,
permissionService,
diff --git a/backend/src/services/project-grant/project-grant-fns.ts b/backend/src/services/project-grant/project-grant-fns.ts
index 84bc596a2b..1159bf3979 100644
--- a/backend/src/services/project-grant/project-grant-fns.ts
+++ b/backend/src/services/project-grant/project-grant-fns.ts
@@ -1,6 +1,20 @@
import { getConfig } from "@app/lib/config/env";
+import { requestMemoKeys } from "@app/lib/request-context/memo-keys";
+import { requestMemoize } from "@app/lib/request-context/request-memoizer";
+
+import { TOrgDALFactory } from "../org/org-dal";
export const canUseCrossProjectSecretSharing = (orgId: string) => {
const appCfg = getConfig();
return appCfg.CROSS_PROJECT_SECRET_SHARING_ORG_WHITELIST.includes(orgId);
};
+
+export const isCrossProjectEnabled = async (
+ actorOrgId: string,
+ orgDAL: Pick<TOrgDALFactory, "findOrgById">
+) => {
+ const org = await requestMemoize(requestMemoKeys.orgFindOrgById(actorOrgId), () =>
+ orgDAL.findOrgById(actorOrgId)
+ );
+ return canUseCrossProjectSecretSharing(actorOrgId) && (org?.allowCrossProjectSecretSharing ?? false);
+};
diff --git a/backend/src/services/project-grant/project-grant-service.ts b/backend/src/services/project-grant/project-grant-service.ts
index abc3801923..eb16da0f39 100644
--- a/backend/src/services/project-grant/project-grant-service.ts
+++ b/backend/src/services/project-grant/project-grant-service.ts
@@ -3,17 +3,16 @@ import { ForbiddenError, subject } from "@casl/ability";
import { ActionProjectType } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
+ ProjectPermissionActions,
ProjectPermissionProjectGrantActions,
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
-import { requestMemoKeys } from "@app/lib/request-context/memo-keys";
-import { requestMemoize } from "@app/lib/request-context/request-memoizer";
import { TOrgDALFactory } from "@app/services/org/org-dal";
import { TProjectDALFactory } from "@app/services/project/project-dal";
import { TSecretFolderDALFactory } from "@app/services/secret-folder/secret-folder-dal";
-import { canUseCrossProjectSecretSharing } from "./project-grant-fns";
+import { isCrossProjectEnabled } from "./project-grant-fns";
import { TProjectGrantDALFactory } from "./project-grant-dal";
import {
TCreateProjectGrantDTO,
@@ -39,12 +38,6 @@ export const projectGrantServiceFactory = ({
orgDAL,
permissionService
}: TProjectGrantServiceFactoryDep) => {
- const isCrossProjectEnabled = async (actorOrgId: string) => {
- const org = await requestMemoize(requestMemoKeys.orgFindOrgById(actorOrgId), () =>
- orgDAL.findOrgById(actorOrgId)
- );
- return canUseCrossProjectSecretSharing(actorOrgId) && (org?.allowCrossProjectSecretSharing ?? false);
- };
const createGrant = async ({
actorId,
actor,
@@ -55,7 +48,7 @@ export const projectGrantServiceFactory = ({
secretPath,
targetProjectId
}: TCreateProjectGrantDTO) => {
- if (!(await isCrossProjectEnabled(actorOrgId))) {
+ if (!(await isCrossProjectEnabled(actorOrgId, orgDAL))) {
throw new ForbiddenRequestError({ message: "Cross-project secret sharing is not enabled for this organization" });
}
@@ -106,7 +99,7 @@ export const projectGrantServiceFactory = ({
grantId,
sourceProjectId
}: TDeleteProjectGrantDTO) => {
- if (!(await isCrossProjectEnabled(actorOrgId))) {
+ if (!(await isCrossProjectEnabled(actorOrgId, orgDAL))) {
throw new ForbiddenRequestError({ message: "Cross-project secret sharing is not enabled for this organization" });
}
@@ -138,7 +131,7 @@ export const projectGrantServiceFactory = ({
actorOrgId,
sourceProjectId
}: TListProjectGrantsDTO) => {
- if (!(await isCrossProjectEnabled(actorOrgId))) {
+ if (!(await isCrossProjectEnabled(actorOrgId, orgDAL))) {
return [];
}
@@ -166,11 +159,11 @@ export const projectGrantServiceFactory = ({
actorOrgId,
targetProjectId
}: TListProjectGrantsForTargetDTO) => {
- if (!(await isCrossProjectEnabled(actorOrgId))) {
+ if (!(await isCrossProjectEnabled(actorOrgId, orgDAL))) {
return [];
}
- await permissionService.getProjectPermission({
+ const { permission } = await permissionService.getProjectPermission({
actor,
actorId,
actorAuthMethod,
@@ -179,6 +172,11 @@ export const projectGrantServiceFactory = ({
actionProjectType: ActionProjectType.SecretManager
});
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionActions.Create,
+ ProjectPermissionSub.SecretImports
+ );
+
return projectGrantDAL.listByTargetProject(targetProjectId);
};
diff --git a/backend/src/services/secret-import/secret-import-service.ts b/backend/src/services/secret-import/secret-import-service.ts
index e45f23f3f4..1e33aef2b2 100644
--- a/backend/src/services/secret-import/secret-import-service.ts
+++ b/backend/src/services/secret-import/secret-import-service.ts
@@ -23,7 +23,9 @@ import { KmsDataKey } from "../kms/kms-types";
import { TProjectDALFactory } from "../project/project-dal";
import { TProjectBotServiceFactory } from "../project-bot/project-bot-service";
import { TProjectEnvDALFactory } from "../project-env/project-env-dal";
+import { isCrossProjectEnabled } from "../project-grant/project-grant-fns";
import { TProjectGrantDALFactory } from "../project-grant/project-grant-dal";
+import { TOrgDALFactory } from "../org/org-dal";
import { TSecretDALFactory } from "../secret/secret-dal";
import { decryptSecretRaw } from "../secret/secret-fns";
import { TSecretQueueFactory } from "../secret/secret-queue";
@@ -52,6 +54,7 @@ type TSecretImportServiceFactoryDep = {
projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus">;
projectEnvDAL: TProjectEnvDALFactory;
projectGrantDAL: Pick<TProjectGrantDALFactory, "findOne" | "find">;
+ orgDAL: Pick<TOrgDALFactory, "findOrgById">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
secretQueueService: Pick<TSecretQueueFactory, "syncSecrets" | "replicateSecrets">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
@@ -66,6 +69,7 @@ export const secretImportServiceFactory = ({
secretImportDAL,
projectEnvDAL,
projectGrantDAL,
+ orgDAL,
permissionService,
folderDAL,
projectDAL,
@@ -76,18 +80,24 @@ export const secretImportServiceFactory = ({
secretV2BridgeDAL,
kmsService
}: TSecretImportServiceFactoryDep) => {
- // Annotates cross-project imports with isAccessRevoked based on grant status.
- // The org-level toggle is enforced at grant creation time in project-grant-service;
- // here the grant is the single source of truth for per-import access.
const $annotateCrossProjectImports = async <
T extends { id: string; importEnv: { id: string; projectId?: string | null }; importPath: string }
>(
imports: T[],
- projectId: string
+ projectId: string,
+ actorOrgId: string
): Promise<(T & { isAccessRevoked: boolean })[]> => {
const crossProject = imports.filter((imp) => imp.importEnv.projectId !== projectId);
if (!crossProject.length) return imports.map((imp) => ({ ...imp, isAccessRevoked: false }));
+ // If org-level toggle is disabled, ignore all cross-project imports
+ if (!(await isCrossProjectEnabled(actorOrgId, orgDAL))) {
+ return imports.map((imp) => ({
+ ...imp,
+ isAccessRevoked: imp.importEnv.projectId !== projectId
+ }));
+ }
+
const sourceFolders = await folderDAL.findByManySecretPath(
crossProject.map((imp) => ({ envId: imp.importEnv.id, secretPath: imp.importPath }))
);
@@ -146,6 +156,10 @@ export const secretImportServiceFactory = ({
const isCrossProjectImport = sourceProjectId !== projectId;
if (isCrossProjectImport) {
+ if (!(await isCrossProjectEnabled(actorOrgId, orgDAL))) {
+ throw new ForbiddenRequestError({ message: "Cross-project secret sharing is not enabled for this organization" });
+ }
+
const importFolder = await folderDAL.findBySecretPath(sourceProjectId, data.environment, data.path);
if (!importFolder) {
throw new NotFoundError({
@@ -703,7 +717,7 @@ export const secretImportServiceFactory = ({
});
const secImports = await secretImportDAL.find({ folderId: folder.id, search, limit, offset });
- return $annotateCrossProjectImports(secImports, projectId);
+ return $annotateCrossProjectImports(secImports, projectId, actorOrgId);
};
const getImportById = async ({
@@ -801,7 +815,8 @@ export const secretImportServiceFactory = ({
const secretImports = (
await $annotateCrossProjectImports(
await secretImportDAL.find({ folderId: folder.id, isReplication: false }),
- projectId
+ projectId,
+ actorOrgId
)
).filter((imp) => !imp.isAccessRevoked);
const allowedImports = secretImports.filter((el) =>
@@ -842,7 +857,8 @@ export const secretImportServiceFactory = ({
const secretImports = (
await $annotateCrossProjectImports(
await secretImportDAL.find({ folderId: folder.id, isReplication: false }),
- projectId
+ projectId,
+ actorOrgId
)
).filter((imp) => !imp.isAccessRevoked);
@@ -953,7 +969,7 @@ export const secretImportServiceFactory = ({
const secImportsArrays = await Promise.all(
folders.map(async (folder) => {
const imports = await secretImportDAL.find({ folderId: folder.id, search, limit, offset });
- const annotated = await $annotateCrossProjectImports(imports, projectId);
+ const annotated = await $annotateCrossProjectImports(imports, projectId, actorOrgId);
return annotated.map((importItem) => ({
...importItem,
environment: folder.environment.slug
@@ -1109,7 +1125,11 @@ export const secretImportServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TGetCrossProjectImportSecretValueDTO) => {
- await permissionService.getProjectPermission({
+ if (!(await isCrossProjectEnabled(actorOrgId, orgDAL))) {
+ throw new ForbiddenRequestError({ message: "Cross-project secret sharing is not enabled for this organization" });
+ }
+
+ const { permission } = await permissionService.getProjectPermission({
actor,
actorId,
projectId,
@@ -1118,6 +1138,12 @@ export const secretImportServiceFactory = ({
actionProjectType: ActionProjectType.SecretManager
});
+ throwIfMissingSecretReadValueOrDescribePermission(permission, ProjectPermissionSecretActions.ReadValue, {
+ environment,
+ secretPath,
+ secretName
+ });
+
const sourceFolder = await folderDAL.findBySecretPath(sourceProjectId, environment, secretPath);
if (!sourceFolder)
throw new NotFoundError({