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

Closed
EdOverflow opened this issue Nov 7, 2017 · 1 comment
Closed

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

EdOverflow opened this issue Nov 7, 2017 · 1 comment

Comments

@EdOverflow
Copy link
Contributor

@EdOverflow EdOverflow commented Nov 7, 2017

Description

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("127.0.0.1")
=> ["127.0.0.1"]
irb(main):003:0> Resolv.getaddresses("localhost")
=> ["127.0.0.1"]
irb(main):004:0> Resolv.getaddresses("127.000.000.1")
=> ["127.0.0.1"]

馃捇 Machine 2

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

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

Mitigation

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]
=> "127.0.0.1"
@EdOverflow
Copy link
Contributor Author

@EdOverflow EdOverflow 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant