Skip to content

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

address greptile reviews

Andrey2e792fea685a
diff --git a/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts b/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts
index e7c09117b5..2e19ff72ba 100644
--- a/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts
+++ b/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts
@@ -32,10 +32,15 @@ export const PAM_RECORDING_CONNECTION_APPS = [AppConnection.AWS, AppConnection.S
export const resolveS3RecordingAccess = async (
appConnection: TAppConnection,
region: string | undefined
-): Promise<Pick<TPamRecordingResolvedConfig, "region" | "endpoint" | "awsCredentials">> => {
+): Promise<Pick<TPamRecordingResolvedConfig, "region" | "endpoint" | "httpsAgent" | "awsCredentials">> => {
if (appConnection.app === AppConnection.S3Compatible) {
const s3Config = await getS3CompatibleConnectionConfig(appConnection);
- return { region: s3Config.region, endpoint: s3Config.endpoint, awsCredentials: s3Config.credentials };
+ return {
+ region: s3Config.region,
+ endpoint: s3Config.endpoint,
+ httpsAgent: s3Config.httpsAgent,
+ awsCredentials: s3Config.credentials
+ };
}
if (appConnection.app !== AppConnection.AWS) {
@@ -56,7 +61,12 @@ const buildClient = (config: TPamRecordingResolvedConfig) => {
if (!config.region || !config.awsCredentials) {
throw new BadRequestError({ message: "S3 storage backend requires region and credentials" });
}
- return createS3Client({ region: config.region, endpoint: config.endpoint, credentials: config.awsCredentials });
+ return createS3Client({
+ region: config.region,
+ endpoint: config.endpoint,
+ httpsAgent: config.httpsAgent,
+ credentials: config.awsCredentials
+ });
};
export const AwsS3RecordingStorageProvider: TPamRecordingStorageProvider = () => ({
diff --git a/backend/src/ee/services/pam-session-recording/pam-recording-storage-types.ts b/backend/src/ee/services/pam-session-recording/pam-recording-storage-types.ts
index dc1afa6b70..b89e963fc7 100644
--- a/backend/src/ee/services/pam-session-recording/pam-recording-storage-types.ts
+++ b/backend/src/ee/services/pam-session-recording/pam-recording-storage-types.ts
@@ -1,3 +1,5 @@
+import type { Agent } from "node:https";
+
import { PamRecordingStorageBackend } from "./pam-recording-enums";
export type TPamRecordingChunkRef = {
@@ -11,6 +13,7 @@ export type TPamRecordingResolvedConfig = {
bucket?: string;
region?: string;
endpoint?: string;
+ httpsAgent?: Agent;
keyPrefix?: string | null;
awsCredentials?: {
diff --git a/backend/src/lib/aws/s3.ts b/backend/src/lib/aws/s3.ts
index ff1fcfde78..8abdcf9fd8 100644
--- a/backend/src/lib/aws/s3.ts
+++ b/backend/src/lib/aws/s3.ts
@@ -1,3 +1,5 @@
+import type { Agent } from "node:https";
+
import { GetObjectCommand, HeadBucketCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
@@ -14,16 +16,19 @@ export type TS3Bucket = ReturnType<typeof createS3Bucket>;
export const createS3Client = ({
region,
credentials,
- endpoint
+ endpoint,
+ httpsAgent
}: {
region: string;
credentials: TS3Credentials;
endpoint?: string;
+ httpsAgent?: Agent;
}) =>
new S3Client({
region,
sha256: CustomAWSHasher,
credentials,
+ ...(httpsAgent && { requestHandler: { httpsAgent } }),
...(endpoint
? {
endpoint,
diff --git a/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.ts b/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.ts
index 189faa07f0..667eff77af 100644
--- a/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.ts
+++ b/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.ts
@@ -1,8 +1,11 @@
+import type { Agent } from "node:https";
+
import { ListBucketsCommand, S3ServiceException } from "@aws-sdk/client-s3";
import { createS3Client } from "@app/lib/aws/s3";
import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
+import { buildSsrfSafeAgent } from "@app/lib/validator";
import { getServerCfg } from "@app/services/super-admin/super-admin-service";
import { AppConnection } from "../app-connection-enums";
@@ -33,13 +36,26 @@ export const getS3CompatibleConnectionConfig = async ({
throw new BadRequestError({ message: S3_COMPATIBLE_ENDPOINT_ERROR });
}
+ const providerName =
+ parsed.provider === S3CompatibleProvider.Custom
+ ? new URL(parsed.origin).host
+ : S3_COMPATIBLE_PROVIDER_MAP[parsed.provider].name;
+
+ const httpsAgent =
+ parsed.provider === S3CompatibleProvider.Custom
+ ? ((await buildSsrfSafeAgent(parsed.origin).catch((error: NodeJS.ErrnoException) => {
+ if (error.code !== "ENOTFOUND" && error.code !== "EAI_AGAIN") throw error;
+ throw new BadRequestError({
+ message: `Could not resolve ${providerName}. Verify the hostname and try again.`
+ });
+ })) as Agent | undefined)
+ : undefined;
+
return {
- providerName:
- parsed.provider === S3CompatibleProvider.Custom
- ? new URL(parsed.origin).host
- : S3_COMPATIBLE_PROVIDER_MAP[parsed.provider].name,
+ providerName,
region: parsed.region,
endpoint: parsed.provider === S3CompatibleProvider.AwsS3 ? undefined : parsed.origin,
+ httpsAgent,
credentials: { accessKeyId: credentials.accessKeyId, secretAccessKey: credentials.secretAccessKey }
};
};
diff --git a/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-schemas.ts b/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-schemas.ts
index 626ac1c4a2..04d2689421 100644
--- a/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-schemas.ts
+++ b/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-schemas.ts
@@ -86,14 +86,15 @@ export const parseS3CompatibleEndpoint = (endpoint: string, allowedStorageHostna
const url = parseEndpointUrl(endpoint);
if (!url) return null;
- if (allowedStorageHostnames.includes(url.host)) {
- return { provider: S3CompatibleProvider.Custom, region: CUSTOM_HOSTNAME_SIGNING_REGION, origin: url.origin };
+ if (!url.port) {
+ for (const provider of Object.keys(S3_COMPATIBLE_PROVIDER_MAP) as (keyof typeof S3_COMPATIBLE_PROVIDER_MAP)[]) {
+ const region = S3_COMPATIBLE_PROVIDER_MAP[provider].getSigningRegion(url.hostname);
+ if (region) return { provider, region, origin: url.origin };
+ }
}
- if (url.port) return null;
- for (const provider of Object.keys(S3_COMPATIBLE_PROVIDER_MAP) as (keyof typeof S3_COMPATIBLE_PROVIDER_MAP)[]) {
- const region = S3_COMPATIBLE_PROVIDER_MAP[provider].getSigningRegion(url.hostname);
- if (region) return { provider, region, origin: url.origin };
+ if (allowedStorageHostnames.includes(url.host)) {
+ return { provider: S3CompatibleProvider.Custom, region: CUSTOM_HOSTNAME_SIGNING_REGION, origin: url.origin };
}
return null;
};
diff --git a/docs/documentation/platform/admin-panel/server-admin.mdx b/docs/documentation/platform/admin-panel/server-admin.mdx
index 194606c73c..5b68876fb4 100644
--- a/docs/documentation/platform/admin-panel/server-admin.mdx
+++ b/docs/documentation/platform/admin-panel/server-admin.mdx
@@ -65,7 +65,7 @@ Select **Save** to apply either change.
### Allowed storage hostnames
-If you store [PAM session recordings](/documentation/platform/pam/sessions/external-storage) on your own S3-compatible server, such as MinIO, add the server's hostname under **Hostnames** and select **Save**. Include the port if it isn't 443, such as `minio.example.com:9000`, and make sure the server accepts HTTPS connections.
+If you store [PAM session recordings](/documentation/platform/pam/sessions/external-storage) on your own S3-compatible server, such as MinIO, add the server's hostname under **Hostnames** and select **Save**. Include the port if it isn't 443, such as `minio.example.com:9000`, and make sure the server accepts HTTPS connections. If the hostname resolves to a private IP address, also set [`ALLOW_INTERNAL_IP_CONNECTIONS`](/self-hosting/configuration/envars#param-allow-internal-ip-connections) to `true`.
An S3-Compatible Storage connection can then use the server as its endpoint, and browsers can play back recordings stored there.
diff --git a/docs/documentation/platform/pam/sessions/external-storage.mdx b/docs/documentation/platform/pam/sessions/external-storage.mdx
index 1d7ab0a143..36bc4ec2f8 100644
--- a/docs/documentation/platform/pam/sessions/external-storage.mdx
+++ b/docs/documentation/platform/pam/sessions/external-storage.mdx
@@ -50,16 +50,18 @@ For AWS S3, the connection's IAM role or user needs these permissions on the buc
External storage is set at the [template](/documentation/platform/pam/templates/overview) level. Each template can use a different bucket if needed.
<Steps>
- <Step title="Open the template">
+ <Step>
Go to **Account Templates** and select the template you want to configure.
</Step>
- <Step title="Find Session Recording">
- On the **General** tab, find the **Session Recording** section.
+ <Step>
+ Find the **Session Recording** section on the **General** tab.
</Step>
- <Step title="Select S3 Bucket">
+ <Step>
Set **Storage backend** to **S3 Bucket**.
</Step>
- <Step title="Configure the bucket">
+ <Step>
+ Configure the bucket:
+
| Field | Description |
|-------|-------------|
| **Connection** | Select your AWS or S3-Compatible Storage connection |
@@ -67,7 +69,7 @@ External storage is set at the [template](/documentation/platform/pam/templates/
| **Region** | AWS region (only for an AWS connection) |
| **Key Prefix** | Optional prefix for object keys (e.g., `pam/prod/`) |
</Step>
- <Step title="Save">
+ <Step>
Select **Save**. Infisical validates that it can reach the bucket before saving.
</Step>
</Steps>
diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.ts
index e00af83d9e..9e1ed709b9 100644
--- a/frontend/src/helpers/appConnections.ts
+++ b/frontend/src/helpers/appConnections.ts
@@ -714,11 +714,11 @@ export const getS3CompatibleProviderName = (
) {
return null;
}
- if (allowedStorageHostnames.includes(url.host)) return url.host;
- if (url.port) return null;
- return (
- S3_COMPATIBLE_PROVIDERS.find(({ hostname }) => hostname.test(url.hostname))?.name ?? null
- );
+ const providerName = url.port
+ ? undefined
+ : S3_COMPATIBLE_PROVIDERS.find(({ hostname }) => hostname.test(url.hostname))?.name;
+ if (providerName) return providerName;
+ return allowedStorageHostnames.includes(url.host) ? url.host : null;
} catch {
return null;
}