Skip to content

Commit 270ecbd

Browse files
committed
fix(security): accept AWS European Sovereign Cloud regions in validateAwsRegion
eusc-de-east-1 is a real Bedrock-enabled region that the existing pattern did not cover, so applying the validator to bedrockRegion would have rejected a config that worked before. Adds the eusc-<country> partition.
1 parent 95202a8 commit 270ecbd

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

apps/sim/lib/core/security/input-validation.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,19 @@ describe('validateAwsRegion', () => {
14601460
})
14611461
})
14621462

1463+
describe('valid European Sovereign Cloud regions', () => {
1464+
it.concurrent('should accept eusc-de-east-1', () => {
1465+
const result = validateAwsRegion('eusc-de-east-1')
1466+
expect(result.isValid).toBe(true)
1467+
expect(result.sanitized).toBe('eusc-de-east-1')
1468+
})
1469+
1470+
it.concurrent('should reject a malformed eusc region', () => {
1471+
expect(validateAwsRegion('eusc-de-east').isValid).toBe(false)
1472+
expect(validateAwsRegion('eusc-deu-east-1').isValid).toBe(false)
1473+
})
1474+
})
1475+
14631476
describe('valid China regions', () => {
14641477
it.concurrent('should accept cn-north-1', () => {
14651478
const result = validateAwsRegion('cn-north-1')

apps/sim/lib/core/security/input-validation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ export function validateAirtableId(
856856
* - ISO partitions: us-iso-east-1, us-iso-west-1, us-isob-east-1
857857
* - Mexico: mx-central-1
858858
* - EU Sovereign Cloud: eu-isoe-west-1
859+
* - European Sovereign Cloud: eusc-de-east-1
859860
*
860861
* @param value - The AWS region to validate
861862
* @param paramName - Name of the parameter for error messages
@@ -881,7 +882,7 @@ export function validateAwsRegion(
881882
}
882883

883884
const awsRegionPattern =
884-
/^(eu-isoe|us-isob|us-iso|us-gov|af|ap|ca|cn|eu|il|me|mx|sa|us)-(central|north|northeast|northwest|south|southeast|southwest|east|west)-\d{1,2}$/
885+
/^(eu-isoe|eusc-[a-z]{2}|us-isob|us-iso|us-gov|af|ap|ca|cn|eu|il|me|mx|sa|us)-(central|north|northeast|northwest|south|southeast|southwest|east|west)-\d{1,2}$/
885886

886887
if (!awsRegionPattern.test(value)) {
887888
logger.warn('Invalid AWS region format', {

0 commit comments

Comments
 (0)