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
metadata, formatting, and security fixes
x0322059a6bff3f52b2
diff --git a/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-factory.ts b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-factory.tsindex 756e884eb4..b524302352 100644--- a/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-factory.ts+++ b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-factory.ts@@ -163,6 +163,28 @@ const toSlugName = (name: string): string =>.replace(new RE2(/-+/g), "-").replace(new RE2(/^-|-$/g), "");+// Parses .NET JSON date format `/Date(ms)/` to ISO 8601 string+const parseDotNetDate = (value: string | null): string | undefined => {+ if (!value) return undefined;+ const match = new RE2(/^\/Date\((\d+)\)\/$/).exec(value);+ if (!match) return undefined;+ return new Date(Number(match[1])).toISOString();+};++// Converts a Windows FILETIME string (100-ns intervals since 1601-01-01) to ISO 8601 string+const fileTimeToIso = (filetime: string | undefined): string | undefined => {+ if (!filetime) return undefined;+ try {+ const value = BigInt(filetime);+ if (value === 0n) return undefined;+ const epochDiffMs = 11644473600000n;+ const ms = value / 10000n - epochDiffMs;+ return new Date(Number(ms)).toISOString();+ } catch {+ return undefined;+ }+};+const buildDomainDN = (domainFQDN: string): string => {return domainFQDN.split(".")@@ -280,11 +302,19 @@ const resolveDnsTcp = (hostname: string, port: number): Promise<string | null> =socket.write(query);});+ // Max legitimate DNS-over-TCP response: 2-byte length prefix + 65535 bytes payload+ const MAX_DNS_TCP_SIZE = 2 + 65535;let responseData = Buffer.alloc(0);socket.on("data", (chunk: Buffer) => {responseData = Buffer.concat([responseData, chunk]);+ if (responseData.length > MAX_DNS_TCP_SIZE) {+ socket.destroy();+ resolve(null);+ return;+ }+// DNS-over-TCP frames each message with a 2-byte big-endian length prefix// wait until we have the full frame before decodingif (responseData.length >= 2) {@@ -614,8 +644,8 @@ const upsertDomainAccount = async (userPrincipalName: user.userPrincipalName || undefined,servicePrincipalName,userAccountControl: user.userAccountControl ? parseInt(user.userAccountControl, 10) : undefined,- pwdLastSet: user.pwdLastSet || undefined,- lastLogonTimestamp: user.lastLogonTimestamp || undefined+ passwordLastSet: fileTimeToIso(user.pwdLastSet),+ lastLogon: fileTimeToIso(user.lastLogonTimestamp)} as TActiveDirectoryAccountInternalMetadata;const account = await pamAccountDAL.create(@@ -823,7 +853,11 @@ const upsertLocalAccount = async (});const internalMetadata = {- accountType: WindowsAccountType.User+ accountType: WindowsAccountType.User,+ lastLogon: parseDotNetDate(localUser.LastLogon),+ passwordLastSet: parseDotNetDate(localUser.PasswordLastSet),+ sid: localUser.SID?.Value || undefined,+ enabled: localUser.Enabled} as TWindowsAccountMetadata;const account = await pamAccountDAL.create(diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.tsindex 7bcda56d4f..7b2b7a062b 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts@@ -11,7 +11,8 @@ import {} from "@app/ee/services/permission/project-permission";import { DatabaseErrorCode } from "@app/lib/error-codes";import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";-import { ActorAuthMethod, ActorType, OrgServiceActor } from "@app/lib/types";+import { OrgServiceActor } from "@app/lib/types";+import { ActorAuthMethod, ActorType } from "@app/services/auth/auth-type";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { TGatewayV2DALFactory } from "../gateway-v2/gateway-v2-dal";@@ -660,7 +661,14 @@ export const pamDiscoverySourceServiceFactory = ({actorAuthMethod: ActorAuthMethod;actorOrgId: string;}) => {- await verifyAccountPermission(accountId, ProjectPermissionPamAccountActions.Read, actor, actorId, actorAuthMethod, actorOrgId);+ await verifyAccountPermission(+ accountId,+ ProjectPermissionPamAccountActions.Read,+ actor,+ actorId,+ actorAuthMethod,+ actorOrgId+ );return pamAccountDependenciesDAL.findByAccountId(accountId);};@@ -681,7 +689,14 @@ export const pamDiscoverySourceServiceFactory = ({actorAuthMethod: ActorAuthMethod;actorOrgId: string;}) => {- await verifyAccountPermission(accountId, ProjectPermissionPamAccountActions.Edit, actor, actorId, actorAuthMethod, actorOrgId);+ await verifyAccountPermission(+ accountId,+ ProjectPermissionPamAccountActions.Edit,+ actor,+ actorId,+ actorAuthMethod,+ actorOrgId+ );const dep = await pamAccountDependenciesDAL.findById(dependencyId);if (!dep || dep.accountId !== accountId) {@@ -705,7 +720,14 @@ export const pamDiscoverySourceServiceFactory = ({actorAuthMethod: ActorAuthMethod;actorOrgId: string;}) => {- await verifyAccountPermission(accountId, ProjectPermissionPamAccountActions.Delete, actor, actorId, actorAuthMethod, actorOrgId);+ await verifyAccountPermission(+ accountId,+ ProjectPermissionPamAccountActions.Delete,+ actor,+ actorId,+ actorAuthMethod,+ actorOrgId+ );const dep = await pamAccountDependenciesDAL.findById(dependencyId);if (!dep || dep.accountId !== accountId) {diff --git a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.tsindex a7d9bce832..3fbca12d26 100644--- a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts+++ b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts@@ -42,8 +42,8 @@ export const ActiveDirectoryAccountMetadataSchema = z.object({userPrincipalName: z.string().optional(),servicePrincipalName: z.string().array().optional(),userAccountControl: z.number().optional(),- pwdLastSet: z.string().optional(),- lastLogonTimestamp: z.string().optional()+ passwordLastSet: z.string().optional(),+ lastLogon: z.string().optional()});export const ActiveDirectoryResourceSchema = BaseActiveDirectoryResourceSchema.extend({diff --git a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-schemas.ts b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-schemas.tsindex 71cf29945b..bf6b4c8f52 100644--- a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-schemas.ts+++ b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-schemas.ts@@ -36,7 +36,11 @@ export const WindowsAccountCredentialsSchema = z.object({// Account metadataexport const WindowsAccountMetadataSchema = z.object({- accountType: z.nativeEnum(WindowsAccountType)+ accountType: z.nativeEnum(WindowsAccountType),+ lastLogon: z.string().optional(),+ passwordLastSet: z.string().optional(),+ sid: z.string().optional(),+ enabled: z.boolean().optional()});// Resource Metadatadiff --git a/frontend/src/hooks/api/pam/types/active-directory-resource.ts b/frontend/src/hooks/api/pam/types/active-directory-resource.tsindex 1f090a0040..88df2122ae 100644--- a/frontend/src/hooks/api/pam/types/active-directory-resource.ts+++ b/frontend/src/hooks/api/pam/types/active-directory-resource.ts@@ -22,8 +22,8 @@ export type TActiveDirectoryAccountInternalMetadata = {accountType: ActiveDirectoryAccountType;adGuid?: string;userPrincipalName?: string;- pwdLastSet?: string;- lastLogonTimestamp?: string;+ passwordLastSet?: string;+ lastLogon?: string;};// Resourcesdiff --git a/frontend/src/hooks/api/pam/types/windows-server-resource.ts b/frontend/src/hooks/api/pam/types/windows-server-resource.tsindex b8d6728dcc..b2ab6c7098 100644--- a/frontend/src/hooks/api/pam/types/windows-server-resource.ts+++ b/frontend/src/hooks/api/pam/types/windows-server-resource.ts@@ -24,6 +24,10 @@ export type TWindowsCredentials = {export type TWindowsAccountMetadata = {accountType: WindowsAccountType;+ lastLogon?: string;+ passwordLastSet?: string;+ sid?: string;+ enabled?: boolean;};// Resourcesdiff --git a/frontend/src/hooks/api/pamDiscovery/types.ts b/frontend/src/hooks/api/pamDiscovery/types.tsindex 88728ffdd5..2ff8411afb 100644--- a/frontend/src/hooks/api/pamDiscovery/types.ts+++ b/frontend/src/hooks/api/pamDiscovery/types.ts@@ -87,7 +87,7 @@ export type TDiscoveredAccountMetadata = {adGuid?: string;displayName?: string;userPrincipalName?: string;- lastLogonTimestamp?: string;+ lastLogon?: string;};export type TDiscoveredAccount = {diff --git a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountPropertiesSection.tsx b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountPropertiesSection.tsxindex fa97d98614..a695937f61 100644--- a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountPropertiesSection.tsx+++ b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountPropertiesSection.tsx@@ -9,17 +9,12 @@ import {UnstableIconButton,UnstableInput} from "@app/components/v3";-import { PamResourceType, TActiveDirectoryAccount, TPamAccount } from "@app/hooks/api/pam";--// Converts a Windows FILETIME (100-nanosecond intervals since 1601-01-01) to a JS Date.-const windowsFileTimeToDate = (filetime: string): Date | null => {- const value = BigInt(filetime);- if (value === 0n) return null;-- const epochDiffMs = 11644473600000n;- const ms = value / 10000n - epochDiffMs;- return new Date(Number(ms));-};+import {+ PamResourceType,+ TActiveDirectoryAccount,+ TPamAccount,+ TWindowsAccount+} from "@app/hooks/api/pam";const CopyableField = ({ label, value }: { label: string; value: string }) => {const handleCopy = () => {@@ -48,7 +43,7 @@ const CopyableField = ({ label, value }: { label: string; value: string }) => {type TPropertyField = {label: string;value: string;- type?: "text" | "date";+ type?: "text" | "date" | "plain";};const getAccountProperties = (account: TPamAccount): TPropertyField[] => {@@ -63,17 +58,42 @@ const getAccountProperties = (account: TPamAccount): TPropertyField[] => {if (internalMetadata.adGuid) {fields.push({ label: "AD GUID", value: internalMetadata.adGuid });}- if (internalMetadata.pwdLastSet) {- const date = windowsFileTimeToDate(internalMetadata.pwdLastSet);- if (date) {- fields.push({ label: "Password Last Set", value: date.toISOString(), type: "date" });- }+ if (internalMetadata.passwordLastSet) {+ fields.push({+ label: "Password Last Set",+ value: internalMetadata.passwordLastSet,+ type: "date"+ });}- if (internalMetadata.lastLogonTimestamp) {- const date = windowsFileTimeToDate(internalMetadata.lastLogonTimestamp);- if (date) {- fields.push({ label: "Last Logon", value: date.toISOString(), type: "date" });- }+ if (internalMetadata.lastLogon) {+ fields.push({ label: "Last Logon", value: internalMetadata.lastLogon, type: "date" });+ }++ return fields;+ }+ case PamResourceType.Windows: {+ const { internalMetadata } = account as TWindowsAccount;+ const fields: TPropertyField[] = [];++ if (internalMetadata.sid) {+ fields.push({ label: "SID", value: internalMetadata.sid });+ }+ if (internalMetadata.enabled !== undefined) {+ fields.push({+ label: "Enabled",+ value: internalMetadata.enabled ? "Yes" : "No",+ type: "plain"+ });+ }+ if (internalMetadata.passwordLastSet) {+ fields.push({+ label: "Password Last Set",+ value: internalMetadata.passwordLastSet,+ type: "date"+ });+ }+ if (internalMetadata.lastLogon) {+ fields.push({ label: "Last Logon", value: internalMetadata.lastLogon, type: "date" });}return fields;@@ -97,16 +117,25 @@ export const PamAccountPropertiesSection = ({ account }: Props) => {<div className="border-b border-border pb-2"><h3 className="text-lg font-medium">Properties</h3></div>- {properties.map((property) =>- property.type === "date" ? (- <Detail key={property.label}>- <DetailLabel>{property.label}</DetailLabel>- <DetailValue>{format(new Date(property.value), "MM/dd/yyyy, hh:mm a")}</DetailValue>- </Detail>- ) : (- <CopyableField key={property.label} label={property.label} value={property.value} />- )- )}+ {properties.map((property) => {+ if (property.type === "date") {+ return (+ <Detail key={property.label}>+ <DetailLabel>{property.label}</DetailLabel>+ <DetailValue>{format(new Date(property.value), "MM/dd/yyyy, hh:mm a")}</DetailValue>+ </Detail>+ );+ }+ if (property.type === "plain") {+ return (+ <Detail key={property.label}>+ <DetailLabel>{property.label}</DetailLabel>+ <DetailValue>{property.value}</DetailValue>+ </Detail>+ );+ }+ return <CopyableField key={property.label} label={property.label} value={property.value} />;+ })}</div>);};diff --git a/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsx b/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsxindex 5257caed92..3b5c8afb89 100644--- a/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsx+++ b/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsx@@ -230,12 +230,10 @@ const formatDuration = (startedAt?: string | null, completedAt?: string | null):return secs > 0 ? `${mins}m ${secs}s` : `${mins}m`;};-const formatWindowsFileTime = (fileTime?: string): string => {- if (!fileTime) return "-";+const formatIsoDate = (isoDate?: string): string => {+ if (!isoDate) return "-";try {- const ms = Number(BigInt(fileTime) / 10000n - 11644473600000n);- if (Number.isNaN(ms) || ms <= 0) return "-";- return format(new Date(ms), "MM/dd/yy, HH:mm");+ return format(new Date(isoDate), "MM/dd/yy, HH:mm");} catch {return "-";}@@ -814,7 +812,7 @@ const AccountsTab = ({{account.dependencyCount ?? 0}</UnstableTableCell><UnstableTableCell className="text-muted">- {formatWindowsFileTime(account.internalMetadata?.lastLogonTimestamp)}+ {formatIsoDate(account.internalMetadata?.lastLogon)}</UnstableTableCell><UnstableTableCell className="text-muted">{format(new Date(account.lastDiscoveredAt), "MM/dd/yy, HH:mm")}