Skip to content

Commit 820df09

Browse files
committed
fix(security): block localhost when allowHttp is enabled
When allowHttp is true (user-supplied webhook URLs), explicitly block localhost/loopback in both validateExternalUrl and validateUrlWithDNS to prevent SSRF against internal services.
1 parent 7f95266 commit 820df09

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ export async function validateUrlWithDNS(
8989
return ip === '127.0.0.1' || ip === '::1'
9090
})()
9191

92-
if (isPrivateOrReservedIP(address) && !(isLocalhost && resolvedIsLoopback)) {
92+
if (
93+
isPrivateOrReservedIP(address) &&
94+
!(isLocalhost && resolvedIsLoopback && !options.allowHttp)
95+
) {
9396
logger.warn('URL resolves to blocked IP address', {
9497
paramName,
9598
hostname,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,12 @@ export function validateExternalUrl(
717717
error: `${paramName} must use http:// or https:// protocol`,
718718
}
719719
}
720+
if (isLocalhost) {
721+
return {
722+
isValid: false,
723+
error: `${paramName} cannot point to localhost`,
724+
}
725+
}
720726
} else if (protocol !== 'https:' && !(protocol === 'http:' && isLocalhost)) {
721727
return {
722728
isValid: false,

0 commit comments

Comments
 (0)