# CVE-2026-46727: Use-after-free in pthread-based getaddrinfo timeout handler

DevFeed: [CVE-2026-46727: Use-after-free in pthread-based getaddrinfo timeout handler](<https://devfeed.tech/articles/cve-2026-46727-use-after-free-in-pthread-based-getaddrinfo-timeout-handler-19152.md>)

Original publisher: [Read original article](<https://www.ruby-lang.org/en/news/2026/05/20/getaddrinfo-cve-2026-46727/>)

Published: 2026-05-20T00:00:00Z

Content type: release

Language: en

Sources: [Ruby-lang](<https://devfeed.tech/sources/ruby-lang.md>)

Topics: [Vulnerabilities](<https://devfeed.tech/topics/vulnerabilities.md>), [Memory Safety](<https://devfeed.tech/topics/memory-safety.md>), [cve remediation](<https://devfeed.tech/topics/cve-remediation.md>)

Tags: [2026](<https://devfeed.tech/tags/2026.md>), [crash](<https://devfeed.tech/tags/crash.md>), [cve](<https://devfeed.tech/tags/cve.md>), [delay](<https://devfeed.tech/tags/delay.md>), [dns](<https://devfeed.tech/tags/dns.md>), [fixed](<https://devfeed.tech/tags/fixed.md>), [memory](<https://devfeed.tech/tags/memory.md>), [race-condition](<https://devfeed.tech/tags/race-condition.md>), [remote](<https://devfeed.tech/tags/remote.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [security](<https://devfeed.tech/tags/security.md>), [socket](<https://devfeed.tech/tags/socket.md>), [tcp](<https://devfeed.tech/tags/tcp.md>), [timeout](<https://devfeed.tech/tags/timeout.md>), [update](<https://devfeed.tech/tags/update.md>), [upgrade](<https://devfeed.tech/tags/upgrade.md>), [utc](<https://devfeed.tech/tags/utc.md>), [workaround](<https://devfeed.tech/tags/workaround.md>)

## AI overview

A race in Ruby's pthread-based getaddrinfo timeout cancellation can cause a use-after-free and crash when a remote attacker delays DNS responses near the timeout. It affects Ruby 4.0.0-4.0.4 and Ruby 4.1.0-dev before the fix; Ruby 3.4 and earlier are stated to be unaffected. Upgrade to Ruby 4.0.5 or later. Until then, avoid the timeout: option in Addrinfo.getaddrinfo and resolv_timeout: in Socket.tcp. The supplied text is excerpted and omits some API names in its details, which are given in the source summary.

## Source excerpt

A use-after-free vulnerability has been discovered in the pthread-based getaddrinfo timeout handler of Ruby. This vulnerability has been assigned the CVE identifier CVE-2026-46727. This issue has been fixed in Ruby 4.0.5. We recommend upgrading Ruby. Details A race condition exists in the timeout cancellation path of rb_getaddrinfo used by Addrinfo.getaddrinfo(..., timeout:) and Socket.tcp(..., resolv_timeout:). A remote attacker who can delay DNS responses near the specified timeout may cause the Ruby process to dereference freed memory and crash. Recommended action Please update to Ruby 4.0.5 or later. Workaround If you cannot upgrade immediately, avoid passing timeout: to Addrinfo.getaddrinfo and resolv_timeout: to Socket.tcp. Affected versions Ruby 4.0.0 through 4.0.4 Ruby 4.1.0-dev (master) before the fix Ruby 3.4 series and earlier are not affected. Credits Thanks to cantina-security for discovering this issue. Also thanks to shioimm for creating the patch. History Originally published at 2026-05-20 00:00:00 (UTC) Posted by hsbt on 20 May 2026