Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
misc: added privilege escalation checks
Sheen Capadngan2d1d6f5ce869
diff --git a/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts b/backend/src/server/routes/v1/identity-aws-iam-auth-router.tsindex 414f8534c5..82387a3ccf 100644--- a/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts+++ b/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts@@ -11,6 +11,7 @@ import {validateAccountIds,validatePrincipalArns} from "@app/services/identity-aws-auth/identity-aws-auth-validators";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider) => {server.route({@@ -130,7 +131,8 @@ export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider)actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({diff --git a/backend/src/server/routes/v1/identity-azure-auth-router.ts b/backend/src/server/routes/v1/identity-azure-auth-router.tsindex f46fb57ca6..1cf59e682b 100644--- a/backend/src/server/routes/v1/identity-azure-auth-router.ts+++ b/backend/src/server/routes/v1/identity-azure-auth-router.ts@@ -8,8 +8,7 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";import { TIdentityTrustedIp } from "@app/services/identity/identity-types";import { validateAzureAuthField } from "@app/services/identity-azure-auth/identity-azure-auth-validators";--import {} from "../sanitizedSchemas";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider) => {server.route({@@ -127,7 +126,8 @@ export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvideractorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({diff --git a/backend/src/server/routes/v1/identity-gcp-auth-router.ts b/backend/src/server/routes/v1/identity-gcp-auth-router.tsindex 057458bb2c..d269072d95 100644--- a/backend/src/server/routes/v1/identity-gcp-auth-router.ts+++ b/backend/src/server/routes/v1/identity-gcp-auth-router.ts@@ -8,6 +8,7 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";import { TIdentityTrustedIp } from "@app/services/identity/identity-types";import { validateGcpAuthField } from "@app/services/identity-gcp-auth/identity-gcp-auth-validators";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider) => {server.route({@@ -121,7 +122,8 @@ export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider)actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({diff --git a/backend/src/server/routes/v1/identity-jwt-auth-router.ts b/backend/src/server/routes/v1/identity-jwt-auth-router.tsindex 2950fc72da..bb09898a39 100644--- a/backend/src/server/routes/v1/identity-jwt-auth-router.ts+++ b/backend/src/server/routes/v1/identity-jwt-auth-router.ts@@ -12,6 +12,7 @@ import {validateJwtAuthAudiencesField,validateJwtBoundClaimsField} from "@app/services/identity-jwt-auth/identity-jwt-auth-validators";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";const IdentityJwtAuthResponseSchema = IdentityJwtAuthsSchema.omit({encryptedJwksCaCert: true,@@ -169,7 +170,8 @@ export const registerIdentityJwtAuthRouter = async (server: FastifyZodProvider)actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({diff --git a/backend/src/server/routes/v1/identity-kubernetes-auth-router.ts b/backend/src/server/routes/v1/identity-kubernetes-auth-router.tsindex 263fa478e8..952cfcdaff 100644--- a/backend/src/server/routes/v1/identity-kubernetes-auth-router.ts+++ b/backend/src/server/routes/v1/identity-kubernetes-auth-router.ts@@ -7,6 +7,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";import { TIdentityTrustedIp } from "@app/services/identity/identity-types";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";const IdentityKubernetesAuthResponseSchema = IdentityKubernetesAuthsSchema.pick({id: true,@@ -147,7 +148,8 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvideactorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({diff --git a/backend/src/server/routes/v1/identity-oidc-auth-router.ts b/backend/src/server/routes/v1/identity-oidc-auth-router.tsindex 7ce0b05b75..ab3a4b8053 100644--- a/backend/src/server/routes/v1/identity-oidc-auth-router.ts+++ b/backend/src/server/routes/v1/identity-oidc-auth-router.ts@@ -11,6 +11,7 @@ import {validateOidcAuthAudiencesField,validateOidcBoundClaimsField} from "@app/services/identity-oidc-auth/identity-oidc-auth-validators";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";const IdentityOidcAuthResponseSchema = IdentityOidcAuthsSchema.pick({id: true,@@ -146,7 +147,8 @@ export const registerIdentityOidcAuthRouter = async (server: FastifyZodProvider)actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({diff --git a/backend/src/server/routes/v1/identity-router.ts b/backend/src/server/routes/v1/identity-router.tsindex 5ec688061e..344da33839 100644--- a/backend/src/server/routes/v1/identity-router.ts+++ b/backend/src/server/routes/v1/identity-router.ts@@ -7,6 +7,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { getTelemetryDistinctId } from "@app/server/lib/telemetry";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";import { SanitizedProjectSchema } from "../sanitizedSchemas";@@ -118,6 +119,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,id: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth),...req.body});@@ -166,7 +168,8 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {actorId: req.permission.id,actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,- id: req.params.identityId+ id: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({diff --git a/backend/src/server/routes/v1/identity-token-auth-router.ts b/backend/src/server/routes/v1/identity-token-auth-router.tsindex 3d331403ac..d6e7259be2 100644--- a/backend/src/server/routes/v1/identity-token-auth-router.ts+++ b/backend/src/server/routes/v1/identity-token-auth-router.ts@@ -7,6 +7,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";import { TIdentityTrustedIp } from "@app/services/identity/identity-types";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider) => {server.route({@@ -74,7 +75,8 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvideractorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({@@ -157,7 +159,8 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvideractorOrgId: req.permission.orgId,actorAuthMethod: req.permission.authMethod,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({@@ -257,7 +260,8 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvideractorId: req.permission.id,actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});await server.services.auditLog.createAuditLog({@@ -312,6 +316,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvideractorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth),...req.body});@@ -370,6 +375,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvideractorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth),...req.query});@@ -421,6 +427,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvideractorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,tokenId: req.params.tokenId,+ isActorSuperAdmin: isSuperAdmin(req.auth),...req.body});@@ -470,7 +477,8 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvideractorId: req.permission.id,actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,- tokenId: req.params.tokenId+ tokenId: req.params.tokenId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});return {diff --git a/backend/src/server/routes/v1/identity-universal-auth-router.ts b/backend/src/server/routes/v1/identity-universal-auth-router.tsindex e48e1f442e..5a9363f3df 100644--- a/backend/src/server/routes/v1/identity-universal-auth-router.ts+++ b/backend/src/server/routes/v1/identity-universal-auth-router.ts@@ -7,6 +7,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";import { TIdentityTrustedIp } from "@app/services/identity/identity-types";+import { isSuperAdmin } from "@app/services/super-admin/super-admin-fns";export const sanitizedClientSecretSchema = IdentityUaClientSecretsSchema.pick({id: true,@@ -142,8 +143,10 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {actorOrgId: req.permission.orgId,actorAuthMethod: req.permission.authMethod,...req.body,- identityId: req.params.identityId+ identityId: req.params.identityId,+ isActorSuperAdmin: isSuperAdmin(req.auth)});+await server.services.auditLog.createAuditLog({...req.auditLogInfo,orgId: identityUniversalAuth.orgId,diff --git a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts b/backend/src/services/identity-aws-auth/identity-aws-auth-service.tsindex ddd9e02787..5be3dfe4c5 100644--- a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts+++ b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts@@ -16,6 +16,7 @@ import { ActorType, AuthTokenType } from "../auth/auth-type";import { TIdentityOrgDALFactory } from "../identity/identity-org-dal";import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identity-access-token-dal";import { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityAwsAuthDALFactory } from "./identity-aws-auth-dal";import { extractPrincipalArn } from "./identity-aws-auth-fns";import {@@ -149,8 +150,11 @@ export const identityAwsAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachAwsAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });diff --git a/backend/src/services/identity-aws-auth/identity-aws-auth-types.ts b/backend/src/services/identity-aws-auth/identity-aws-auth-types.tsindex c24186ee0e..785b37bbc0 100644--- a/backend/src/services/identity-aws-auth/identity-aws-auth-types.ts+++ b/backend/src/services/identity-aws-auth/identity-aws-auth-types.ts@@ -16,6 +16,7 @@ export type TAttachAwsAuthDTO = {accessTokenMaxTTL: number;accessTokenNumUsesLimit: number;accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateAwsAuthDTO = {diff --git a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts b/backend/src/services/identity-azure-auth/identity-azure-auth-service.tsindex 01878dbb3d..87e076e939 100644--- a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts+++ b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts@@ -14,6 +14,7 @@ import { ActorType, AuthTokenType } from "../auth/auth-type";import { TIdentityOrgDALFactory } from "../identity/identity-org-dal";import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identity-access-token-dal";import { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityAzureAuthDALFactory } from "./identity-azure-auth-dal";import { validateAzureIdentity } from "./identity-azure-auth-fns";import {@@ -122,8 +123,11 @@ export const identityAzureAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachAzureAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });diff --git a/backend/src/services/identity-azure-auth/identity-azure-auth-types.ts b/backend/src/services/identity-azure-auth/identity-azure-auth-types.tsindex ec03451dbc..485753b6fd 100644--- a/backend/src/services/identity-azure-auth/identity-azure-auth-types.ts+++ b/backend/src/services/identity-azure-auth/identity-azure-auth-types.ts@@ -14,6 +14,7 @@ export type TAttachAzureAuthDTO = {accessTokenMaxTTL: number;accessTokenNumUsesLimit: number;accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateAzureAuthDTO = {diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.tsindex 7b0dd4390c..321f633fff 100644--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts@@ -14,6 +14,7 @@ import { ActorType, AuthTokenType } from "../auth/auth-type";import { TIdentityOrgDALFactory } from "../identity/identity-org-dal";import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identity-access-token-dal";import { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityGcpAuthDALFactory } from "./identity-gcp-auth-dal";import { validateIamIdentity, validateIdTokenIdentity } from "./identity-gcp-auth-fns";import {@@ -162,8 +163,11 @@ export const identityGcpAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachGcpAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-types.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-types.tsindex 45e64b24b6..063630c738 100644--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-types.ts+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-types.ts@@ -15,6 +15,7 @@ export type TAttachGcpAuthDTO = {accessTokenMaxTTL: number;accessTokenNumUsesLimit: number;accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateGcpAuthDTO = {diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.tsindex 555dc00a6c..9bfc979560 100644--- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts+++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts@@ -18,6 +18,7 @@ import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identitimport { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";import { TKmsServiceFactory } from "../kms/kms-service";import { KmsDataKey } from "../kms/kms-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityJwtAuthDALFactory } from "./identity-jwt-auth-dal";import { doesFieldValueMatchJwtPolicy } from "./identity-jwt-auth-fns";import {@@ -248,8 +249,11 @@ export const identityJwtAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachJwtAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) {if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-types.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-types.tsindex a6881f0e5a..bc19aba830 100644--- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-types.ts+++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-types.ts@@ -19,6 +19,7 @@ export type TAttachJwtAuthDTO = {accessTokenMaxTTL: number;accessTokenNumUsesLimit: number;accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateJwtAuthDTO = {diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.tsindex c7b2c5c8d0..40c7a0af6f 100644--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts@@ -18,6 +18,7 @@ import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identitimport { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";import { TKmsServiceFactory } from "../kms/kms-service";import { KmsDataKey } from "../kms/kms-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityKubernetesAuthDALFactory } from "./identity-kubernetes-auth-dal";import { extractK8sUsername } from "./identity-kubernetes-auth-fns";import {@@ -227,8 +228,11 @@ export const identityKubernetesAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachKubernetesAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-types.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-types.tsindex f1cde2be9a..c66ec8480f 100644--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-types.ts+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-types.ts@@ -17,6 +17,7 @@ export type TAttachKubernetesAuthDTO = {accessTokenMaxTTL: number;accessTokenNumUsesLimit: number;accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateKubernetesAuthDTO = {diff --git a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.tsindex 3c947f5041..d3e713b304 100644--- a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts+++ b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts@@ -19,6 +19,7 @@ import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identitimport { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";import { TKmsServiceFactory } from "../kms/kms-service";import { KmsDataKey } from "../kms/kms-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityOidcAuthDALFactory } from "./identity-oidc-auth-dal";import { doesAudValueMatchOidcPolicy, doesFieldValueMatchOidcPolicy } from "./identity-oidc-auth-fns";import {@@ -196,8 +197,10 @@ export const identityOidcAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachOidcAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) {if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });diff --git a/backend/src/services/identity-oidc-auth/identity-oidc-auth-types.ts b/backend/src/services/identity-oidc-auth/identity-oidc-auth-types.tsindex 761f68aa74..78a10479cc 100644--- a/backend/src/services/identity-oidc-auth/identity-oidc-auth-types.ts+++ b/backend/src/services/identity-oidc-auth/identity-oidc-auth-types.ts@@ -12,6 +12,7 @@ export type TAttachOidcAuthDTO = {accessTokenMaxTTL: number;accessTokenNumUsesLimit: number;accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateOidcAuthDTO = {diff --git a/backend/src/services/identity-token-auth/identity-token-auth-service.ts b/backend/src/services/identity-token-auth/identity-token-auth-service.tsindex d9e2d66fad..1d327fff30 100644--- a/backend/src/services/identity-token-auth/identity-token-auth-service.ts+++ b/backend/src/services/identity-token-auth/identity-token-auth-service.ts@@ -14,6 +14,7 @@ import { ActorType, AuthTokenType } from "../auth/auth-type";import { TIdentityOrgDALFactory } from "../identity/identity-org-dal";import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identity-access-token-dal";import { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityTokenAuthDALFactory } from "./identity-token-auth-dal";import {TAttachTokenAuthDTO,@@ -59,8 +60,11 @@ export const identityTokenAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachTokenAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });@@ -126,8 +130,11 @@ export const identityTokenAuthServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TUpdateTokenAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });@@ -218,8 +225,11 @@ export const identityTokenAuthServiceFactory = ({actorId,actor,actorAuthMethod,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TRevokeTokenAuthDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });@@ -271,8 +281,11 @@ export const identityTokenAuthServiceFactory = ({actor,actorAuthMethod,actorOrgId,- name+ name,+ isActorSuperAdmin}: TCreateTokenAuthTokenDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });@@ -350,8 +363,11 @@ export const identityTokenAuthServiceFactory = ({actorId,actor,actorAuthMethod,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TGetTokenAuthTokensDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });@@ -386,7 +402,8 @@ export const identityTokenAuthServiceFactory = ({actorId,actor,actorAuthMethod,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TUpdateTokenAuthTokenDTO) => {const foundToken = await identityAccessTokenDAL.findOne({[`${TableName.IdentityAccessToken}.id` as "id"]: tokenId,@@ -398,6 +415,8 @@ export const identityTokenAuthServiceFactory = ({if (!identityMembershipOrg) {throw new NotFoundError({ message: `Failed to find identity with ID ${foundToken.identityId}` });}++ await validateIdentityUpdateForSuperAdminPrivileges(foundToken.identityId, isActorSuperAdmin);if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.TOKEN_AUTH)) {throw new BadRequestError({message: "The identity does not have Token Auth"@@ -446,18 +465,22 @@ export const identityTokenAuthServiceFactory = ({actorId,actor,actorAuthMethod,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TRevokeTokenAuthTokenDTO) => {const identityAccessToken = await identityAccessTokenDAL.findOne({[`${TableName.IdentityAccessToken}.id` as "id"]: tokenId,[`${TableName.IdentityAccessToken}.isAccessTokenRevoked` as "isAccessTokenRevoked"]: false,[`${TableName.IdentityAccessToken}.authMethod` as "authMethod"]: IdentityAuthMethod.TOKEN_AUTH});+if (!identityAccessToken)throw new NotFoundError({message: `Token with ID ${tokenId} not found or already revoked`});+ await validateIdentityUpdateForSuperAdminPrivileges(identityAccessToken.identityId, isActorSuperAdmin);+const identityOrgMembership = await identityOrgMembershipDAL.findOne({identityId: identityAccessToken.identityId});diff --git a/backend/src/services/identity-token-auth/identity-token-auth-types.ts b/backend/src/services/identity-token-auth/identity-token-auth-types.tsindex 12c689728b..16cd60db77 100644--- a/backend/src/services/identity-token-auth/identity-token-auth-types.ts+++ b/backend/src/services/identity-token-auth/identity-token-auth-types.ts@@ -6,6 +6,7 @@ export type TAttachTokenAuthDTO = {accessTokenMaxTTL: number;accessTokenNumUsesLimit: number;accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateTokenAuthDTO = {@@ -14,6 +15,7 @@ export type TUpdateTokenAuthDTO = {accessTokenMaxTTL?: number;accessTokenNumUsesLimit?: number;accessTokenTrustedIps?: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TGetTokenAuthDTO = {@@ -22,24 +24,29 @@ export type TGetTokenAuthDTO = {export type TRevokeTokenAuthDTO = {identityId: string;+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TCreateTokenAuthTokenDTO = {identityId: string;name?: string;+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TGetTokenAuthTokensDTO = {identityId: string;offset: number;limit: number;+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateTokenAuthTokenDTO = {tokenId: string;name?: string;+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TRevokeTokenAuthTokenDTO = {tokenId: string;+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.tsindex 078b50c082..848b536bab 100644--- a/backend/src/services/identity-ua/identity-ua-service.ts+++ b/backend/src/services/identity-ua/identity-ua-service.ts@@ -17,6 +17,7 @@ import { ActorType, AuthTokenType } from "../auth/auth-type";import { TIdentityOrgDALFactory } from "../identity/identity-org-dal";import { TIdentityAccessTokenDALFactory } from "../identity-access-token/identity-access-token-dal";import { TIdentityAccessTokenJwtPayload } from "../identity-access-token/identity-access-token-types";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityUaClientSecretDALFactory } from "./identity-ua-client-secret-dal";import { TIdentityUaDALFactory } from "./identity-ua-dal";import {@@ -150,8 +151,11 @@ export const identityUaServiceFactory = ({actorId,actorAuthMethod,actor,- actorOrgId+ actorOrgId,+ isActorSuperAdmin}: TAttachUaDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });diff --git a/backend/src/services/identity-ua/identity-ua-types.ts b/backend/src/services/identity-ua/identity-ua-types.tsindex 2045c21432..07b6a48101 100644--- a/backend/src/services/identity-ua/identity-ua-types.ts+++ b/backend/src/services/identity-ua/identity-ua-types.ts@@ -7,6 +7,7 @@ export type TAttachUaDTO = {accessTokenNumUsesLimit: number;clientSecretTrustedIps: { ipAddress: string }[];accessTokenTrustedIps: { ipAddress: string }[];+ isActorSuperAdmin?: boolean;} & Omit<TProjectPermission, "projectId">;export type TUpdateUaDTO = {diff --git a/backend/src/services/identity/identity-service.ts b/backend/src/services/identity/identity-service.tsindex 8ada2a5d1a..bd6c8d30c6 100644--- a/backend/src/services/identity/identity-service.ts+++ b/backend/src/services/identity/identity-service.ts@@ -9,6 +9,7 @@ import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/import { TIdentityProjectDALFactory } from "@app/services/identity-project/identity-project-dal";import { ActorType } from "../auth/auth-type";+import { validateIdentityUpdateForSuperAdminPrivileges } from "../super-admin/super-admin-fns";import { TIdentityDALFactory } from "./identity-dal";import { TIdentityMetadataDALFactory } from "./identity-metadata-dal";import { TIdentityOrgDALFactory } from "./identity-org-dal";@@ -112,8 +113,11 @@ export const identityServiceFactory = ({actorId,actorAuthMethod,actorOrgId,- metadata+ metadata,+ isActorSuperAdmin}: TUpdateIdentityDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(id, isActorSuperAdmin);+const identityOrgMembership = await identityOrgMembershipDAL.findOne({ identityId: id });if (!identityOrgMembership) throw new NotFoundError({ message: `Failed to find identity with id ${id}` });@@ -209,7 +213,16 @@ export const identityServiceFactory = ({return identity;};- const deleteIdentity = async ({ actorId, actor, actorOrgId, actorAuthMethod, id }: TDeleteIdentityDTO) => {+ const deleteIdentity = async ({+ actorId,+ actor,+ actorOrgId,+ actorAuthMethod,+ id,+ isActorSuperAdmin+ }: TDeleteIdentityDTO) => {+ await validateIdentityUpdateForSuperAdminPrivileges(id, isActorSuperAdmin);+const identityOrgMembership = await identityOrgMembershipDAL.findOne({ identityId: id });if (!identityOrgMembership) throw new NotFoundError({ message: `Failed to find identity with id ${id}` });diff --git a/backend/src/services/identity/identity-types.ts b/backend/src/services/identity/identity-types.tsindex 3f9e5c5239..0eca6b7ee1 100644--- a/backend/src/services/identity/identity-types.ts+++ b/backend/src/services/identity/identity-types.ts@@ -17,6 +17,7 @@ export type TUpdateIdentityDTO = {export type TDeleteIdentityDTO = {id: string;+ isActorSuperAdmin?: boolean;} & Omit<TOrgPermission, "orgId">;export type TGetIdentityByIdDTO = {diff --git a/backend/src/services/super-admin/super-admin-fns.ts b/backend/src/services/super-admin/super-admin-fns.tsindex b7c00dd44c..12ac0e7d79 100644--- a/backend/src/services/super-admin/super-admin-fns.ts+++ b/backend/src/services/super-admin/super-admin-fns.ts@@ -1,6 +1,8 @@+import { ForbiddenRequestError } from "@app/lib/errors";import { TAuthMode } from "@app/server/plugins/auth/inject-identity";import { ActorType } from "../auth/auth-type";+import { getServerCfg } from "./super-admin-service";export const isSuperAdmin = (auth: TAuthMode) => {if (auth.actor === ActorType.USER && auth.user.superAdmin) {@@ -13,3 +15,16 @@ export const isSuperAdmin = (auth: TAuthMode) => {return false;};++export const validateIdentityUpdateForSuperAdminPrivileges = async (+ identityId: string,+ isActorSuperAdmin?: boolean+) => {+ const serverCfg = await getServerCfg();+ if (serverCfg.adminIdentityIds?.includes(identityId) && !isActorSuperAdmin) {+ throw new ForbiddenRequestError({+ message:+ "You are attempting to modify an instance admin identity. This requires elevated instance admin privileges"+ });+ }+};