4

Disclaimer

If this question is ridiculous it's because secure public key exchange sounds impossible before you learn about it. So I'm asking about things that may be impossible.

Question

Is it possible to drop a secure connection for plain text while maintaining a trusted connection. Meaning the server knows the player's requests are still his and the player knows game information is still the players.

Background

I am writing some small JavaScript multiplayer games that will have authenticated users (Persistent user accounts across games). Since the server is resource limited on the computing side I would like to drop down to an unencrypted connection for game data. I am wondering if that is possible without opening myself up to very easy client or server spoofing attacks (JavaScript client).

Main Concern

User Trading in games seems particularly risky but is in development. Especially if I monetize a game linked to trading in the future. There may be enough incentive to fake a client sending valid but self damaging trades or spoof game information making misinformation scams possible.

Additional Information

Since I already can't trust the client (as it's written in JavaScript) game state is always server side and clients can only send requests which are evaluated for validity.

Some small games are already written and authentication is currently handled on the site which is running over https and is completely separate from the game servers. I'm in the process of bringing them together though no.

Fun distributed solution?

Although I don't have the resources, time or prerequisite knowledge to implement it, if trading was run through a series of DAPPS (On the ether block-chain) To my understanding all my concerns would be rectified at the expense of needing to spend real money on transactions.

  • Have you measured what the impact of HTTPS is on your server's performance, or is this just a hypothetical concern? – Ajedi32 Sep 27 '18 at 19:14
  • This isn’t what you asked, but is there anything stopping you from using an SSL websocket? I’d recommend socket.io, it supports this out of the box. SSL encryption isn’t really that heavy on the server, and I’d highly recommend you don’t use plaintext for anything that needs to be authenticated. – Kevin Sep 28 '18 at 2:34
  • This is an hypothetical concern as I read elsewhere that HTTPS may add overhead and the server sometimes does choke due to very low cpu resource allocation. It's currently serving web pages only through HTTPs and game data through unencrypted websockets (Relevant Multiplayer Traffic hasn't been pushed to the online server yet, just tested locally) so using socket.io and making them encrypted is a good idea, just haven't implemented any of the planned game encryption yet. – Sarzorus Sep 28 '18 at 14:58
5

Is it possible to drop a secure connection for plain text while maintaining a trusted connection.

No.

Since the server is resource limited on the computing side I would like to drop down to an unencrypted connection for game data.

It sounds like you need to do some profiling and optimizing, but I can almost guarantee that TLS isn't going to be the bottleneck.

I am wondering if that is possible without opening myself up to very easy client or server spoofing attacks (JavaScript client).

Nope (technically it may be possible, but it's really not worth it, and there's a good chance you'd do it wrong anyway).

Since I already can't trust the client (as it's written in JavaScript) game state is always server side and clients can only send requests which are evaluated for validity.

You're right that you can't trust the client, but not because it's JavaScript. Even if you try to make reverse engineering more difficult, you can't make it impossible.

Although I don't have the resources, time or prerequisite knowledge to implement it, if trading was run through a series of DAPPS (On the ether block-chain) To my understanding all my concerns would be rectified at the expense of needing to spend real money on transactions.

Blockchains do have some useful properties, but there's also a substantial amount of hype. Blockchains aren't going to magically solve all of your problems.

2

Is it possible to drop a secure connection for plain text while maintaining a trusted connection?

This is possible. You could give the user an encryption key during your TLS connection, which can then be used to perform (symmetric) encryption and/or authentication (MAC). However, this would require you to build your own crypto. And the first thing you learn in any crypto 101 is to never roll your own crypto. Plus, if you add this extra layer anyway, you might as well use TLS, because chances are small you write tight crypto and have it be faster than a widely used crypto library.

In fact, you would be using the same technique TLS is using; after the initial public/private key exchange the TLS protocol generates keys for symmetric encryption to speed up communications.

Keep in mind that users can always spoof their own traffic so you should validate all user input, regardless if they are using TLS. In order to spoof someone else's plaintext traffic, an attacker would need to perform a Man-in-the-Middle attack.

  • I think OP stating "plain text" puts encryption out of the picture. You would be correct if OP stated that he wanted to get rid of TLS, but that's not the case. OP wants to start the session under TLS and fall to clear text after that. – ThoriumBR Sep 27 '18 at 19:40
  • That's exactly what I'm describing. OP states "Meaning the server knows the player's requests are still his". This can be done by exchanging a crypto key during the TLS connection, then dropping to plain HTTP (without TLS), and using custom crypto to ensure message integrity, etc. – Graa Sep 27 '18 at 20:18
1

Is it possible to drop a secure connection for plain text while maintaining a trusted connection.

No, it's impossible. In clear text, that's no way to the server to prevent data from being altered, in any direction.

Since the server is resource limited on the computing side I would like to drop down to an unencrypted connection for game data.

TLS is not resource intensive anymore. If that is really a concern, you can offload the TLS encryption to another server or service, like Cloudflare, for example. But any VPS or virtual machine can easily handle TLS. If your server cannot handle TLS, it surely cannot handle even a small fraction of your game logic.

Since I already can't trust the client (as it's written in JavaScript)

You cannot trust the client, no matter what language, technology or framework you use. Even if your client was running inside an ASIC, you should not trust data from the client.

if trading was run through a series of DAPPS

Don't. DAPPS are hard to develop, very difficult to maintain, and will not solve your problem in any way. Unless you want to lose the money of the players, pay someone with experience and credentials to develop this functions for you. Don't try to do all by yourself, or you will lose your time, money, and reputation. Either pay someone to do for you, or don't involve real money.

Dapps are not scalable, as Ethereum network currently cannot process even 50 transactions per second. After deploying a dapp, unless you specifically created it thinking on modifying its code, it's impossible to fix any bugs. There are a few techniques for it, like proxy contracts, but they greatly increase complexity and costs (development and processing costs). And a dapp is a very specific kind of mechanism, and must be used only when other technologies cannot solve the problem.

  • I am wondering if you could expand on DAPPS being difficult to maintain a little or point me in the right direction since that would directly make even paying someone to develop it a continuous investment? Appreciate TLS not being resource intensive especially on virtual machines since it's very relevant to my situation. Resources aren't always maxed, but specific situations do overload them temporarily (about 10 minutes of slowdown once a month) so I was worried about adding TLS overhead. – Sarzorus Sep 28 '18 at 14:38
  • TLS should use less than 1% of the processing power of your computer, so don't worry about it. Developing something to secure the connection without TLS will use more than this. – ThoriumBR Sep 28 '18 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.