Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
creating an anti cheat in an online web game

I have a simple website with a little game in it. It has a basic scoreboard using express - every time you die the website send a post request to the server with your score and the server adds it to the leaderboard. My problem is that its very simple for the leaderboard to be exploited. through devtools people can easily just:

  • disable the colliders so they cant die and then turning it back on when they are happy with the score
  • straight up just set the score to what ever value they want
  • use the console to send a post request of their own with a score of their choice

I thought about creating a server side score counter and collision checker but my game is fast paced so I think this would be problematic, not talking about the computing power that it would put on the server if multiple people play at the same time.

Is this really the only solution or are there simpler solutions I'm not thinking of?

server code:

const express = require('express');
const app = express();
const fs = require('fs');

const { json } = require('express');

app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(express.static('Build'))

app.get('/leaderBoard', (req,res)=>{
    var rawData = fs.readFileSync('./database.json');
    var data = JSON.parse(rawData);
    res.json(data);
})

app.post('/leaderBoard', (req, res)=>{
    var rawData = fs.readFileSync('./database.json');
    var leaderBoard = JSON.parse(rawData).leaderBoard;

    for(var i = 0; i < leaderBoard.length; i++){
        if(req.body.score > leaderBoard[i].score){
            for(let i2 = leaderBoard.length -1; i2 > i; i2--)
                leaderBoard[i2] = leaderBoard[i2-1];
            
            leaderBoard[i] = req.body;
            break;
        }
    }

    fs.writeFileSync("./database.json",JSON.stringify({leaderBoard},null,2));
})

app.listen(process.env.PORT || 3000);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A server side check would be imperative if you want to truly avoid any cheating... BUT, you could always make it harder to cheat on the client side with simple checks, like defining a maximum score change (for example if someone gains more than 100 points in 1 second, then he's cheating).

Using a minified code can't hurt, and you could also replace your variables name by abstract ones (a, b, c, instead of "score"). For that same reason, a collision check shouldn't just be defined by a true/false flag.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!