I'm making a simple multiplayer game in Python. No personal/important data will be transferred between the server and client. I am using the Python sockets library to communicate between the client and the server.

However, I have done nothing special for security. I'm worried that someone could hijack the client-server connection of another player and control their actions in the game. Is this possible? Should this be a security concern, or are Python sockets safe from tampering?

  • How does the client identify itself to the server, such that the server can tell different clients apart? Does the player have to authenticate in any way, e.g. a password? Are you using TLS (HTTPS or otherwise) at all?
    – CBHacking
    Jul 30, 2022 at 1:47
  • @CBHacking When the client joins a server, a connection object is created which I can use to communicate with the client.
    – Some Guy
    Jul 30, 2022 at 3:32
  • In other words, you're just using the TCP session, which can be trivially spoofed by any man-in-the-middle, and you have no way to actually tell one player from another?
    – CBHacking
    Jul 31, 2022 at 12:09

1 Answer 1


Assuming this is a TCP connection, generally another player wouldn't be able to hijack the established client-server connection of another player.

However, someone controlling their network (the ISP of the player, the owner of the wifi it uses to connect, etc.) would be able to:

  • view the contents of all packets transferred (including any authentication data)
  • modify the commands sent
  • replace their connection with its own
  • MITM connections to the server

You could avoid this by doing your communication on top of TLS, instead of bare sockets.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .