No, this protocol is not secure.
A person in the middle can intercept the data sent by the client and send whatever it wants to the server, since you have not specified any mechanism for client authentication or message integrity verification.
Of course, you could study your protocol to fix these glaring problems, but there would be others. If you ever fix them all, you will have something that appears in TLS or SSH, so why not just start there?
@Petoj - the problem I focused on is that the server trusts the messages it receives; Your offer does not provide any security there. However, if you are concerned about privacy, you still have a problem, because MITM can send messages back and forth without changes until it sees what it wants to find, because you do not have confidentiality in client messages.
Your suggestion seems to be aimed at ensuring the integrity of messages from the client. You developed a protocol until the client cannot distinguish between attack and network failure. Instead of trying to help the client determine if the server was acting on a forged message, allow the server to check the integrity of the message before acting on it.
erickson
source share