Skip to content

Conversation

pcarleton
Copy link
Member

No description provided.

}

// Resolve DNS name to IPv4 addresses
const addresses = await dns.promises.resolve4(url.hostname);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other useful SSRF defense-in-depth technique is to use a public resolver instead of the default resolver - this prevents internal hostnames from ever resolving to a private address in the first place

const { Resolver } = require('node:dns').promises;
const resolver = new Resolver();
resolver.setServers(['1.1.1.1']);  // Use Cloudflare public DNS
const addresses = await resolver.resolve4(url.hostname);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants