Skip to content

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

fix: add org boundary check for GATEWAY actors in PAM session/account services

bernie-g2a38a97ac37e
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 106529cd43..e152a449cf 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -972,6 +972,10 @@ export const pamAccountServiceFactory = ({
OrgPermissionGatewayActions.CreateGateways,
OrgPermissionSubjects.Gateway
);
+ } else if (actor.type === ActorType.GATEWAY) {
+ if (project.orgId !== actor.orgId) {
+ throw new ForbiddenRequestError({ message: "Gateway does not have access to this session" });
+ }
}
if (!session.accountId) throw new NotFoundError({ message: "Session is missing accountId column" });
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index 8cbf5e78a1..ebb12fa87a 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -172,6 +172,10 @@ export const pamSessionServiceFactory = ({
OrgPermissionGatewayActions.CreateGateways,
OrgPermissionSubjects.Gateway
);
+ } else if (actor.type === ActorType.GATEWAY) {
+ if (project.orgId !== actor.orgId) {
+ throw new ForbiddenRequestError({ message: "Gateway does not have access to this session" });
+ }
}
const authorized =
@@ -224,6 +228,9 @@ export const pamSessionServiceFactory = ({
throw new ForbiddenRequestError({ message: "Identity does not have access to end this session" });
}
} else if (actor.type === ActorType.GATEWAY) {
+ if (project.orgId !== actor.orgId) {
+ throw new ForbiddenRequestError({ message: "Gateway does not have access to this session" });
+ }
if (session.gatewayId && session.gatewayId !== actor.id) {
throw new ForbiddenRequestError({ message: "Gateway does not have access to end this session" });
}
@@ -411,6 +418,10 @@ export const pamSessionServiceFactory = ({
OrgPermissionGatewayActions.CreateGateways,
OrgPermissionSubjects.Gateway
);
+ } else if (actor.type === ActorType.GATEWAY) {
+ if (project.orgId !== actor.orgId) {
+ throw new ForbiddenRequestError({ message: "Gateway does not have access to this session" });
+ }
}
const authorized =