Socket#sendto removed in newer Ruby — affects dozens of call sites in lib/ and modules/

Author: bandrelCreated Aug 12, 2026Updated Sep 17, 2026
LabelsStale

Steps to reproduce

  1. On a Ruby install where Socket#sendto/UDPSocket#sendto has been removed (confirmed removed as of Ruby 4.0.3; deprecated in earlier 3.x versions), run any module or library code path that calls .sendto(data, host, port, flags) on a UDP socket.
  2. Observe either a deprecation warning (older Ruby) or a hard NoMethodError: undefined method 'sendto' for an instance of UDPSocket (newer Ruby).

Minimal repro of the underlying Ruby behavior:

ruby
require 'socket'
s = UDPSocket.new
s.sendto('x', '127.0.0.1', 9)
# NoMethodError: undefined method 'sendto' for an instance of UDPSocket

Were you following a specific guide/tutorial or reading documentation?

No.

Expected behavior

Metasploit's UDP send paths should work regardless of Ruby version, using send(mesg, flags, host, port) (or Socket#sendmsg) instead of the removed sendto.

Current behavior

Socket#sendto / UDPSocket#sendto is deprecated in recent Ruby 3.x and has been fully removed in Ruby 4.0 (confirmed via direct test on Ruby 4.0.3 — raises NoMethodError rather than a warning). metasploit-framework.gemspec only requires Ruby >= 3.1, so this will increasingly break as users run the framework on newer interpreters.

This is not limited to login_scanner/snmp.rb (originally reported here) — the same .sendto(...) pattern is used throughout the codebase on raw Ruby UDP sockets:

Library code:

  • lib/snmp/manager.rb
  • lib/msf/core/exploit/remote/wdbrpc_client.rb (multiple call sites)
  • lib/msf/core/exploit/remote/ip.rb
  • lib/msf/core/auxiliary/udp_scanner.rb
  • lib/rex/proto/tftp/server.rb
  • lib/rex/proto/dhcp/server.rb (multiple call sites)
  • lib/rex/proto/dns/server.rb
  • lib/rex/proto/ldap/server.rb
  • lib/rex/proto/iax2/client.rb
  • lib/rex/proto/tftp/client.rb (multiple call sites)
  • lib/rex/proto/natpmp/packet.rb
  • lib/metasploit/framework/login_scanner/snmp.rb

Modules:

  • modules/post/multi/recon/multiport_egress_traffic.rb
  • modules/post/multi/escalate/metasploit_pcaplog.rb
  • modules/exploits/osx/mdns/upnp_location.rb
  • modules/exploits/multi/upnp/libupnp_ssdp_overflow.rb
  • modules/exploits/windows/misc/crosschex_device_bof.rb
  • modules/auxiliary/dos/scada/d20_tftp_overflow.rb
  • modules/auxiliary/server/capture/sip.rb
  • modules/auxiliary/scanner/vxworks/wdbrpc_version.rb
  • modules/auxiliary/scanner/vxworks/wdbrpc_bootline.rb
  • modules/auxiliary/scanner/scada/bacnet_l3.rb
  • modules/auxiliary/scanner/scada/koyo_login.rb
  • modules/auxiliary/scanner/tftp/netdecision_tftp.rb
  • modules/auxiliary/scanner/tftp/ipswitch_whatsupgold_tftp.rb
  • modules/auxiliary/scanner/tftp/tftpbrute.rb
  • modules/auxiliary/scanner/ike/cisco_ike_benigncertain.rb
  • modules/auxiliary/scanner/sip/enumerator.rb
  • modules/auxiliary/scanner/jenkins/jenkins_udp_broadcast_enum.rb
  • modules/auxiliary/scanner/ipmi/ipmi_dumphashes.rb
  • modules/auxiliary/scanner/natpmp/natpmp_portscan.rb
  • modules/auxiliary/fuzzers/ntp/ntp_protocol_fuzzer.rb

(Not affected: railgun.ws2_32.sendto calls are Windows API calls via Railgun, unrelated to Ruby's Socket#sendto.)

Each of these should be updated to use send(mesg, flags, host, port) instead of sendto(mesg, host, port, flags).

Metasploit version

Source install, git log -1 --pretty=oneline:

7fca144afc75d935a49ea5de56d822aee2e53b8d Merge pull request #21740 from dwelch-r7/fix-json-rpc-payload-testf

Additional Information

Not encountered inside msfconsole directly — surfaces as a Ruby warning (older Ruby) or hard crash (Ruby 4.0+) any time one of the affected UDP send paths is hit.

Source: rapid7/metasploit-framework