Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolv::getaddresses bug allows one to bypass your SSRF filter. #1

EdOverflow opened this issue Nov 7, 2017 · 1 comment


None yet
1 participant
Copy link

commented Nov 7, 2017


Resolv::getaddresses is OS-dependent, therefore by playing around with different IP formats one can return blank values. This bug can be abused to bypass your exclusion list.

馃捇 Machine 1 馃捇 Machine 2
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu] ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

馃捇 Machine 1

irb(main):002:0> Resolv.getaddresses("")
=> [""]
irb(main):003:0> Resolv.getaddresses("localhost")
=> [""]
irb(main):004:0> Resolv.getaddresses("")
=> [""]

馃捇 Machine 2

irb(main):008:0> Resolv.getaddresses("")
=> [""]
irb(main):009:0> Resolv.getaddresses("localhost")
=> [""]
irb(main):010:0> Resolv.getaddresses("")
=> []

Proof of concept

irb(main):001:0> require 'private_address_check'
=> true
irb(main):002:0> PrivateAddressCheck.resolves_to_private_address?("127.1")
=> false # Bypass


I suggest staying away from Resolv::getaddresses altogether and using the Socket class.

irb(main):002:0> Resolv.getaddresses("127.1")
=> []
irb(main):003:0> Socket.getaddrinfo("127.1", nil).sample[3]
=> ""

This comment has been minimized.

Copy link
Contributor Author

commented Nov 8, 2017

This issue has been resolved in 58a0d7f.

@EdOverflow EdOverflow closed this Nov 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.