Skip to content

Honor AI_NUMERICHOST in Socket.getaddrinfo - #9801

Open
sampokuokkanen wants to merge 1 commit into
jruby:masterfrom
sampokuokkanen:getaddrinfo-ai-numerichost
Open

sampokuokkanen wants to merge 1 commit into
jruby:masterfrom
sampokuokkanen:getaddrinfo-ai-numerichost

Conversation

@sampokuokkanen

Copy link
Copy Markdown
Contributor

The flag was ignored, so a host name went to InetAddress.getAllByName and was resolved through DNS instead of raising SocketError. Code that uses AI_NUMERICHOST to tell address literals from names (surfguard's SSRF guard, for one) then treated resolved names as literals. Only IPv6 and decimal IPv4 literals are accepted with the flag now, before any lookup.

The added specs pass on MRI, this was found when running ONCE Campfile on JRuby. https://github.com/basecamp/once-campfire/blob/05c5a2c0d72f7fd74d7c2ace23cc123000f956b9/lib/restricted_http/private_network_guard.rb#L20-L23 this bug is hit inside the Surfguard gem.

The flag was ignored, so a host name went to InetAddress.getAllByName
and was resolved through DNS instead of raising SocketError. Code that
uses AI_NUMERICHOST to tell address literals from names (surfguard's SSRF
guard, for one) then treated resolved names as literals. Only IPv6 and
decimal IPv4 literals are accepted with the flag now, before any lookup.
@kares kares added this to the JRuby 10.1.3.0 milestone Oct 13, 2026
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.

2 participants