The vulnerability is a Server-Side Request Forgery (SSRF) caused by a Time-of-check to time-of-use (TOCTOU) flaw in Deno's network permission enforcement for the WebSocket API. When a script initiated a WebSocket connection, Deno would check the provided hostname against the --deny-net list. However, it failed to perform a second check on the IP address(es) that the hostname resolved to.
An attacker could exploit this by using a specially crafted domain name that is permitted by the --deny-net rules but resolves to a denied IP address, such as 127.0.0.1 or an internal service. This would bypass the intended network sandbox.
The patch addresses this by introducing a check on the resolved IP addresses. This is achieved by:
- Plumbing the
PermissionsContainer down to the DNS resolver used by fetch() and WebSocket connections.
- In the DNS resolver (
deno::ext::fetch::dns::Resolver::call), after the hostname is resolved, a new function check_resolved_permissions is called to validate each resulting IP address against the --deny-net list.
- Introducing a
PermissionedHttpConnector to ensure that the correct destination port is available to the resolver, making port-specific deny rules effective.
The vulnerable functions are those in the connection setup path that failed to ensure this post-resolution check was performed, primarily deno::ext::websocket::op_ws_create and the underlying DNS resolver deno::ext::fetch::dns::Resolver::call.