Skip to content

Commit 57855c6

Browse files
committed
qrexec-daemon: check for valid messages from clients
This catches messages that would otherwise cause qrexec-agent to immediately terminate. It also logs an error if there is a port number in a non-MSG_SERVICE_CONNECT message, which should never happen.
1 parent 4f1e524 commit 57855c6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

daemon/qrexec-daemon.c

+13
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,19 @@ static int handle_cmdline_body_from_client(int fd, struct msg_header *hdr)
588588
goto terminate;
589589
}
590590
policy_pending[i].response_sent = RESPONSE_ALLOW;
591+
} else {
592+
if (hdr->type != MSG_JUST_EXEC && hdr->type != MSG_EXEC_CMDLINE) {
593+
// Sending such a message would just cause the agent to terminate.
594+
LOG(ERROR, "Invalid message type %" PRIu32 " from client", hdr->type);
595+
goto terminate;
596+
}
597+
if (params->connect_port != 0) {
598+
// This is wrong, so log it, but allow it in case any code relies
599+
// on it. I did not find any such code.
600+
LOG(ERROR, "Client provided port %" PRIu32
601+
" in non-MSG_SERVICE_CONNECT request (type %" PRIu32 ")",
602+
params->connect_port, hdr->type);
603+
}
591604
}
592605

593606
if (!params->connect_port) {

0 commit comments

Comments
 (0)