when someone use fast-proxy like:
const base = 'http://somewhere.com'
const { proxy, close } = require('fast-proxy')({
base
})
and give the req.url like "//10.10.10.10/", the result of getReqUrl method is:
URL {
href: 'http://10.10.10.10/',
origin: 'http://10.10.10.10',
protocol: 'http:',
username: '',
password: '',
host: '10.10.10.10',
hostname: '10.10.10.10',
port: '',
pathname: '/',
search: '',
searchParams: URLSearchParams {},
hash: '' }
but the result we expected is:
URL {
href: 'http://somewhere.com/',
origin: 'http://somewhere.com',
protocol: 'http:',
username: '',
password: '',
host: 'somewhere.com',
hostname: 'somewhere.com',
port: '',
pathname: '/',
search: '',
searchParams: URLSearchParams {},
hash: '' }
it can be used to make SSRF attack.
so i suggest to pollyfill the method getResUrl:


when we give new URL instance, we need to exclude some source that begin with '//', to make it like '/'.