Skip to content

Commit ec633dc

Browse files
committed
chore(api): tighten proxy-path inline comments
1 parent d9b9440 commit ec633dc

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,14 @@ export async function validateAndPinProxyUrl(
203203

204204
const resolvedIP = validation.resolvedIP!
205205

206-
// validateUrlWithDNS carves out loopback for self-hosted dev targets, but a proxy
207-
// must be publicly reachable unconditionally: once it governs egress, a loopback
208-
// forward proxy plus a rebinding target could reach internal addresses that
209-
// target-IP pinning otherwise blocks.
206+
// validateUrlWithDNS permits loopback for self-hosted dev targets; a proxy governs
207+
// egress, so loopback/private proxy hosts stay blocked unconditionally.
210208
if (isPrivateOrReservedIP(resolvedIP)) {
211209
return { isValid: false, error: 'proxyUrl resolves to a blocked IP address' }
212210
}
213211

214-
// Bracket IPv6 literals: assigning an unbracketed IPv6 address to
215-
// URL.hostname is a no-op (the WHATWG parser rejects it), which would leave
216-
// the original DNS hostname in place and reopen the rebinding window.
212+
// Bracket IPv6 literals: assigning an unbracketed IPv6 address to URL.hostname
213+
// is a no-op, which would leave the DNS hostname in place and reopen rebinding.
217214
parsed.hostname = resolvedIP.includes(':') ? `[${resolvedIP}]` : resolvedIP
218215
return { isValid: true, pinnedProxyUrl: parsed.toString() }
219216
}
@@ -756,11 +753,9 @@ export async function secureFetchWithPinnedIP(
756753

757754
let agent: http.Agent
758755
if (options.proxyUrl) {
759-
// The proxy connection is already IP-pinned by validateAndPinProxyUrl; routing
760-
// through the proxy intentionally bypasses target-IP pinning (the proxy
761-
// resolves the target). Agent choice keys off the target protocol: an
762-
// https target tunnels via CONNECT, an http target uses absolute-URI
763-
// forwarding - both over the plain-http proxy connection.
756+
// Proxy connection is already IP-pinned by validateAndPinProxyUrl; target-IP
757+
// pinning is intentionally bypassed (the proxy resolves the target). https
758+
// targets tunnel via CONNECT, http targets use absolute-URI forwarding.
764759
agent = isHttps ? new HttpsProxyAgent(options.proxyUrl) : new HttpProxyAgent(options.proxyUrl)
765760
} else {
766761
const lookup = createPinnedLookup(resolvedIP)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,6 @@ describe('validateAndPinProxyUrl', () => {
904904
const result = await validateAndPinProxyUrl('http://user:pass@[2606:4700:4700::1111]:8080')
905905
expect(result.isValid).toBe(true)
906906
const pinned = new URL(result.pinnedProxyUrl!)
907-
// Must be pinned to the bracketed IPv6 literal, never left as a DNS name.
908907
expect(pinned.hostname).toBe('[2606:4700:4700::1111]')
909908
expect(pinned.username).toBe('user')
910909
expect(pinned.password).toBe('pass')

0 commit comments

Comments
 (0)