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
fix: renew token revocation missing interval
=f1de1726782a
diff --git a/backend/src/services/identity-access-token/identity-access-token-fns.ts b/backend/src/services/identity-access-token/identity-access-token-fns.tsindex 0236997213..c320a307c3 100644--- a/backend/src/services/identity-access-token/identity-access-token-fns.ts+++ b/backend/src/services/identity-access-token/identity-access-token-fns.ts@@ -56,7 +56,7 @@ export const verifyAccessTokenJwt = (accessToken: string): TIdentityAccessTokenJ// stable id we can rely on across both formats. Callers that need the live token// id read `decoded.jti ?? decoded.identityAccessTokenId`.const hasCoreTokenClaims = (decoded: TIdentityAccessTokenJwtPayload): decoded is TCoreTokenClaims =>- typeof decoded.iat === "number" && !!decoded.identityId && !!decoded.identityAccessTokenId;+ typeof decoded.iat === "number" && Boolean(decoded.identityId) && Boolean(decoded.identityAccessTokenId);// Baseline assertion shared by every JWT-consuming entry point (auth, renew,// revoke). Per-flow predicates narrow further.@@ -71,11 +71,11 @@ export const assertMinimalRenewClaims = (decoded: TIdentityAccessTokenJwtPayload// jti + org claims + TTL/period/creationEpoch budget anchors. Legacy tokens fail// this and fall through to loadLegacyTokenSource.export const hasFullRenewClaims = (decoded: TMinimalRenewClaims): decoded is TRenewableClaims =>- !!decoded.jti &&- !!decoded.orgId &&- !!decoded.rootOrgId &&- !!decoded.parentOrgId &&- !!decoded.authMethod &&+ Boolean(decoded.jti) &&+ Boolean(decoded.orgId) &&+ Boolean(decoded.rootOrgId) &&+ Boolean(decoded.parentOrgId) &&+ Boolean(decoded.authMethod) &&typeof decoded.accessTokenTTL === "number" &&typeof decoded.accessTokenMaxTTL === "number" &&typeof decoded.accessTokenPeriod === "number" &&diff --git a/backend/src/services/identity-access-token/identity-access-token-service.ts b/backend/src/services/identity-access-token/identity-access-token-service.tsindex e4fc6b074f..b6aa7a7c77 100644--- a/backend/src/services/identity-access-token/identity-access-token-service.ts+++ b/backend/src/services/identity-access-token/identity-access-token-service.ts@@ -435,7 +435,29 @@ export const identityAccessTokenServiceFactory = ({const decodedToken = assertRevocableClaims(verifyAccessTokenJwt(accessToken));const { identityId } = decodedToken;const tokenId = decodedToken.jti ?? decodedToken.identityAccessTokenId;- const expiresAt = new Date((decodedToken.exp ?? decodedToken.iat + appCfg.MAX_MACHINE_IDENTITY_TOKEN_AGE) * 1000);++ const source: TRenewSource = hasFullRenewClaims(decodedToken)+ ? {+ authMethod: decodedToken.authMethod,+ accessTokenTTL: decodedToken.accessTokenTTL,+ accessTokenMaxTTL: decodedToken.accessTokenMaxTTL,+ accessTokenPeriod: decodedToken.accessTokenPeriod,+ creationEpoch: decodedToken.creationEpoch,+ identityName: decodedToken.identityName ?? "",+ orgId: decodedToken.orgId,+ rootOrgId: decodedToken.rootOrgId,+ parentOrgId: decodedToken.parentOrgId,+ clientSecretId: decodedToken.clientSecretId,+ numUsesLimit: decodedToken.numUsesLimit ?? 0,+ identityAuth: decodedToken.identityAuth+ }+ : await loadLegacyTokenSource(decodedToken);++ const maxLifetimeSeconds =+ source.accessTokenMaxTTL > 0+ ? source.creationEpoch + source.accessTokenMaxTTL+ : Math.floor(Date.now() / 1000) + appCfg.MAX_MACHINE_IDENTITY_TOKEN_AGE;+ const expiresAt = new Date(maxLifetimeSeconds * 1000);await identityAccessTokenRevocationDAL.insertRevocation({id: tokenId,@@ -450,6 +472,7 @@ export const identityAccessTokenServiceFactory = ({// admin "revoke this token by id" flow). Caller computes the latest possible// exp and passes it as `expiresAt`; we skip the PG insert if it's already// in the past since no future JWT could be blocked by such a marker.+ // DON'T USE IT WITHOUT VALIDATIONconst markPerTokenRevocation = async ({tokenId,identityId,