News for hackers. Stuff that matters.
Re:Rack-webconsole: a Ruby/Rails console inside your browser by patio11 on Monday July 25, 2011 @11:21AM (#2802958)
Sabat, would you do the following for me?

Turn on Rails.

Open Firefox, type http://localhost:3000/a-malicious-string into the top bar. Hit enter.

Observe how that gets you a malicious string to your web server. This particular string will 404. I can construct much more interesting strings.

Now, notice that step where I told you a URL to type in? Pretend that, instead, I had control over some element of a webpage you were looking at. Any element would do. Say, you come to a blog where I control an image embed for my avatar, and I embed <img src="http://localhost:3000/a-malicious-string />. Firefox is going to make the HTTP request I desire without you having to do anything suspicious and without me having to ever talk to localhost:3000 directly.

After I have a malicious string in your web server, this application lets me execute arbitrary code as your web server. Things get very, very interesting then, in the "may you live in interesting times" sense of interesting. For example, one interesting thing I could do is read your SSH private key, which you use to connect from development to staging or production. Another thing I could do is read your database credentials from database.yml, and maybe even just open up extra ActiveRecord connections directly to those databases and start executing arbitrary SQL. Still another thing I could do is install a keylogger or rootkit on your local machine and wait to get whatever credential I need to totally compromise your company. There are many, many options.

Do not install this anywhere.

Re:Rack-webconsole: a Ruby/Rails console inside your browser by joeyespo on Monday July 25, 2011 @01:47PM (#2803679)
Hmm. What would you say about the Werkzeug debugger? It's been around a while but also allows in-browser console debugging.

http://werkzeug.pocoo.org/docs/debug/

Re:Rack-webconsole: a Ruby/Rails console inside your browser by rufugee on Monday July 25, 2011 @05:11PM (#2804656)
I'd be interested in this as well (as someone preparing to start a flask project)...
Re:Rack-webconsole: a Ruby/Rails console inside your browser by joeyespo on Monday July 25, 2011 @08:04PM (#2805317)
Ah Flask is pretty incredible. You could probably learn it and build a functional MVP by the time we get a decent answer. (And no, I'm not hinting that it'll take a long time for him to answer :)

You can turn off the console debugger though if it's making you uneasy by doing this:

    app.run('localhost', debug=True, use_evalex=False)
You'll still get the nice stack trace and code context, but without the ability to run arbitrary code.
Re:Rack-webconsole: a Ruby/Rails console inside your browser by rufugee on Monday July 25, 2011 @12:44PM (#2803372)
Help me understand this. In your example, how would this malicious string be any more worrisome with the console installed than without it? I realize you could trigger the console to be displayed by crafting a URL, but it would be displayed in my browser (and thus, localhost) as the consumer of your URL, correct? It'd be one thing if this gem caused any arbitrary query string to be executed as ruby code, but I don't believe it does. So help me understand the way you could exploit this?

I'm not doubting you...I'd simply like to understand. Thanks.

Re:Rack-webconsole: a Ruby/Rails console inside your browser by patio11 on Monday July 25, 2011 @01:14PM (#2803517)
It'd be one thing if this gem caused any arbitrary query string to be executed as ruby code

That's pretty much the exact designed intent of the software. Read the Repl code, specifically, Repl#call at line 59 or so.

https://github.com/codegram/rack-webconsole/blob/master/lib/...

You'll note the code has recently been enhanced with check_legitimate, which was designed to patch the issue I raised on this thread (and via email). I am going to very carefully avoid commenting about whether check_legitimate actually works as designed. My main worry is that pronouncing it done well would make me professionally responsible when it gets cracked, and committing to endless rounds of "Actually, that won't really work" throws good hours after bad in pursuit of securing a bad idea which is architecturally insecurable.

Do not allow your web application to execute arbitrary code. It will not end well.

Re:Rack-webconsole: a Ruby/Rails console inside your browser by rednaught on Monday July 25, 2011 @01:39PM (#2803650)
Isn't this in the same vein as Ajaxterm/Anyterm? I suppose most uses of those (e.g. Slicehost/Linode) are behind SSL.
Re:Rack-webconsole: a Ruby/Rails console inside your browser by tptacek on Monday July 25, 2011 @09:15PM (#2805521)
What difference are you supposing that would make?
Re:Rack-webconsole: a Ruby/Rails console inside your browser by rednaught on Monday July 25, 2011 @09:36PM (#2805586)
I have preconceived ideas but I am not a security specialist by profession and hence the question. Perhaps you can explain instead of a downvote?
Re:Rack-webconsole: a Ruby/Rails console inside your browser by mentat on Tuesday July 26, 2011 @01:57AM (#2806159)
Since the request is coming from an authorized user, then SSL won't matter any which way. The action the attacker is causing the user to take would be legitimate except the user doesn't actually want to do it. Check out CSRF.
Re:Rack-webconsole: a Ruby/Rails console inside your browser by rednaught on Tuesday July 26, 2011 @02:42AM (#2806256)
Thanks Mentat. Yup, I understand CSRF and current methods such as tokenization, double submit cookies, etc. I was trying to get an explanation from tptacek or patio11 about their statements about unprotected shells and arbitrary code.

The most voted comment is from patio11 about it being a very bad idea. A lot of discussion and hand-waving happened before finally CRSF was even mentioned. Once the author implemented a CSRF fix, the conversation seemed to quiet down. So is this kind of web-based access on the road to being safe and usable now? Many popular VPS hosts offer out-of-band access through web-based consoles such as Anyterm and Ajaxterm. Are those acceptable simply because they've taken care of the CSRF, XSS common issues? They allow arbitrary code on the remote boxes so how are they different from a security concern? I have no idea so I just threw out SSL even though it probably makes no bit of difference. I simply don't have the background or experience to know. Is it time to be concerned about how proficient the hosts are in securing their hypervisors and bridged networking for guests? If they do pose a concern, then why is there not more brouhaha about it to get some attention on the matter? Linode and Slicehost have a lot of customers...

To just say it is a bad idea and move on and not mention other implementations seems to leave a bad taste. Someone also asked about Werkzeug(of the Python demesne) as well...

Re:Rack-webconsole: a Ruby/Rails console inside your browser by mentat on Tuesday July 26, 2011 @12:05PM (#2807958)
The idea is that any sort of web console (that can be attacked with CSRF) is a really bad idea as it likely results in a complete compromise. Most web developers are not at all good at web security (case in point being this release with easy CSRF vulnerabilities). The likelihood that the same or similar mistakes will be introduced again later is high. The conservative approach is that, because the consequences of a failure are really bad, and because the level of convenience beyond an ssh shell is marginal, therefore you should never use web consoles. I guess if you were an expert at web security you could analyze a particular web console and say "yeah, it looks ok to me and I'm willing to take the risk." I think Patrick is saying that he doesn't see that being a worthwhile tradeoff for himself (as an expert) and therefore it seems particularly unwise for non-experts to be doing it.

There is some buzz about doing cloud to cloud attacks but I haven't heard anything that's been realized yet. I have also heard that there are issues with data staying resident on local disks on EC2 after machine termination, but I don't know if that's the case.

Re:Rack-webconsole: a Ruby/Rails console inside your browser by txus on Monday July 25, 2011 @06:18PM (#2804981)
I insist, this is fixed in version v0.0.5, thanks to your very warning.