Skip to content

Commit d478737

Browse files
Honor the fromURL graceful-failure contract for non-IPv6 hosts (#218)
Address6.fromURL() is documented and typed to return `{ error, address: null, port: null }` when a URL can't be parsed, but that contract was only implemented on the regex-miss path. The URL host character class `[0-9a-f:.]` is a superset of valid IPv6, so any host made only of hex digits, colons and dots matched the regex and was handed straight to `new Address6(host)`, whose AddressError propagated out uncaught. IPv4 literals are the visible case — `http://127.0.0.1/`, `http://169.254.169.254/`, `http://0.0.0.0/` all threw — but so did `[:::]`, `[1:2:3:4:5:6:7:8:9]` and `[::ffff:999.1.1.1]`. A plain hostname like `example.com` avoided the throw only because letters outside a-f break the regex match first. Catch the constructor and return the same error object the regex-miss path returns, so the function never throws for any input. Reported by @zikk090 via GHSA-mxvh-v779-f36j. Declining that as a security advisory: an uncaught synchronous throw from a parser on the caller's own stack is a correctness bug, not a denial of service.
1 parent fbb8db2 commit d478737

3 files changed

Lines changed: 149 additions & 77 deletions

File tree

0 commit comments

Comments
 (0)