Work around SSRF issue

Ingredients needed for the issue to occur are:

* an allowed IPv4 range
* a checked IPv6 address
* the checked address must be wrapped in HTTPX::Resolver::Entry

This leads to a failure in checking address inclusion by IPAddr.
This commit is contained in:
Jan Sandbrink
2026-06-05 09:45:04 +02:00
parent 396de9362f
commit 5689a105a0
+7 -1
View File
@@ -46,7 +46,13 @@ module OpenProject
end
def addresses=(addrs)
addrs.reject!(&SsrfProtection.method(:unsafe_ip_address?)) # rubocop:disable Performance/MethodObjectAsBlock
addrs.reject! do |addr|
# working around an error in IPAddr that fails to check address inclusion if the passed address is not an
# IPAddr, but a SimpleDelegator to an IPAddr (like HTTPX::Resolver::Entry).
addr = addr.address if addr.respond_to?(:address)
SsrfProtection.send(:unsafe_ip_address?, addr)
end
raise ServerSideRequestForgeryError, "#{@origin.host} has no public IP addresses" if addrs.empty?