mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
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:
@@ -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?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user