Skip to content

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

remove from token minting endpoints

Thiago Araujo da Silva36b37ebc4d0f
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index b3261b0c9d..d0c05a979a 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -186,6 +186,12 @@ Auth extraction happens in `src/server/plugins/auth/`:
- five org routes held back individually and commented as such: `GET /v1/organization`,
`GET /v1/organization/accessible-with-sub-orgs`, `POST /v2/organization`, `GET /v1/organization/:organizationId`,
`DELETE /v2/organization/:organizationId`
+ - **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
+ (`POST /v2/service-token`), KMIP client certificates (`POST /v1/kmip/clients/:id/certificates`), and the
+ gateway / relay / KMIP-server enrollment tokens (`POST .../token-auth/generate-enrollment-token`). See
+ below.
Rough proxy: nothing passing `requireOrg: false` accepts `AuthMode.OAUTH`, since with no org there's no
ability to narrow. Before adding `AuthMode.OAUTH` to a route, check the handler actually builds an
@@ -201,6 +207,16 @@ Auth extraction happens in `src/server/plugins/auth/`:
no subject, any member with an identity token can already call it, and a gate would change first-party
behaviour. Weigh a route in this position on what it returns.
+ **A route that mints a credential can't accept a delegated one either.** Everything the revocation story
+ rests on (deleting the application, rotating its secret, withdrawing its grant, deactivating the user)
+ reaches only the OAuth sessions tagged with `getOauthClientSessionUserAgent`. An identity access token, a
+ universal-auth client secret, a service token, a KMIP client certificate, or a redeemed enrollment token is
+ a separate row with its own lifetime, so a compromised client could mint one (token auth accepts a TTL of
+ years) and keep the access after every handle we have on it is pulled. The credential also outranks its
+ minter: it authenticates as a machine identity whose permissions no OAuth scope intersects. This is why
+ credential issuance is on the exception list above regardless of how well the route builds its permission,
+ and why a new issuance route starts first-party only.
+
**A route that mints session tokens can't accept a delegated one.** `DELETE /v2/organization/:organizationId`
deletes the org the caller's token points at, so it reissues the user's session through
`loginService.generateUserTokens` and returns it. `generateUserTokens` has no oauthClientId, scopes or
diff --git a/backend/src/ee/routes/v1/kmip-router.ts b/backend/src/ee/routes/v1/kmip-router.ts
index d48c13655a..15a5423aeb 100644
--- a/backend/src/ee/routes/v1/kmip-router.ts
+++ b/backend/src/ee/routes/v1/kmip-router.ts
@@ -312,7 +312,7 @@ export const registerKmipRouter = 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 certificate = await server.services.kmip.createKmipClientCertificate({
actor: req.permission.type,
diff --git a/backend/src/ee/routes/v1/kmip-server-router.ts b/backend/src/ee/routes/v1/kmip-server-router.ts
index e5e2104f29..0b879777de 100644
--- a/backend/src/ee/routes/v1/kmip-server-router.ts
+++ b/backend/src/ee/routes/v1/kmip-server-router.ts
@@ -317,7 +317,7 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {
200: z.object({ token: z.string(), expiresAt: z.date() })
}
},
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
const result = await server.services.resourceAuthMethod.mintToken({
resource: { type: "kmip", id: req.params.kmipServerId },
diff --git a/backend/src/ee/routes/v2/relay-router.ts b/backend/src/ee/routes/v2/relay-router.ts
index 155d897efd..5f9ae577f2 100644
--- a/backend/src/ee/routes/v2/relay-router.ts
+++ b/backend/src/ee/routes/v2/relay-router.ts
@@ -264,7 +264,7 @@ export const registerRelayV2Router = async (server: FastifyZodProvider) => {
200: z.object({ token: z.string(), expiresAt: z.date() })
}
},
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
const result = await server.services.resourceAuthMethod.mintToken({
resource: { type: "relay", id: req.params.relayId },
diff --git a/backend/src/ee/routes/v3/gateway-router.ts b/backend/src/ee/routes/v3/gateway-router.ts
index e97004ba14..5b645c7f51 100644
--- a/backend/src/ee/routes/v3/gateway-router.ts
+++ b/backend/src/ee/routes/v3/gateway-router.ts
@@ -360,7 +360,7 @@ export const registerGatewayV3Router = 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 result = await server.services.resourceAuthMethod.mintToken({
resource: { type: "gateway", id: req.params.gatewayId },
diff --git a/backend/src/server/routes/v1/identity-token-auth-router.ts b/backend/src/server/routes/v1/identity-token-auth-router.ts
index ae438564d1..3f67ea4cd2 100644
--- a/backend/src/server/routes/v1/identity-token-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-token-auth-router.ts
@@ -346,7 +346,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
config: {
rateLimit: writeLimit
},
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: {
hide: false,
operationId: "createTokenAuthToken",
diff --git a/backend/src/server/routes/v1/identity-universal-auth-router.ts b/backend/src/server/routes/v1/identity-universal-auth-router.ts
index 933d8f9ae7..a07e187a41 100644
--- a/backend/src/server/routes/v1/identity-universal-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-universal-auth-router.ts
@@ -542,7 +542,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
config: {
rateLimit: writeLimit
},
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: {
hide: false,
operationId: "createUniversalAuthClientSecret",
diff --git a/backend/src/server/routes/v2/service-token-router.ts b/backend/src/server/routes/v2/service-token-router.ts
index c52eccf87e..d9636c08f5 100644
--- a/backend/src/server/routes/v2/service-token-router.ts
+++ b/backend/src/server/routes/v2/service-token-router.ts
@@ -82,7 +82,7 @@ export const registerServiceTokenRouter = async (server: FastifyZodProvider) =>
config: {
rateLimit: writeLimit
},
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.OAUTH]),
+ onRequest: verifyAuth([AuthMode.JWT]),
schema: {
operationId: "createServiceToken",
body: z.object({
diff --git a/docs/documentation/platform/oauth-token-exchange.mdx b/docs/documentation/platform/oauth-token-exchange.mdx
index b637f3e410..2d8321230b 100644
--- a/docs/documentation/platform/oauth-token-exchange.mdx
+++ b/docs/documentation/platform/oauth-token-exchange.mdx
@@ -56,10 +56,11 @@ Structurally, this is your organization's OIDC sign-in with the token handed ove
The issued token carries the user's **full effective permissions**, not a narrowed subset. There is no consent screen and no scope list: an organization admin approves the delegation once, when registering the application.
-Three things it deliberately cannot do:
+Four things it deliberately cannot do:
- **Manage the user's account.** Changing MFA, revoking sessions, and other account self-management actions are never reachable with a delegated token.
- **Create or delete an organization.** Both require the user's own sign-in, so a delegated token is rejected on those endpoints even when the user is an organization admin.
+- **Mint 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.
- **Outlive its access token.** No refresh token is issued, so your middleware exchanges again against the still-valid identity provider token.
<Warning>