[Bug] Anti-cheat bug when deleting vehicles

Started by VK.Angel.OfDeath, Dec 29, 2020, 02:27 PM

Previous topic - Next topic

VK.Angel.OfDeath

Description
Now that updates are being made to VC-MP, I wanted to report an anti-cheat bug that can cause people to be incorrectly detected as an HP hacker. It occurs in the latest update as well as in previous client updates & server updates. I am using the latest plugins & the windows server (x86) from: https://forum.vc-mp.org/?topic=8223.0

See the steps below on how to reproduce it.

How to trigger the bug with the script
1. Use the code I provided at the bottom.
2. Enter the server and spawn. You should now be in world 10 and you should see a vehicle to the left of you.
3. Enter the vehicle.
4. Type /test or /testlag.

These commands will execute the following code:
- Set your HP to 100.
- Eject you from your vehicle. (Bug occurs with or without this code).
- If you're using /testlag it will print out 100 messages. This will take 4-8 ms to execute. If you're using /test this step will be skipped. I suggest trying with /test first and then see how the issue occurs more with /testlag.
- Delete the vehicle.
- Change your world to 0

5. If you don't get kicked type /veh once to re-create the vehicle.

6.  Repeat steps 1-5 multiple times. If /test doesn't work try with /testlag. It's a little harder to trigger it with /test.

7.  If everything is done correctly. You should receive the following message on your console:



Reproducible
Can be hard to reproduce. I believe the higher your ping is the easier it is to trigger this. I also believe that the execution time in /testlag also makes it easier to trigger the bug.

What you think caused the bug
My guess is that the anti-cheat system runs into some issue when your health increases to 100 at the same time as your vehicle gets deleted and/or your world gets changed.

Video
Using /test and /veh.

https://www.youtube.com/watch?v=wFwj_WjdKMQ&feature=youtu.be

Code

function onScriptLoad()
{
CreateVehicle(130, 10, -669.603, 738.837, 10.9447, 0, 0, 0);
}

function onPlayerCommand(player, command, arguments)
{
if (command == "exe")
{
local executee = compilestring("" + arguments);
executee();
}

else if (command == "veh")
{
player.World = 10;
player.Health = 50;
CreateVehicle(130, 10, -669.603, 738.837, 10.9447, 0, 0, 0);
}

else if (command == "test") TestAntiHack(0, 0);
else if (command == "testlag") TestAntiHack(0, 100);
}

function onPlayerJoin(player)
{
player.World = 10;
}

function TestAntiHack(id, Num)
{
local player = FindPlayer(0);
player.Health = 100;
player.Eject();
AntiHackTest(Num);
FindVehicle(1).Remove();
player.World = 0;
}

function AntiHackTest(num) // Increases the execution time of TestAntiHack
{
local testClock = clock();
for (local i = 0; i < num; i++) print("test");
print("" + (clock()-testClock));
}