Skip to content

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

fix: qualify ambiguous id column in legacy token lookup

Tre Dubravac6b7533e9b1f
diff --git a/backend/src/services/identity-access-token/identity-access-token-service.test.ts b/backend/src/services/identity-access-token/identity-access-token-service.test.ts
index 0bb6908c1d..0060b12a0e 100644
--- a/backend/src/services/identity-access-token/identity-access-token-service.test.ts
+++ b/backend/src/services/identity-access-token/identity-access-token-service.test.ts
@@ -1,6 +1,6 @@
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
-import { IdentityAuthMethod } from "@app/db/schemas";
+import { IdentityAuthMethod, TableName } from "@app/db/schemas";
import { crypto } from "@app/lib/crypto";
import { IPType, TIp } from "@app/lib/ip";
@@ -454,7 +454,9 @@ describe("identityAccessTokenServiceFactory", () => {
rootOrgId: "org-id",
parentOrgId: "org-id"
});
- expect(identityAccessTokenDAL.findOne).toHaveBeenCalledWith({ id: "legacy-token-id" });
+ expect(identityAccessTokenDAL.findOne).toHaveBeenCalledWith({
+ [`${TableName.IdentityAccessToken}.id`]: "legacy-token-id"
+ });
expect(orgDAL.findEffectiveOrgMembership).toHaveBeenCalledWith({
actorType: "identity",
actorId: "identity-id",
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.ts
index 1a6425c033..e4fc6b074f 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
@@ -1,6 +1,6 @@
import { Knex } from "knex";
-import { IdentityAuthMethod, OrgMembershipStatus, TIdentityAccessTokens } from "@app/db/schemas";
+import { IdentityAuthMethod, OrgMembershipStatus, TableName, TIdentityAccessTokens } from "@app/db/schemas";
import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto";
@@ -208,7 +208,11 @@ export const identityAccessTokenServiceFactory = ({
// the lazy-insert model and always have a row; revoked or missing rows mean
// the token can't be safely upgraded. Auth uses a subset of these fields.
const loadLegacyTokenSource = async (decoded: TMinimalRenewClaims): Promise<TRenewSource> => {
- const row = await identityAccessTokenDAL.findOne({ id: decoded.identityAccessTokenId });
+ // Qualify the column — the DAL joins with Identity which also has an `id`,
+ // so an unprefixed filter is ambiguous and the DB rejects the query.
+ const row = await identityAccessTokenDAL.findOne({
+ [`${TableName.IdentityAccessToken}.id` as "id"]: decoded.identityAccessTokenId
+ });
if (!row || row.isAccessTokenRevoked) {
throw new UnauthorizedError({ message: "Cannot renew revoked or unknown access token" });
}