Skip to content

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

fix(pam): address review findings for machine identity support

bernie-ged73759e6097
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
index eb94408436..d511c8ca90 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
@@ -6,7 +6,7 @@ import { EventType, UserAgentType } from "@app/ee/services/audit-log/audit-log-t
import { PamAccountType, PamSessionStatus } from "@app/ee/services/pam/pam-enums";
import { PamRecordingStorageBackend } from "@app/ee/services/pam-session-recording/pam-recording-enums";
import { ApiDocsTags } from "@app/lib/api-docs/constants";
-import { BadRequestError, NotFoundError } from "@app/lib/errors";
+import { NotFoundError } from "@app/lib/errors";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
@@ -314,12 +314,8 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>
})
}
},
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
- if (req.auth.authMode !== AuthMode.JWT) {
- throw new BadRequestError({ message: "Account access requires JWT authentication" });
- }
-
const result = await server.services.pamSession.access({
path: req.body.path,
projectId: req.internalPamProjectId,
@@ -400,12 +396,8 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>
200: z.object({ ticket: z.string() })
}
},
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
- if (req.auth.authMode !== AuthMode.JWT) {
- throw new BadRequestError({ message: "Web access requires JWT authentication" });
- }
-
const { ticket } = await server.services.pamWebAccess.issueWebSocketTicket({
accountId: req.params.accountId,
projectId: req.internalPamProjectId,
diff --git a/backend/src/ee/services/pam-membership/pam-membership-service.ts b/backend/src/ee/services/pam-membership/pam-membership-service.ts
index b5c8581d91..68f0c0e1be 100644
--- a/backend/src/ee/services/pam-membership/pam-membership-service.ts
+++ b/backend/src/ee/services/pam-membership/pam-membership-service.ts
@@ -412,6 +412,14 @@ export const pamMembershipServiceFactory = ({
const updateProductMemberRole = async ({ projectId, role, ...dto }: TUpdatePamProductMemberDTO & TActorContext) => {
await checkProductAdmin(projectId, dto);
+ if (dto.userId && dto.userId === dto.actorId) {
+ throw new ForbiddenRequestError({ message: "You cannot modify your own membership" });
+ }
+
+ if (dto.identityId && dto.identityId === dto.actorId) {
+ throw new ForbiddenRequestError({ message: "You cannot modify your own membership" });
+ }
+
if (!VALID_PRODUCT_ROLES.includes(role)) {
throw new BadRequestError({
message: `Invalid product role '${role}'. Expected: ${VALID_PRODUCT_ROLES.join(", ")}`
@@ -452,6 +460,14 @@ export const pamMembershipServiceFactory = ({
const removeProductMember = async ({ projectId, ...dto }: TRemovePamProductMemberDTO & TActorContext) => {
await checkProductAdmin(projectId, dto);
+ if (dto.userId && dto.userId === dto.actorId) {
+ throw new ForbiddenRequestError({ message: "You cannot modify your own membership" });
+ }
+
+ if (dto.identityId && dto.identityId === dto.actorId) {
+ throw new ForbiddenRequestError({ message: "You cannot modify your own membership" });
+ }
+
const { column, id, kind } = resolveActorColumn(dto);
return membershipDAL.transaction(async (tx) => {
diff --git a/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx b/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx
index 17dc290e51..5ce041af6a 100644
--- a/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx
+++ b/frontend/src/pages/pam/PamAccessControlPage/components/IdentitiesTab.tsx
@@ -89,7 +89,8 @@ export const IdentitiesTab = () => {
const handleDeleteIdentity = async () => {
if (!identityToRemove) return;
- await removeIdentity.mutateAsync({ identityId: identityToRemove.identityId! });
+ if (!identityToRemove.identityId) return;
+ await removeIdentity.mutateAsync({ identityId: identityToRemove.identityId });
createNotification({ text: "Identity removed", type: "success" });
setIdentityToRemove(null);
};
diff --git a/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx b/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx
index aa29507574..2e2727e0a9 100644
--- a/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx
+++ b/frontend/src/pages/pam/PamAccessControlPage/components/IdentityRoleModal.tsx
@@ -42,9 +42,10 @@ export const IdentityRoleModal = ({ identity, identityName, isOpen, onOpenChange
const hasChanges = selectedRole !== currentRole;
const handleSave = () => {
+ if (!identity.identityId) return;
updateRole.mutate(
{
- identityId: identity.identityId!,
+ identityId: identity.identityId,
role: selectedRole
},
{
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx
index d7e3d631f0..7d6c2d18fa 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AssignAccessModal.tsx
@@ -116,7 +116,7 @@ type Props = {
resourceId: string;
existingUserIds: Set<string>;
existingGroupIds: Set<string>;
- existingIdentityIds?: Set<string>;
+ existingIdentityIds: Set<string>;
editMember?: EditMemberTarget | null;
};