Skip to content

Commit 6f70ef0

Browse files
committed
fix(security): check vendor-hosted URL scheme on the parsed URL and pass abort signal to DNS validation
1 parent 3e95daa commit 6f70ef0

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,8 +1158,14 @@ function validateVendorHostedUrl(
11581158

11591159
// These vendors are public SaaS reached over TLS. Enforced here rather than
11601160
// left to the egress policy, which would permit plain HTTP to a host an
1161-
// operator happened to put in their allowlist.
1162-
if (/^http:\/\//i.test(candidate)) {
1161+
// operator happened to put in their allowlist. Checked on the parsed URL:
1162+
// the parser also reads `http:\\host`, `http:host`, and a scheme split by a
1163+
// tab or newline as `http://host`.
1164+
let scheme: string | undefined
1165+
try {
1166+
scheme = new URL(candidate).protocol
1167+
} catch {}
1168+
if (scheme === 'http:') {
11631169
return { isValid: false, error: `${paramName} must use https://` }
11641170
}
11651171

‎apps/sim/lib/internal/salesforce/operations/update-custom-field.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const executeSalesforceUpdateCustomFieldOperation: InternalToolOperationI
3333
Authorization: `Bearer ${params.accessToken}`,
3434
'Content-Type': 'application/json',
3535
}
36-
const validation = await validateUrlWithDNS(url, 'instanceUrl', 'configuredEndpoint')
36+
const validation = await validateUrlWithDNS(url, 'instanceUrl', 'configuredEndpoint', { signal })
3737
signal?.throwIfAborted()
3838
if (!validation.isValid) {
3939
throw new Error(validation.error || 'Invalid Salesforce instance URL')

0 commit comments

Comments
 (0)