2

I am currently writing a network multiplayer game that uses a lobby system to find available matches for players to join. The list of available matches is served and updated by a web application via a simple REST API.

For example, when a player enters the lobby and creates a new match for other players to join, the game will send a POST request to the web application, which will add the match to the list. For another example, if this same player then decides they don't want to host a match, they would click a button that says "cancel match" or something like that. The game will send a DELETE request to the web application, which will remove the match from the list.

As far as security goes, I'm concerned that a smart player would be able to figure out how to use the API for my web application via cURL (or some other tool for making HTTP requests) to send malicious requests (like removing someone else's match from the list, for example). To state my goals clearly: I want my web application to be able to verify that incoming requests are coming from the game, and not from some other application like cURL, before processing them.

My instincts tell me that the best solution is to use a JWT token. The game will authenticate itself to the web application, which will generate a token and give it to the game. Then, the game will provide the token every time it makes a request. The question is: how do I get the game to authenticate itself (and, thus, receive a token from the web app) in a way that a malicious user couldn't do using a tool like cURL?

Anders
  • 64,406
  • 24
  • 178
  • 215
  • 3
    Possible duplicate of [Ensure web service only accessed by authorized applications](https://security.stackexchange.com/questions/42586), [How to ensure that only my single page app can make requests to an API](https://security.stackexchange.com/questions/64055/), [How can I set my server to only accept requests from my own client app?](https://security.stackexchange.com/questions/81838/) and [others](https://www.google.com/search?q=site%3Asecurity.stackexchange.com+make+sure+requests+comes+from+application). – Steffen Ullrich Oct 08 '18 at 20:51
  • 1
    Rather than trying to make sure the request comes from the game, a better approach may be to make sure it doesn't matter where the request comes from. Make players authenticate by logging in with a user+pass and receive a token. When you receive a request make a check to see if the user of that token is authorised to delete that match e.g. is the requestor the same as the person who created it. – Daisetsu Oct 08 '18 at 21:42

0 Answers0