Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

request.remote_ip/X-Forwarded-For may not be an IP

#6438

hi,

X-Forwarded-For headerfield isn't sanatized if the request comes from a class c network.

i made a poc screencast that shows the bug with the latest rails version with devise and shows more possible attacks

http://webservsec.blogspot.com/2011/02/ruby-on-rails-vulnerability....

quick-fix for internal web-apps:
check request.remote_ip before you use it

best regards
J

Reported by banditj · February 16th, 2011 @ 02:41 AM

State: new
Milestone: 3.0.6
Assigned to: nobody
Importance: Low

Activity

  1. Michael Koziarski
    Michael Koziarski
    • Milestone set to 3.0.5
    • Importance changed from to Low

    The attack vectors they're talking about there assume no one does any sanitization. SQL Injection, shell script exploits etc only apply if people don't check those inputs.

    There's certainly a bug here, but it's not a security bug.

    February 16th, 2011 @ 10:22 PM

  2. Michael Koziarski
    Michael Koziarski
    • Title changed from rails security bug - request.remote_ip/X-Forwarded-For not sanitized to request.remote_ip/X-Forwarded-For may not be an IP

    February 16th, 2011 @ 10:29 PM

  3. Santiago Pastorino
    Santiago Pastorino
    • Milestone changed from 3.0.5 to 3.0.6

    February 27th, 2011 @ 03:15 AM

  4. Christopher Meiklejohn
    Christopher Meiklejohn

    Is the issue here just that the input isn't validated as an actual IP address?

    March 3rd, 2011 @ 04:23 AM

  5. alindeman
    alindeman

    I'd be happy to help fix this, but there are a existing few tests that make me wonder what the expected behavior is:

    request = stub_request 'HTTP_X_FORWARDED_FOR' => 'unknown,192.168.0.1'
    assert_equal 'unknown', request.remote_ip
    

    As the tests are written, it seems like returning a string (non-IP) was thought about. What's the expected behavior here then?

    March 26th, 2011 @ 03:19 PM