haxball / haxball-issues

115 stars 43 forks source link

[VULNERABILITY (player with admin rights does something that blocks the room) in headless-min.js] TypeError: Cannot read properties of undefined (reading 'Me') #1789

Open akmere opened 1 year ago

akmere commented 1 year ago

Hi. I have some hosts running on VPSs and out of a sudden for some of them I started getting this error. The room can be okay for few hours and then this happens. After this error room is visible but you cannot connect. image

It only started recently and I cannot associate it with any of my changes.

TypeError: Cannot read properties of undefined (reading 'Me') at J.Oe (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:73:336) at J.Rg (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:68:466) at Aa.Sh (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:99:488) at Object.apply (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:119:78) at Fa.nf (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:45:101) at Fa.zh (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:51:285) at Fa.wh (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:50:117) at a.$e (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:47:346) at Na.e.onmessage (https://html5.haxball.com/PFj3geCw/__cache_static__/g/headless-min.js:9:456)

akmere commented 1 year ago

I now associated this issue with the logins of some player. It only happens in the room when admin is given to people. Login is Dibtn Tpmbdfs, I don't know if that matters. So my educated guess is that admin is given to him and then he writes something that explodes the room. I log every message, but message from him is not logged so probably error happens when he writes something.

Summary: Player named Dibtn Tpmbdfs with admin writes something that destroys haxball.

guguxh commented 1 year ago

You need to send the script for us to see

akmere commented 1 year ago

@guguxh this error happens in headless.min.js, not in my script

guguxh commented 1 year ago

@guguxh this error happens in headless.min.js, not in my script

Thats can be cause your script causes this error by calling something wrong, or doing anything who cause the API to crash

akmere commented 1 year ago

@guguxh this error happens in headless.min.js, not in my script

Thats can be cause your script causes this error by calling something wrong, or doing anything who cause the API to crash

https://sharetext.me/ck5tt2vxhv

As I said one player is doing this deliberately (probably chatting something) when he has admin, room seems to have no issues otherwise. And great thanks for your attention, guguxh

wxyz-abcd commented 1 year ago

I now associated this issue with the logins of some player. It only happens in the room when admin is given to people. Login is Dibtn Tpmbdfs, I don't know if that matters. So my educated guess is that admin is given to him and then he writes something that explodes the room. I log every message, but message from him is not logged so probably error happens when he writes something.

Summary: Player named Dibtn Tpmbdfs with admin writes something that destroys haxball.

Easy: Just talk to him and learn what he writes. :)

I personally don't believe such a bug exists in Haxball. Therefore, the bug is probably on your code. As for what could cause it, I don't have a guess yet. Except if he changes the map, maybe? There IS the map bug, you know. Some maps are causing that behaviour when you load it. After that, the room is gone byebye. :) It's probably that one. I've also fixed that bug in my API, just in case. :)

akmere commented 1 year ago

Thanks @wxyz-abcd for mentioning this map bug. I googled something and yes, that was it exactly. #1473 . Although I couldn't find any solution in the code. I solved it by stopping the game and changing the map when room.getBallPosition() was throwing an error.

function getStats() {
        try {
        ballPosition = room.getBallPosition();
        point[1] = point[0];
        point[0] = ballPosition;
        ballSpeed = pointDistance(point[0], point[1]) * speedCoefficient;
        }
        catch(e) {
            console.log(e);
            room.stopGame();
            room.setDefaultStadium('Classic');
            sendMessage(`The bug map was set... Had to deal with it...`, undefined, Styles.ANNOUNCEMENT);
        }
    }
wxyz-abcd commented 1 year ago

Thanks @wxyz-abcd for mentioning this map bug. I googled something and yes, that was it exactly. #1473 . Although I couldn't find any solution in the code. I solved it by stopping the game and changing the map when room.getBallPosition() was throwing an error.

function getStats() {
      try {
      ballPosition = room.getBallPosition();
      point[1] = point[0];
      point[0] = ballPosition;
      ballSpeed = pointDistance(point[0], point[1]) * speedCoefficient;
      }
      catch(e) {
          console.log(e);
          room.stopGame();
          room.setDefaultStadium('Classic');
          sendMessage(`The bug map was set... Had to deal with it...`, undefined, Styles.ANNOUNCEMENT);
      }
  }

Yes, yours is a nice solution. But it would be much better if the game did not crash at all in the first place, wouldn't it? :) I have the better solution: use my API. You won't regret it. :D