Skip to content

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

make sure the sts endpoint provided uses a valid region

adilsona6962c067c85
diff --git a/backend/src/services/app-connection/aws/aws-connection-fns.ts b/backend/src/services/app-connection/aws/aws-connection-fns.ts
index 9b72105cdf..161a02fb4c 100644
--- a/backend/src/services/app-connection/aws/aws-connection-fns.ts
+++ b/backend/src/services/app-connection/aws/aws-connection-fns.ts
@@ -132,14 +132,21 @@ export const buildAwsConnectionConfig = (
}) as TAwsConnectionConfig;
export const validateAwsConnectionCredentials = async (appConnection: TAwsConnectionConfig) => {
+ const stsEndpoint =
+ appConnection.method === AwsConnectionMethod.AssumeRole ? appConnection.credentials.stsEndpoint : undefined;
+ const stsRegion = getStsSigningRegion(stsEndpoint);
+
+ if (stsEndpoint && (!stsRegion || !(Object.values(AWSRegion) as string[]).includes(stsRegion))) {
+ throw new BadRequestError({
+ message: `STS endpoint must target a supported AWS region. "${stsEndpoint}" does not resolve to a supported region.`
+ });
+ }
+
try {
const awsConfig = await getAwsConnectionConfig(appConnection);
- const stsEndpoint =
- appConnection.method === AwsConnectionMethod.AssumeRole ? appConnection.credentials.stsEndpoint : undefined;
-
const sts = new STSClient({
- region: getStsSigningRegion(stsEndpoint) ?? awsConfig.region,
+ region: stsRegion ?? awsConfig.region,
credentials: awsConfig.credentials,
...(stsEndpoint ? { endpoint: stsEndpoint } : {})
});