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
remove sub org as well
Thiago Araujo da Silva874157809d32
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 267e088a74..41f39f9207 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -181,11 +181,20 @@ Auth extraction happens in `src/server/plugins/auth/`:- account self-management (user, password, MFA, sessions, login, signup, notifications, announcements)- super-admin routes (`v1/admin-router.ts`, `ee/v1/rate-limit-router.ts`), gated by `verifySuperAdmin`,which reads `user.superAdmin` rather than a CASL ability- - OAuth client CRUD + consent (`v1/oauth-router.ts`) and `ee/v1/assume-privilege-router.ts`, where a- delegated token could widen its own grant- - five org routes held back individually and commented as such: `GET /v1/organization`,- `GET /v1/organization/accessible-with-sub-orgs`, `POST /v2/organizations`, `GET /v1/organization/:organizationId`,- `DELETE /v2/organizations/:organizationId`+ - OAuth client CRUD + consent (`v1/oauth-router.ts`), `ee/v1/assume-privilege-router.ts`, and+ `POST /v1/organization-admin/projects/:projectId/grant-admin-access`, where a delegated token could+ widen its own grant. The last one is the durable half of privilege assumption: it checks a CASL+ ability, so scopes do narrow it, but it writes the caller a permanent project-admin membership that+ outlives the delegation, so revoking the application does not take the access back+ - **creating or deleting an organization**, parent or sub, held back individually and commented as such:+ `POST /v2/organizations`, `DELETE /v2/organizations/:organizationId`, `POST /v1/sub-orgs`,+ `DELETE /v1/sub-orgs/:subOrgId`. Updating a sub-org and managing its memberships stay open — it is+ creation and deletion that a delegation should not reach+ - the org reads that return more than the token's org, held back individually and commented as such:+ `GET /v1/organization`, `GET /v1/organization/accessible-with-sub-orgs`,+ `GET /v1/organization/:organizationId`+ - `POST /v2/organizations/privilege-system-upgrade`, which gates on `hasRole(Admin)` rather than a CASL+ ability and one-way-switches the org's whole privilege model- **every route that mints a long-lived credential**, each commented as such: identity token-auth tokens(`POST /v1/auth/token-auth/identities/:identityId/tokens`), universal-auth client secrets(`POST /v1/auth/universal-auth/identities/:identityId/client-secrets`), service tokens@@ -201,7 +210,10 @@ Auth extraction happens in `src/server/plugins/auth/`:calls `getOrgPermission`/`getProjectPermission` and throws the ability away is using it as a membershipgate: the intersection with granted scopes happens inside, but nothing reads the result, so a scopedtoken passes like a first-party session. That's why `GET /v1/organization/:organizationId` came back off- the list. The membership-only reads that keep `AuthMode.OAUTH` return project metadata a secrets client+ the list. Gating on `hasRole(...)` from the same return value has the same problem and is easier to miss,+ since it reads like an authorization check: the role comes from the actor's memberships, not from the+ narrowed ability, so no scope ever touches it. That's why `POST /v2/organizations/privilege-system-upgrade`+ is first-party. The membership-only reads that keep `AuthMode.OAUTH` return project metadata a secrets clientneeds to operate rather than org or security config: `getAProject` (clients resolve environment slugsbefore reading secrets) and `getProjectKmsKeys`. A CASL gate isn't the fix there, since the operation hasno subject, any member with an identity token can already call it, and a gate would change first-partydiff --git a/backend/src/ee/routes/v1/sub-org-router.ts b/backend/src/ee/routes/v1/sub-org-router.tsindex 0b88d90246..4a419b2154 100644--- a/backend/src/ee/routes/v1/sub-org-router.ts+++ b/backend/src/ee/routes/v1/sub-org-router.ts@@ -49,7 +49,7 @@ export const registerSubOrgRouter = async (server: FastifyZodProvider) => {})}},- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {const { organization } = await server.services.subOrganization.createSubOrg({name: req.body.name,@@ -270,7 +270,7 @@ export const registerSubOrgRouter = async (server: FastifyZodProvider) => {})}},- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {const { organization } = await server.services.subOrganization.deleteSubOrg({subOrgId: req.params.subOrgId,diff --git a/backend/src/server/config/rateLimiter.ts b/backend/src/server/config/rateLimiter.tsindex e373c9d3b0..536238fb2d 100644--- a/backend/src/server/config/rateLimiter.ts+++ b/backend/src/server/config/rateLimiter.ts@@ -54,13 +54,6 @@ export const authRateLimit: RateLimitOptions = {keyGenerator: (req) => req.realIp};-export const oauthTokenLimit: RateLimitOptions = {- timeWindow: 60 * 1000,- hook: "preValidation",- max: (req) => req.rateLimits.writeLimit,- keyGenerator: (req) => req.realIp-};-export const inviteUserRateLimit: RateLimitOptions = {timeWindow: 60 * 1000,hook: "preValidation",diff --git a/backend/src/server/routes/v1/oauth-router.ts b/backend/src/server/routes/v1/oauth-router.tsindex a81a5287f3..fadfb7ac79 100644--- a/backend/src/server/routes/v1/oauth-router.ts+++ b/backend/src/server/routes/v1/oauth-router.ts@@ -3,7 +3,7 @@ import { z } from "zod";import { OauthClientsSchema } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { BadRequestError } from "@app/lib/errors";-import { authRateLimit, oauthTokenLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter";+import { authRateLimit, 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 { isAllowedRedirectUri, parseBasicAuthHeader } from "@app/services/oauth-client/oauth-client-fns";@@ -410,7 +410,7 @@ export const registerOAuthRouter = async (server: FastifyZodProvider) => {method: "POST",url: "/token",config: {- rateLimit: oauthTokenLimit+ rateLimit: authRateLimit},schema: {body: z.object({diff --git a/backend/src/server/routes/v1/org-admin-router.ts b/backend/src/server/routes/v1/org-admin-router.tsindex 9e60d22364..adf06f9b42 100644--- a/backend/src/server/routes/v1/org-admin-router.ts+++ b/backend/src/server/routes/v1/org-admin-router.ts@@ -62,7 +62,7 @@ export const registerOrgAdminRouter = async (server: FastifyZodProvider) => {})}},- onRequest: verifyAuth([AuthMode.JWT, AuthMode.OAUTH]),+ onRequest: verifyAuth([AuthMode.JWT]),handler: async (req) => {const { membership } = await server.services.orgAdmin.grantProjectAdminAccess({actorOrgId: req.permission.orgId,diff --git a/backend/src/server/routes/v2/organization-router.ts b/backend/src/server/routes/v2/organization-router.tsindex 85cbbdd4f6..7cfe1b069d 100644--- a/backend/src/server/routes/v2/organization-router.ts+++ b/backend/src/server/routes/v2/organization-router.ts@@ -514,7 +514,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {})}},- onRequest: verifyAuth([AuthMode.JWT, AuthMode.OAUTH]),+ onRequest: verifyAuth([AuthMode.JWT]),handler: async (req) => {const organization = await server.services.org.upgradePrivilegeSystem({actorId: req.permission.id,diff --git a/docs/documentation/platform/oauth-applications/token-exchange.mdx b/docs/documentation/platform/oauth-applications/token-exchange.mdxindex d183166432..34ab4648fd 100644--- a/docs/documentation/platform/oauth-applications/token-exchange.mdx+++ b/docs/documentation/platform/oauth-applications/token-exchange.mdx@@ -61,9 +61,9 @@ The issued token carries the user's **full effective permissions**, not a narrowThe token works across the Infisical API wherever the user's own permissions allow, with four deliberate exceptions:- **Managing the user's account.** Password, MFA, session, and notification endpoints are never reachable with a delegated token.-- **Creating or deleting an organization.** Both require the user's own sign-in, so a delegated token is rejected even when the user is an organization admin.+- **Creating or deleting an organization**, including a sub-organization. All four require the user's own sign-in, so a delegated token is rejected even when the user is an organization admin. Updating an organization and managing its members stay available.- **Minting another credential.** Machine identity tokens and client secrets, service tokens, KMIP client certificates, and gateway or relay enrollment tokens all outlive the delegation that created them, so those endpoints stay first-party. Revoking this application has to revoke everything it obtained.-- **Widening its own access.** Managing OAuth applications, instance admin settings, and privilege assumption stay first-party.+- **Widening its own access.** Managing OAuth applications, instance admin settings, upgrading the organization's privilege system, and both forms of privilege assumption stay first-party. That includes an organization admin granting themselves access to a project they are not a member of, because the membership it writes outlives the delegation that asked for it.No refresh token is issued. When the access token expires, your middleware exchanges again against the still-valid identity provider token.