-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
weechat relays give remote code execution rights #928
Comments
|
Since the exec.so file is part of the weechat-plugins package in debian, the last step of the workaround should actually be Also, I don't think that As I understand it, all of the different language plugins are all for running scripts, so they depend on the script plugin to get the code to run, and then load. So a manual disabling of the script plugin once all desired scripts have been installed and loaded effectively disables all of these script plugins as potential ways of pulling off a RCE. And, without having tested it at all, the file transfer capacity of the xfer plugin seems like it could maybe bring in some code, and disabling it doesn't seem like it would break anything, so that would probably be a good idea too. Also the trigger plugin says "execute one or more commands" in its description, so that one too. So once desired scripts have been setup, this should hopefully harden weechat against the kinds of attacks via a less-trusted relay (a phone!) that are being raised in this issue, while still leaving it pretty fully featured: And then "/plugin unload" for all of these within weechat. Of course, changing the scripts that are running in weechat will then require a manual enabling and then loading of the scripts plugin. Since these are all installed via the weechat-plugins package, the |
|
I do not know if I have modified the original post to cover the mistakes you have outlined, thanks! |
|
Hi, The weechat protocol allows client to display a GUI and let the user enter commands exactly like if it was locally in WeeChat itself. Restricting allowed commands in relay client is not easy, because /exec or scripts can be indirectly called by other commands (like triggers, /script, ...). I think it's better to protect correctly the relay plugin, by using a non-standard port, restricting IP allowed, and of course setting a strong and secure password (which is NOT saved on the client side for maximum security). If needed, we can think about even more security on the relay plugin, which is for me a better solution than trying to restrict what the client can do. Running commands via /exec and the relay client is similar than a SSH access on your box with a SSH key (and optional password). If someone get your device, he can connect as your user and do anything with the shell. As a conclusion, I would remind that relay plugin is purely optional and never enabled by default in WeeChat. So when it is enabled, the user is responsible to secure it correctly (as I mentioned above) to prevent any problem. Ideas are welcome to protect even more connections from relay clients. |
|
you assume the client is trusted. what i am saying is this is a false assumption: people are not aware that the client can run all those commands, and are pretty liberal about what machines they authorize to connect to the weechat relay. regarding the protection you are proposing users do:
even worse: the client, by default connects in the clear, over plaintext TCP, to the relay port. this allows arbitrary commands to be injected through through TCP session hijacking. arguably, any sane person wouldn't do that and would instead setup a VPN or SSH bridge below that, but instructions like the Weechat Android guide don't even mention that. I am really not sure people are aware that the relay service provides such capabilities. it seems to me it would be really important to clarify, in the documentation, that the and SSH is different: there are ways to craft SSH credentials (through besides, i am deliberately not giving SSH access on the box when i setup a Weechat relay: the point is exactly to provide limited functionality, namely to chat with people and not run arbitrary commands. you can call this a feature all you like, I certainly did not think of Weechat relays as remote shells. if they are, that should really be clarified, especially considering some people use public web interfaces that they do not even control themselves to connect to their own Weechat relays... basically, anyone using glowing-bear.org is giving them a shell on their local relay. if that's considered acceptable security practices in the weechat project, that makes me seriously question the practices elsewhere in the project... are there any hidden shells like this in other parts of the client that we should know about? |
|
to clarify, the kind of attack i am thinking of, once someone has control over a weechat client (through TCP session hijacking, stealing your phone or script injection on glowing bear), is some nasty shit like: that would give anyone a remote shell on the server running weechat on port 19992. nice feature. one has to wonder who would want to make something like that even possible... |
|
First, security is not an option in WeeChat, it's very important. As I said, relay gives the client exactly same rights as WeeChat itself, it was designed like that. And it assumes clients are trusted, that's why it's protected by IP and/or password, and of course SSL support. If you want restricted access, there are 3 solutions:
Another thing, there is nothing in plain text by default: there is no IRC server by default in WeeChat (since version 1.2), and no relay. When you define the relay, you can of course use SSL (and I recommend that). This is explained in I'm OK to mention in docs clearly that with weechat relay protocol you can run any command. |
|
i'm just going to give up here because it seems we have drastically different views on how this should work. i understand your point that weechat relay system is not designed to restrict commands, and i'm not arguing about that. what I am arguing is that the design is fundamentally flawed and urgent action is required to avoid serious security issues. but just to be clear:
My recommendations would be:
Unfortunately, I do not have the time nor the energy to go through this whole process myself. This issue made me avoid weechat completely and i'm happy to be using another client right now. I just opened this issue to document it for my fellow IRC users that recently switched to Weechat without being aware of this design issue. |
|
So my answers:
About your recommendations:
|
|
@ashkitten You didn't really read what @flashcode said, did you? If you want something like irssi-proxy use /relay add ssl.irc, which acts as a pure irc proxy with all networks in one connection. |
|
(Just passing by.)
You can instruct dpkg to mark the renaming of the file as permanent with: This will rename the file to |
|
I think the main issue here is that people confuse Weechat's Relay mode with a standard bouncer like ZNC or psyBNC, when instead it provides an interface more akin to SSH or VNC. |
|
well, weechat relay has some advantages over IRC relay mode.. I use the weechat relay as well and I would prefer having weechat relay over IRC relay for all my relays, but this code execution is ridiculous. small addition: Weechat supports since 2.4 TOTP. This way you can secure your weechat relay with a unique password and TOTP as second factor. The client needs to support it. |
|
To mitigate the problem, I'll add a new option The default value could be something like Note: commands indirectly called via aliases or scripts will also be affected (ie allowed or excluded, according to the value of the new option). |
|
This is great, thanks @flashcode! Just pointing out that one would likely want to add |
|
@mhoran: you're right. For maximum security, I'll disable these commands as well: |
Commands were already forbidden (option relay.weechat.commands): - /exec - /upgrade - /quit These extra commands are now forbidden by default: - /fset - /set - /unset - /plugin - /script - /python - /perl - /ruby - /lua - /tcl - /guile - /javascript - /php - /secure
|
i propose a whitelist instead of a blacklist for the default setting. if someone is trying to execute malicious code, they'll likely spend considerable time investigating their options, and blacklisting gives them plenty of commands to work with fwiw running |
|
@oakkitten: for Using a whitelist is harder, I just counted about 131 commands that should be allowed, while 26 should be forbidden (if we count aliases as well). So the list of allowed commands would be extremely long. |
|
what i suggested was not whitelisting all commands but a small number of handpicked commands that are surely safe, such as when an evildoer is able to execute relay commands, they are either a
in the latter case the owner of the server can change the password as they will surely notice a missing phone, so we can ignore that. that leaves us with an evildoer that can do 1. or 2.—someone who is pretty good at what they are doing. so if you want to protect the relay server, it doesn't make much sense to just blacklist some of the most obvious dangerous weechat commands. you'd have to go through all commands and carefully examine them, and also scripts; that would take a great amount of time and some things will probably get missed anyway. so a blacklist is a poor solution a whitelist by default would be much easier to do right. (for weechat-android, one caveat is that it uses the |
|
If I'm reading the current relay-config.c right, it looks like |
…issue #928) The relay client is supposed to be safe by default, and the relay connection should be protected by the different ways (restriction on IP address, SSL, strong password, Time-based One-Time Password, local bind address and use of SSH tunnel…). So this option lets the user add extra security by allowing only some commands (whitelist), or allowing any commands except a list of given commands (blacklist).
…928) The whole command with arguments and the full buffer name are now displayed in the warning message (in debug mode only).
|
In the latest commits related to this issue, I finally removed the default value in the option, so all commands are allowed by default (like in the latest stable version). |
this IRC conversation made me gave up on relays and, incidentally, weechat itself:
in other words, if i hook up my Android phone to a Weechat instance using the "weechat"
relayprotocol, i give that phone execution rights to the machine running the weechat instance, as the user running weechat. the impact of this is huge: if you lose that phone, that device can then be used to infiltrate your network. the communication channel can also be attacked to try and abuse that new attack surface.i do not believe users expect this from the weechat relays. 2 new users that were happy to start using Weechat did not know about this feature and were really surprised to hear about
/exec(which they didn't know about at all). a friend proposed the following workaround:but one should note this will fail when the package is updated. in Debian, this can be worked around with
apt-mark hold weechat-plugins, but then upgrades are completely disabled, which is a security issue in itself.note that, on top of deleting the
execplugin, you will probably also want to disable any scripts plugin, that is lua, python, perl, ruby, tcl, guile, javascript... and probably xfer as well. at that point, you will have disabled most of the extra functionality in weechat and it suddently looks much less interesting.i therefore strongly petition the weechat team to consider setting the relay protocol to allow setting a allow_list of
/commandsallowed to certain relays, that defaults to "none" or maybe just/me,/join,/part, and so on...The text was updated successfully, but these errors were encountered: