Skip to content Skip to sidebar Skip to footer

Multiple Responses In Twisted

I'm trying to develop simple TCP, clinet/server game using Twisted and Pygame, but I have difficulties with sending data to clients. Twisted doesn't allow me to send multiple respo

Solution 1:

Your server has a remote arbitrary code execution vulnerability in it.

There are very few - if any - circumstances under which you should unpickle data received from the network. Doing so allows any peer to hijack your server for arbitrary, perhaps malicious, purposes. Note the big red box in the pickle documentation.

Apart from this serious security issue, the problem you're having with only the first piece of data being sent being interpreted is probably caused by the two pieces of data being joined together as they traverse the network. Your receiving code has no proper framing support, so it can't tell there are two messages. It so happens that pickle will load data from the first message and ignore the extra data afterwards which represents the second message, effectively dropping that data on the floor.

Both the security problem and the framing problem can be solved if you switch to a more expressive protocol (more expressive than bare TCP transporting unframed pickle strings), for example AMP.

Post a Comment for "Multiple Responses In Twisted"