Skip to content

Hardened hostname handling against Node.js October 2026 security release - #67

Open
Gera-G-Guiles wants to merge 2 commits into
totaljs:masterfrom
totaljs-es:master
Open

Gera-G-Guiles wants to merge 2 commits into
totaljs:masterfrom
totaljs-es:master

Conversation

@Gera-G-Guiles

Copy link
Copy Markdown
Contributor

No description provided.

Node.js published security releases on 2026-10-21 (22.23.4, 24.22.1, 26.12.1).
Several of the fixed issues depend on how a hostname is written before it
reaches the DNS resolver or the TLS identity check. Total.js cannot require
a specific Node.js version, so the framework now normalizes and validates
hostnames itself, whatever Node.js version the user runs.

Related advisories:
- CVE-2026-105482 (high): dns.resolve*() truncates names at a NUL byte, so
  "attacker.example\0.trusted.example" can pass a hostname validation and then
  resolve a different name.
- CVE-2026-105483 (high), CVE-2026-106069 (high), CVE-2026-106072 (medium):
  tls.checkServerIdentity() mishandles IPv4 literals written with non-ASCII
  digits, leading zeros (octal vs decimal) or non-canonical forms
  (0x7f.0.0.1, 127.1, 2130706433), so a certificate can match a different
  address than the one the OS connects to.

Unlike Total.js 5, this framework parses URLs with the legacy Url.parse(),
which keeps "0127.0.0.1" or "0x7f.1" exactly as written, so these values
reached the resolver and the TLS check untouched. A redirect (Location header)
could also point a request to such an address.

Changes:
- utils.js: added U.validhost(host). It accepts plain hostnames and canonical
  IP literals only and rejects NUL bytes, non-ASCII characters and
  non-canonical IPv4 forms.
- utils.js: added U.tohost(host). It converts the host to its canonical ASCII
  form with url.domainToASCII (punycode for international names, dotted IPv4
  for numeric forms) and returns an empty string when the host is invalid.
  Valid input keeps working: only the written form is normalized.
- utils.js: REQUEST(), U.resolve() and the redirects normalize the hostname of
  the parsed URL and return "Invalid hostname" when it is not valid.
- utils.js: U.connect() (also used by LDAP()) normalizes opt.host and returns
  an "Invalid hostname" error instead of connecting when it is not valid.
- websocketclient.js: the host is normalized and an invalid hostname emits the
  error event.
- mail.js: the SMTP server is normalized with U.tohost(). Invalid values return
  "Invalid SMTP server hostname." instead of reaching the socket.

Not covered by the framework (fixed only by updating Node.js):
- CVE-2026-105481 (medium): unsolicited data on a reused keep-alive socket.
- The Brotli decoder issue (CVE-2026-111497) does not apply, the framework
  only decompresses gzip and deflate.

The proxy host is taken from configuration and its certificate is not
validated, so it was left as it is.

Tested with the framework test suite on Node.js 14, 16, 18, 19, 20, 22, 24
and 26.
Documents the hostname normalization and validation (U.validhost, U.tohost, REQUEST, U.resolve, U.connect, WebSocket client, SMTP server) and the Node.js CVEs it covers (CVE-2026-105482, CVE-2026-105483, CVE-2026-106069, CVE-2026-106072). Notes that CVE-2026-105481 is fixed only by updating Node.js and that CVE-2026-111497 does not affect the framework.
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.

1 participant