"Hmm, we don't really test or fuzz LibIPC, let's see if I can find something weird with it."
…
Oh no.
// attack.cpp
#include <LibCore/EventLoop.h>
#include <LibCore/LocalSocket.h>
#include <unistd.h>
int main()
{
Core::EventLoop loop;
auto socket = Core::LocalSocket::construct();
socket->set_blocking(true);
socket->connect(Core::SocketAddress::local("/tmp/portal/window"));
u8* buf = (u8*)malloc(MiB);
memset(buf, 0xff, MiB);
socket->write(buf, MiB);
return 1;
}
There are several issues, probably not all exposed by the above attacker:
m_unprocessed_messages
queue is effectively unbounded. This isn't really a problem yet, as they will usually be processed (and thus removed) very quickly. However, wait_for_specific_endpoint_message
allows for receiving and storing arbitrarily many messages. In clients, this isn't a problem, and servers usually send async messages, so they don't call it. With two big exceptions:
wait_for_specific_message<Messages::WindowClient::FastGreet>()
.ConnectionBase::wait_for_specific_endpoint_message_impl
might also accidentally quadratic: We keep re-checking all messages again and again on each wakeup, even though I don't think any messages are being processed. I might be wrong about the latter point though, since WindowServer clearly still works while waiting for a specific message.So I guess the following fixes are a good idea:
wait_for_specific_endpoint_message
able to give up. In particular, ConnectionBase::wait_for_specific_endpoint_message_impl
contains an infinite loop. If more than X (maybe 10?) messages arrive, I think the peer probably won't send one, and can be considered malicious.m_unprocessed_messages
we are, and only start checking messages from there. Afterall, messages are not processed while this method is ongoing.Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too