node/doc/api
Timothy Gu 70157b9cb7
url: forbid certain confusable changes from being introduced by toASCII
The legacy url.parse() function attempts to convert Unicode domains
(IDNs) into their ASCII/Punycode form through the use of the toASCII
function. However, toASCII can introduce or remove various characters
that at best invalidate the parsed URL, and at worst cause hostname
spoofing:

  url.parse('http://bad.c℀.good.com/').href === 'http://bad.ca/c.good.com/'
  (from [1])
  url.parse('http://\u00AD/bad.com').href === 'http:///bad.com/'

While changes to the legacy URL parser are discouraged in general, the
security implications here outweigh the desire for strict compatibility.
This is since this commit only changes behavior when non-ASCII
characters appear in the hostname, an unusual situation for most use
cases. Additionally, despite the availability of the WHATWG URL API,
url.parse remain widely deployed in the Node.js ecosystem, as
exemplified by the recent un-deprecation of the legacy API.

This change is similar in spirit to CPython 3.8's change [2] fixing
bpo-36216 [3] aka CVE-2019-9636, which also occurred despite potential
compatibility concerns.

[1]: https://hackerone.com/reports/678487
[2]: 16e6f7dee7
[3]: https://bugs.python.org/issue36216

PR-URL: https://github.com/nodejs/node/pull/38631
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2021-05-13 23:04:23 -07:00
..
addons.md doc: add link to V8 2021-04-10 19:22:20 +05:30
assert.md 2021-04-20, Version 16.0.0 (Current) 2021-04-20 16:48:35 +01:00
async_hooks.md async_hooks,doc: replace process.stdout.fd with 1 2021-04-26 11:51:48 -07:00
buffer.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
child_process.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
cli.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
cluster.md 2021-04-20, Version 16.0.0 (Current) 2021-04-20 16:48:35 +01:00
console.md doc: fix typo in console.md 2021-02-08 10:25:27 -08:00
crypto.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
debugger.md doc: update message to match actual output 2021-04-27 09:04:33 -07:00
deprecations.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
dgram.md 2021-02-02, Version 15.8.0 (Current) 2021-02-02 21:50:24 +01:00
diagnostics_channel.md doc: fix description of hasSubscribers 2021-02-12 14:00:27 +05:30
dns.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
documentation.md doc,tools: allow stability table to be updated 2021-04-06 06:14:44 +02:00
domain.md doc: change wording in doc/api/domain.md comment 2021-04-04 21:12:32 -07:00
embedding.md doc: use HEAD for links in api docs 2021-02-22 12:30:52 +01:00
errors.md url: forbid certain confusable changes from being introduced by toASCII 2021-05-13 23:04:23 -07:00
esm.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
events.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
fs.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
globals.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
http2.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
http.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
https.md doc: document return value of https.request 2020-12-26 14:04:05 +01:00
index.md doc: rename N-API to Node-API 2021-02-08 09:08:37 -08:00
inspector.md doc: use .md extension for internal links 2020-10-01 06:19:12 -07:00
intl.md doc: spell out ICU acronym on first occurrence 2021-03-27 13:34:14 -07:00
module.md tools: add support for mjs and cjs JS snippet linting 2021-03-06 16:05:39 +01:00
modules.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
n-api.md doc: update node-api support matrix 2021-04-28 18:18:43 -04:00
net.md doc: document new TCP_KEEPCNT and TCP_KEEPINTVL socket option defaults 2021-04-27 13:16:16 -07:00
os.md Revert "doc: os.uptime() temporary bug notice" 2021-05-03 13:36:01 +02:00
packages.md doc: fix version history for "exports" patterns 2021-04-25 09:45:04 +02:00
path.md doc: minor clarification to pathObject 2021-04-27 14:56:09 -07:00
perf_hooks.md 2021-05-04, Version 16.1.0 (Current) 2021-05-04 17:09:39 +02:00
policy.md doc: revise dependency redirection text in policy.md 2020-09-24 04:30:35 -07:00
process.md process: add 'worker' event 2021-05-13 18:12:52 -07:00
punycode.md docs: add references to punycode.md 2021-01-09 08:56:59 -08:00
querystring.md doc: mark querystring api as legacy 2021-04-29 13:03:59 +02:00
readline.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
repl.md repl: document top level await limitation with const/let 2021-04-28 10:13:03 -07:00
report.md src: add loop idle time in diagnostic report 2020-11-13 11:53:37 +05:30
stream.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
string_decoder.md doc: update list styles for remark-parse@9 rendering 2020-11-12 06:29:49 +00:00
synopsis.md doc: use .md extension for internal links 2020-10-01 06:19:12 -07:00
timers.md 2021-04-20, Version 16.0.0 (Current) 2021-04-20 16:48:35 +01:00
tls.md doc: document 'secureConnect' event limitation 2021-05-02 09:24:55 +02:00
tracing.md doc: simplify wording in tracing APIs doc 2020-10-10 05:55:04 -07:00
tty.md doc: add missing comma in tty 2021-01-25 06:51:15 -08:00
url.md url: forbid certain confusable changes from being introduced by toASCII 2021-05-13 23:04:23 -07:00
util.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
v8.md 2021-03-30, Version 12.22.0 'Erbium' (LTS) 2021-03-30 15:09:15 +01:00
vm.md doc: change "oject" to "object" 2021-04-16 09:04:15 -07:00
wasi.md tools,doc: add support for several flavors of JS code snippets 2021-03-06 16:13:57 +01:00
webcrypto.md doc: standardize on pseudorandom 2021-04-13 19:10:28 +05:30
worker_threads.md 2021-05-11, Version 14.17.0 'Fermium' (LTS) 2021-05-11 19:05:18 -04:00
zlib.md doc: fix YAML syntax errors 2020-10-06 15:52:10 -07:00