Skip to content

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

address reviews

x484ab9c00646
diff --git a/backend/src/ee/services/pam-discovery/pam-discovered-account-dal.ts b/backend/src/ee/services/pam-discovery/pam-discovered-account-dal.ts
index 610dd5fd7a..78d90c3b9e 100644
--- a/backend/src/ee/services/pam-discovery/pam-discovered-account-dal.ts
+++ b/backend/src/ee/services/pam-discovery/pam-discovered-account-dal.ts
@@ -34,7 +34,8 @@ export const pamDiscoveredAccountDALFactory = (db: TDbClient) => {
const baseQuery = db
.replicaNode()(TableName.PamDiscoveredAccount)
.where({ discoverySourceId })
- .whereNull("importedAccountId");
+ .whereNull("importedAccountId")
+ .where("isStale", false);
if (search) void baseQuery.andWhere("name", "ilike", `%${sanitizeSqlLikeString(search)}%`);
const countQuery = baseQuery.clone().clearSelect().count("id as count").first<{ count: string }>();
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index 3ef07a8487..e1637be315 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -425,10 +425,6 @@ export const pamSessionServiceFactory = ({
}) => {
const account = await resolveAccountByPath(projectId, path);
- if (account.isStale) {
- throw new ForbiddenRequestError({ message: "This account is no longer available in the environment" });
- }
-
const policy = resolveAccessControls(account.templatePolicies);
const { requiresApproval } = policy;
@@ -442,6 +438,10 @@ export const pamSessionServiceFactory = ({
actor
);
+ if (account.isStale) {
+ throw new ForbiddenRequestError({ message: "This account is no longer available in the environment" });
+ }
+
const trimmedReason = reason?.trim() || null;
if (policy.requireMfa) {
diff --git a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
index 7065dcd626..f6ab1cdf57 100644
--- a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
+++ b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts
@@ -167,10 +167,6 @@ export const pamWebAccessServiceFactory = ({
throw new NotFoundError({ message: `Account with ID '${accountId}' not found` });
}
- if (account.isStale) {
- throw new ForbiddenRequestError({ message: "This account is no longer available in the environment" });
- }
-
if (!SESSION_HANDLERS[account.accountType as PamAccountType]) {
throw new BadRequestError({ message: "Web access is not supported for this account type" });
}
@@ -194,6 +190,10 @@ export const pamWebAccessServiceFactory = ({
}
);
+ if (account.isStale) {
+ throw new ForbiddenRequestError({ message: "This account is no longer available in the environment" });
+ }
+
let grantRemainingMs: number | null = null;
if (requiresApproval) {
const grant = await pamAccessRequestService.checkGrant({
diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx
index 235ad8b4aa..d7350de420 100644
--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx
@@ -406,6 +406,9 @@ export const DiscoverySourceDetailSheet = ({ isOpen, sourceId, onOpenChange }: P
queryClient.invalidateQueries({
queryKey: [...pamKeys.discovery(), "discovered", sourceId ?? ""]
});
+ queryClient.invalidateQueries({
+ queryKey: [...pamKeys.discovery(), "unavailable", sourceId ?? ""]
+ });
// A scan reconciles dependencies onto managed accounts, so refresh account views (their dependency
// lists are keyed under pamKeys.account()) which the discovery scan otherwise never invalidates.
queryClient.invalidateQueries({ queryKey: pamKeys.account() });