3 ms·
Sabat, would you do the following for me? Turn on Rails. Open Firefox, type http://localhost:3000/a-malicious-string http://localhost:3000/a-malicious-string
by patio11 15y ago
Sabat, would you do the following for me?
Turn on Rails.
Open Firefox, type http://localhost:3000/a-malicious-string 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 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.
- rufugee 15y agoHelp 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.
- patio11 15y agoIt'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/rack/webconsole/repl.rb#L59 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.
- rednaught 15y agoIsn't this in the same vein as Ajaxterm/Anyterm? I suppose most uses of those (e.g. Slicehost/Linode) are behind SSL.
- tptacek 15y agoWhat difference are you supposing that would make?
- rednaught 15y agoI have preconceived ideas but I am not a security specialist by profession and hence the question. Perhaps you can explain instead of a downvote?
- mentat 15y agoSince 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.
- joeyespo 15y agoHmm. 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/ http://werkzeug.pocoo.org/docs/debug/
- rufugee 15y agoI'd be interested in this as well (as someone preparing to start a flask project)...
- joeyespo 15y agoAh 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.
- txus 15y agoI insist, this is fixed in version v0.0.5, thanks to your very warning.