Skip to content

Commit

Permalink
block ips starting with localhost octet
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayachand committed Sep 15, 2023
1 parent c889db2 commit c99185f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const staticLookup = (transformerVersionId) => async (hostname, _, cb) => {
}

for (const ip of ips) {
if (ip.includes(LOCALHOST_IP)) {
cb(null, `cannot use ${LOCALHOST_IP} as IP address`, RECORD_TYPE_A);
if (ip.startsWith('127.')) {
cb(null, `cannot use ${ip} as IP address`, RECORD_TYPE_A);
return;
}
}
Expand All @@ -55,7 +55,7 @@ const blockLocalhostRequests = (url) => {
try {
const parseUrl = new URL(url);
const { hostname } = parseUrl;
if (LOCAL_HOST_NAMES_LIST.includes(hostname)) {
if (LOCAL_HOST_NAMES_LIST.includes(hostname) || hostname.startsWith('127.')) {
throw new Error('localhost requests are not allowed');
}
if (BLOCK_HOST_NAMES_LIST.includes(hostname)) {
Expand Down

0 comments on commit c99185f

Please sign in to comment.