Skip to content
SSRF Disclosed report Intermediate

Hostname spoofing

The url.parse() function in Node.js mishandles certain Unicode characters, causing the parsed hostname to differ from the actual host that will be contacted. An attacker could craft a URL that appears to belong to a trusted domain but actually points to a malicious one, potentially enabling open redirects or SSRF.

tosh Follow

Originally disclosed on HackerOne

  • Triaged in 3 months
  • Disclosed after 5 months

Summary: I found that url.parse() is vulnerable to hostsplit that causes hostname spoofing.

Description:

Steps To Reproduce:

url.parse('http://evil.c℀.victim.test/?') returns evil.ca/c.victim.test as hostname, so this hostname matches *.victim.test but will access evil.ca.

Welcome to Node.js v12.9.0.
Type ".help" for more information.
> url = require('url')
{
  Url: [Function: Url],
  parse: [Function: urlParse],
  resolve: [Function: urlResolve],
  resolveObject: [Function: urlResolveObject],
  format: [Function: urlFormat],
  URL: [Function: URL],
  URLSearchParams: [Function: URLSearchParams],
  domainToASCII: [Function: domainToASCII],
  domainToUnicode: [Function: domainToUnicode],
  pathToFileURL: [Function: pathToFileURL],
  fileURLToPath: [Function: fileURLToPath]
}
> url.parse('http://evil.c℀.victim.test/?')
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'evil.ca/c.victim.test',
  port: null,
  hostname: 'evil.ca/c.victim.test',
  hash: null,
  search: '?',
  query: '',
  pathname: '/',
  path: '/?',
  href: 'http://evil.ca/c.victim.test/?'
}
> url.parse('http://a.com/.b.com/')
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'a.com/.b.com',
  port: null,
  hostname: 'a.com/.b.com',
  hash: null,
  search: null,
  query: null,
  pathname: '/',
  path: '/',
  href: 'http://a.com/.b.com/'
}

Impact

  • Hostname spoofing may cause openredirect, ssrf, etc...

Supporting Material/References:

Impact

Hostname spoofing may cause openredirect, ssrf, etc...

The original report as published on HackerOne, by tosh. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the URL parser does not correctly normalise or reject certain Unicode characters that are treated as path separators or that map to different characters, leading to a mismatch between the parsed hostname and the actual host.

Impact

Hostname spoofing may cause open redirect or SSRF, as the parsed hostname can match a trusted pattern while the actual request goes to an attacker-controlled host.

What the attacker needed

Application uses url.parse() on untrusted input

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program reads a web address, it splits it into parts like the hostname (the site name). This report shows that Node.js's url.parse() can be tricked by special characters so that the hostname it reports is not the one the browser will actually visit. That means a link that looks like it goes to a trusted site could really go to an attacker's site.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More from Node.js

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.