Skip to content

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

feat: remove pam assumer role

Sheen Capadngan8db7c36289ea
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.ts
index 6b22e01ff4..239c550702 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -531,20 +531,13 @@ export const ACCOUNT_TYPE_CONFIGS = {
connectionDetails: z.object({
roleArn: z.string().trim().min(1).max(2048)
}),
- credentials: z.object({
- targetRoleArn: z.string().trim().min(1).max(2048)
- }),
- sanitizedCredentials: z.object({
- targetRoleArn: z.string().optional()
- }),
+ credentials: z.object({}),
+ sanitizedCredentials: z.object({}),
ui: {
roleArn: {
- label: "PAM Role ARN",
- tooltip: "The ARN of the IAM role that Infisical assumes to broker access to the target role."
- },
- targetRoleArn: {
- label: "Target Role ARN",
- tooltip: "The ARN of the IAM role the user will assume when accessing this account."
+ label: "Role ARN",
+ tooltip:
+ "The ARN of the IAM role Infisical assumes when accessing this account. Its trust policy must allow Infisical using your Infisical Organization ID as the External ID.\n\nOrganization ID: {{organizationId}}"
}
}
}
diff --git a/backend/src/ee/services/pam-session/aws-iam/aws-iam-federation.ts b/backend/src/ee/services/pam-session/aws-iam/aws-iam-federation.ts
index 1062c2769e..1adbf7c430 100644
--- a/backend/src/ee/services/pam-session/aws-iam/aws-iam-federation.ts
+++ b/backend/src/ee/services/pam-session/aws-iam/aws-iam-federation.ts
@@ -10,7 +10,7 @@ export const AWS_STS_MIN_DURATION_SECONDS = 900;
const AWS_STS_DEFAULT_REGION = "us-east-1";
-const createStsClient = (credentials?: Credentials): STSClient => {
+const createStsClient = (): STSClient => {
const appCfg = getConfig();
const config: STSClientConfig = {
@@ -19,13 +19,7 @@ const createStsClient = (credentials?: Credentials): STSClient => {
sha256: CustomAWSHasher
};
- if (credentials) {
- config.credentials = {
- accessKeyId: credentials.AccessKeyId!,
- secretAccessKey: credentials.SecretAccessKey!,
- sessionToken: credentials.SessionToken
- };
- } else if (appCfg.PAM_AWS_ACCESS_KEY_ID && appCfg.PAM_AWS_SECRET_ACCESS_KEY) {
+ if (appCfg.PAM_AWS_ACCESS_KEY_ID && appCfg.PAM_AWS_SECRET_ACCESS_KEY) {
config.credentials = {
accessKeyId: appCfg.PAM_AWS_ACCESS_KEY_ID,
secretAccessKey: appCfg.PAM_AWS_SECRET_ACCESS_KEY
@@ -35,64 +29,34 @@ const createStsClient = (credentials?: Credentials): STSClient => {
return new STSClient(config);
};
-const assumePamRole = async ({
- connectionDetails,
- projectId,
- sessionDuration = AWS_STS_MIN_DURATION_SECONDS,
- sessionNameSuffix = "validation"
-}: {
- connectionDetails: { roleArn: string };
- projectId: string;
- sessionDuration?: number;
- sessionNameSuffix?: string;
-}): Promise<Credentials> => {
- const stsClient = createStsClient();
-
- const result = await stsClient.send(
- new AssumeRoleCommand({
- RoleArn: connectionDetails.roleArn,
- RoleSessionName: `infisical-pam-${sessionNameSuffix}-${Date.now()}`,
- DurationSeconds: sessionDuration,
- ExternalId: projectId
- })
- );
-
- if (!result.Credentials) {
- throw new InternalServerError({
- message: "Failed to assume PAM role - AWS STS did not return credentials"
- });
- }
-
- return result.Credentials;
-};
-
-const assumeTargetRole = async ({
- pamCredentials,
- targetRoleArn,
- projectId,
+// Infisical assumes the account's role directly (single hop). The role's trust policy must allow
+// Infisical's AWS account with the org's Infisical ID as the External ID (confused-deputy guard).
+const assumeRole = async ({
+ roleArn,
+ externalId,
roleSessionName,
sessionDuration = AWS_STS_MIN_DURATION_SECONDS
}: {
- pamCredentials: Credentials;
- targetRoleArn: string;
- projectId: string;
+ roleArn: string;
+ externalId: string;
roleSessionName: string;
sessionDuration?: number;
}): Promise<Credentials> => {
- const chainedStsClient = createStsClient(pamCredentials);
+ const stsClient = createStsClient();
- const result = await chainedStsClient.send(
+ const result = await stsClient.send(
new AssumeRoleCommand({
- RoleArn: targetRoleArn,
+ RoleArn: roleArn,
RoleSessionName: roleSessionName,
DurationSeconds: sessionDuration,
- ExternalId: projectId
+ ExternalId: externalId
})
);
if (!result.Credentials) {
throw new BadRequestError({
- message: "Failed to assume target role - verify the target role trust policy allows the PAM role to assume it"
+ message:
+ "Failed to assume role - verify the role's trust policy allows Infisical using your Infisical Organization ID as the External ID"
});
}
@@ -107,34 +71,24 @@ export type TAwsIamSessionCredentials = {
};
export const generateAwsIamSessionCredentials = async ({
- connectionDetails,
- targetRoleArn,
+ roleArn,
+ externalId,
roleSessionName,
- projectId,
sessionDuration
}: {
- connectionDetails: { roleArn: string };
- targetRoleArn: string;
+ roleArn: string;
+ externalId: string;
roleSessionName: string;
- projectId: string;
sessionDuration: number;
}): Promise<TAwsIamSessionCredentials> => {
- const pamCredentials = await assumePamRole({
- connectionDetails,
- projectId,
- sessionDuration,
- sessionNameSuffix: "session"
- });
-
- const targetCredentials = await assumeTargetRole({
- pamCredentials,
- targetRoleArn,
- projectId,
+ const credentials = await assumeRole({
+ roleArn,
+ externalId,
roleSessionName,
sessionDuration
});
- const { AccessKeyId, SecretAccessKey, SessionToken, Expiration } = targetCredentials;
+ const { AccessKeyId, SecretAccessKey, SessionToken, Expiration } = credentials;
if (!AccessKeyId || !SecretAccessKey || !SessionToken) {
throw new InternalServerError({
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 663ca8a514..3bc9468ee8 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -560,13 +560,14 @@ export const pamSessionServiceFactory = ({
}
const rawConnectionDetails = await decrypt(projectId, account.encryptedConnectionDetails);
- const rawCredentials = await decrypt(projectId, account.encryptedCredentials);
+ const roleArn = rawConnectionDetails.roleArn as string;
const stsCredentials = await generateAwsIamSessionCredentials({
- connectionDetails: { roleArn: rawConnectionDetails.roleArn as string },
- targetRoleArn: rawCredentials.targetRoleArn as string,
+ roleArn,
+ // PAM is one project per org, so the actor's org owns this account. We use the org ID as the
+ // STS External ID so the customer's role trust policy scopes assumption to this Infisical org.
+ externalId: actor.actorOrgId,
roleSessionName: actorEmail.replace(new RE2(/[^\w+=,.@-]/g), "_").substring(0, 64),
- projectId,
sessionDuration: stsDurationSeconds
});
@@ -586,10 +587,10 @@ export const pamSessionServiceFactory = ({
metadata.secretAccessKey = stsCredentials.secretAccessKey;
metadata.sessionToken = stsCredentials.sessionToken;
metadata.expiresAt = expiresAt.toISOString();
- metadata.targetRoleArn = rawCredentials.targetRoleArn as string;
+ metadata.roleArn = roleArn;
metadata.federatedUsername = actorEmail;
- const awsAccountId = extractAwsAccountIdFromArn(rawConnectionDetails.roleArn as string);
+ const awsAccountId = extractAwsAccountIdFromArn(roleArn);
if (awsAccountId) {
metadata.awsAccountId = awsAccountId;
}
diff --git a/docs/documentation/platform/pam/accounts/aws-iam.mdx b/docs/documentation/platform/pam/accounts/aws-iam.mdx
index e2c0098726..1560c48c56 100644
--- a/docs/documentation/platform/pam/accounts/aws-iam.mdx
+++ b/docs/documentation/platform/pam/accounts/aws-iam.mdx
@@ -6,10 +6,84 @@ description: "Add and connect to AWS accounts via IAM role assumption."
AWS IAM accounts let you manage access to AWS through IAM role assumption. Users can open the AWS console directly or use the CLI to get temporary credentials, and every access is logged.
+Infisical assumes the IAM role you configure directly, then returns short-lived STS credentials. Those credentials work with the AWS CLI and can also be exchanged for a federated AWS Management Console sign-in URL.
+
<Note>
-AWS IAM accounts do not require a Gateway — Infisical connects directly to AWS.
+AWS IAM accounts do not require a Gateway. Infisical communicates directly with the AWS STS API.
</Note>
+## How It Works
+
+When a user accesses an AWS IAM account, Infisical assumes the account's IAM role using AWS STS and returns the temporary credentials:
+
+```mermaid
+sequenceDiagram
+ participant User
+ participant Infisical
+ participant Role as IAM Role<br/>(Your AWS Account)
+ participant Console as AWS Console
+ User->>Infisical: Request AWS access
+ Infisical->>Role: AssumeRole (with ExternalId = Org ID)
+ Role-->>Infisical: Temporary credentials
+ Infisical-->>User: Return credentials (CLI)
+ Infisical->>Console: Exchange for federation URL (Console)
+ Console-->>Infisical: Signed console URL
+ Infisical-->>User: Return console URL
+```
+
+There is a single role per account. Its trust policy allows Infisical to assume it, scoped by an **External ID** set to your **Infisical Organization ID**. The External ID prevents [confused deputy attacks](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html), where another Infisical customer could otherwise trick Infisical into assuming your role.
+
+## Prerequisites
+
+Before adding the account in Infisical, create the IAM role in your AWS account with a trust policy that allows Infisical to assume it.
+
+<Steps>
+ <Step title="Create the role with a trust policy">
+ Create an IAM role (e.g., `infisical-pam-readonly`) with the following trust policy. Replace `<INFISICAL_AWS_ACCOUNT_ID>` with the Infisical account ID for your region and `<YOUR_INFISICAL_ORG_ID>` with your Infisical Organization ID.
+
+ ```json
+ {
+ "Version": "2012-10-17",
+ "Statement": [{
+ "Effect": "Allow",
+ "Principal": {
+ "AWS": "arn:aws:iam::<INFISICAL_AWS_ACCOUNT_ID>:root"
+ },
+ "Action": "sts:AssumeRole",
+ "Condition": {
+ "StringEquals": {
+ "sts:ExternalId": "<YOUR_INFISICAL_ORG_ID>"
+ }
+ }
+ }]
+ }
+ ```
+
+ <Warning>
+ Always include the External ID condition. Without it, another Infisical customer could potentially trick Infisical into assuming your role.
+ </Warning>
+
+ **Infisical AWS Account IDs:**
+
+ | Region | Account ID |
+ |--------|------------|
+ | US | `381492033652` |
+ | EU | `345594589636` |
+
+ <Note>
+ **For Dedicated Instances**: Your AWS account ID differs from the ones listed above. Contact Infisical support to obtain your dedicated AWS account ID.
+ </Note>
+ <Note>
+ **For Self-Hosted Instances**: Use the AWS account ID where your Infisical instance is deployed. This is the account that hosts your Infisical infrastructure and will be assuming the role.
+ </Note>
+
+ You can find your Infisical Organization ID under **Organization Settings**.
+ </Step>
+ <Step title="Attach permissions to the role">
+ Attach whatever permissions policies define what this role can do in AWS. These are the permissions users receive when they access this account through Infisical.
+ </Step>
+</Steps>
+
## Creating an Account
<Steps>
@@ -23,27 +97,26 @@ AWS IAM accounts do not require a Gateway — Infisical connects directly to AWS
| Field | Description |
|-------|-------------|
| **Name** | A descriptive name (e.g., `prod-admin-access`) |
- | **PAM Role ARN** | The ARN of the IAM role that Infisical assumes to broker access |
- </Step>
- <Step title="Enter credentials">
- | Field | Description |
- |-------|-------------|
- | **Target Role ARN** | The ARN of the IAM role the user will assume |
+ | **Role ARN** | The ARN of the IAM role Infisical assumes for this account (e.g., `arn:aws:iam::123456789012:role/infisical-pam-readonly`) |
</Step>
<Step title="Save">
Click **Create**.
</Step>
</Steps>
-## How It Works
+<Note>
+ To expose the same role in more than one folder, add an account in each folder pointing at the same **Role ARN**. Each account is a distinct entry that references the same underlying IAM role.
+</Note>
+
+## Session Duration
-When a user accesses an AWS IAM account:
+Sessions use short-lived STS credentials. The duration is bounded by the target role's **maximum session duration** in AWS (`MaxSessionDuration`), with a minimum of 15 minutes. Requesting longer than the role allows will cause AWS to reject the request, so set the role's `MaxSessionDuration` to cover the session lengths you expect.
-1. Infisical assumes the **PAM Role** (configured at the account level)
-2. Using that role, Infisical assumes the **Target Role** on behalf of the user
-3. The user receives temporary AWS credentials for the target role
+<Info>
+ AWS Console sessions cannot be terminated early. Once a federated URL is generated, the session remains valid until it expires. You can [revoke active sessions](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_revoke-sessions.html) by modifying the role's trust policy.
+</Info>
-This lets you centralize access control through Infisical while using standard AWS IAM roles.
+All actions performed with the credentials are logged in [AWS CloudTrail](https://console.aws.amazon.com/cloudtrail). The session is identified by the `RoleSessionName`, which includes the user's email for attribution.
## Connecting
@@ -51,7 +124,7 @@ This lets you centralize access control through Infisical while using standard A
<Tab title="AWS Console">
1. Go to **Privileged Access Management → My Access**
2. Find the account and click **Launch → Connect in Browser**
- 3. You'll be taken directly to the AWS console, logged in with the target role
+ 3. You'll be taken directly to the AWS console, logged in with the role
</Tab>
<Tab title="CLI">
The CLI writes temporary credentials to your AWS credentials file as a named profile:
@@ -76,7 +149,7 @@ This lets you centralize access control through Infisical while using standard A
Press **Ctrl+C** to stop and remove the credentials profile.
**Flags:**
- - `--reason <reason>` — provide an access reason (if required by template)
+ - `--reason <reason>`: provide an access reason (if required by template)
</Tab>
</Tabs>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
index 45a81cc3db..9119a8fa0a 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
@@ -470,10 +470,12 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Pr
</div>
</div>
- <div className="mt-2">
- <h3 className="mb-3 text-sm font-medium text-foreground">Credentials</h3>
- <CredentialsForm control={control} />
- </div>
+ {(selectedMetadata?.credentialFields.length ?? 0) > 0 && (
+ <div className="mt-2">
+ <h3 className="mb-3 text-sm font-medium text-foreground">Credentials</h3>
+ <CredentialsForm control={control} />
+ </div>
+ )}
<div aria-hidden className="h-8 shrink-0" />
</div>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsx
index 4c35821e5f..e875a90847 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsx
@@ -294,15 +294,17 @@ export const EditAccountForm = ({ accountId, onDirtyChange }: Props) => {
</CardContent>
</Card>
- <Card>
- <CardHeader className="border-b">
- <CardTitle className="text-base">Credentials</CardTitle>
- <CardDescription>Authentication used to connect to this account.</CardDescription>
- </CardHeader>
- <CardContent>
- <CredentialsForm control={control} />
- </CardContent>
- </Card>
+ {(metadata?.credentialFields.length ?? 0) > 0 && (
+ <Card>
+ <CardHeader className="border-b">
+ <CardTitle className="text-base">Credentials</CardTitle>
+ <CardDescription>Authentication used to connect to this account.</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <CredentialsForm control={control} />
+ </CardContent>
+ </Card>
+ )}
<div aria-hidden className="h-8 shrink-0" />
{isDirty && <SheetSaveBar isPending={updateAccount.isPending} onDiscard={() => reset()} />}
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx
index f22b6820a8..c540cc5d2d 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx
@@ -13,6 +13,7 @@ import {
import { Switch } from "@app/components/v3/generic/Switch";
import { TextArea } from "@app/components/v3/generic/TextArea";
import { Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3/generic/Tooltip";
+import { useOrganization } from "@app/context";
import { PamFieldWidget, TPamFieldDescriptor } from "@app/hooks/api/pam";
import { TAccountFormValues } from "./accountFormSchema";
@@ -28,6 +29,22 @@ type Props = {
const RequiredMark = () => <span className="text-product-pam">*</span>;
+// Tooltips may reference the org's ID via a {{organizationId}} placeholder (e.g. the AWS IAM role's
+// External ID); resolve it here so the user sees their actual ID inline.
+const FieldTooltip = ({ text }: { text?: string }) => {
+ const { currentOrg } = useOrganization();
+ if (!text) return null;
+ const resolved = text.replace(/\{\{organizationId\}\}/g, currentOrg.id);
+ return (
+ <Tooltip>
+ <TooltipTrigger>
+ <Info className="text-muted-foreground ml-1 inline h-3.5 w-3.5" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs whitespace-pre-line">{resolved}</TooltipContent>
+ </Tooltip>
+ );
+};
+
type FieldProps = {
field: ControllerRenderProps<TAccountFormValues>;
descriptor: TPamFieldDescriptor;
@@ -116,16 +133,7 @@ export const PamSchemaFields = ({ control, namePrefix, fields }: Props) => {
<FieldLabel>
{descriptor.label}
{(descriptor.required || descriptor.secret) && <RequiredMark />}
- {descriptor.tooltip && (
- <Tooltip>
- <TooltipTrigger>
- <Info className="text-muted-foreground ml-1 inline h-3.5 w-3.5" />
- </TooltipTrigger>
- <TooltipContent className="whitespace-pre-line">
- {descriptor.tooltip}
- </TooltipContent>
- </Tooltip>
- )}
+ <FieldTooltip text={descriptor.tooltip} />
</FieldLabel>
<Switch
variant="pam"
@@ -138,16 +146,7 @@ export const PamSchemaFields = ({ control, namePrefix, fields }: Props) => {
<FieldLabel>
{descriptor.label}
{(descriptor.required || descriptor.secret) && <RequiredMark />}
- {descriptor.tooltip && (
- <Tooltip>
- <TooltipTrigger>
- <Info className="text-muted-foreground ml-1 inline h-3.5 w-3.5" />
- </TooltipTrigger>
- <TooltipContent className="whitespace-pre-line">
- {descriptor.tooltip}
- </TooltipContent>
- </Tooltip>
- )}
+ <FieldTooltip text={descriptor.tooltip} />
</FieldLabel>
<FieldContent>
<FieldWidget field={field} descriptor={descriptor} isError={!!fieldState.error} />