Skip to content

Commit 3fff5e8

Browse files
committed
fix: ensure all ips are private
1 parent 15b4291 commit 3fff5e8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server/utils/image-proxy.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,12 @@ export async function resolveAndValidateHost(url: string): Promise<boolean> {
120120
}
121121

122122
try {
123-
// Resolve to check all returned IPs
124-
const { address } = await lookup(hostname)
125-
return !isPrivateIP(address)
123+
// Resolve with { all: true } to get every A/AAAA record. A hostname can
124+
// have multiple records; an attacker could mix a public IP with a private
125+
// one. If any resolved IP is private/reserved, reject the entire request.
126+
const results = await lookup(hostname, { all: true })
127+
if (results.length === 0) return false
128+
return results.every(result => !isPrivateIP(result.address))
126129
} catch {
127130
// DNS resolution failed — block the request
128131
return false

0 commit comments

Comments
 (0)