From 7788bf48e2bd57a04c4e53902b6516737f6c4636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Wed, 29 Jul 2026 21:41:58 -0300 Subject: [PATCH] net: reject non-address SocketAddress.parse input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guilherme Araújo --- doc/api/net.md | 5 ++++ lib/internal/socketaddress.js | 10 ++++++++ test/parallel/test-socketaddress.js | 36 +++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/doc/api/net.md b/doc/api/net.md index 988bc5669e7f..d2e4f8f8d8aa 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -295,6 +295,11 @@ added: * Returns: {net.SocketAddress} Returns a `SocketAddress` if parsing was successful. Otherwise returns `undefined`. +The `input` may contain only hexadecimal digits, `x`, `.`, `:`, `[`, and `]`. +Anything else returns `undefined`, including other URL components such as +`user@1.2.3.4` or `1.2.3.4/foo`, whitespace, control characters, +percent-encoding, and non-ASCII characters. + ## Class: `net.Server`